summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/pool.py
Commit message (Collapse)AuthorAgeFilesLines
* - Fixed critical issue whereby the pool "checkout" event handlerMike Bayer2015-07-221-0/+5
| | | | | | | | | | | | may be called against a stale connection without the "connect" event handler having been called, in the case where the pool attempted to reconnect after being invalidated and failed; the stale connection would remain present and would be used on a subsequent attempt. This issue has a greater impact in the 1.0 series subsequent to 1.0.2, as it also delivers a blanked-out ``.info`` dictionary to the event handler; prior to 1.0.2 the ``.info`` dictionary is still the previous one. fixes #3497
* - Fixed bug where in the case that a pool checkout event handler is usedMike Bayer2015-05-141-1/+7
| | | | | | | | | | | | | | | | | and the database can no longer be connected towards, that the checkout handler failure is caught, the attempt to re-acquire the connection also raises an exception, but the underlying connection record is not immediately re-checked in before the exception is propagated outwards, having the effect that the checked-out record does not close itself until the stack trace it's associated with is garbage collected, preventing that record from being used for a new checkout until we leave the scope of the stack trace. This can lead to confusion in the specific case of when the number of current stack traces in memory exceeds the number of connections the pool can return, as the pool will instead begin to raise errors about no more checkouts available, rather than attempting a connection again. The fix applies a checkin of the record before re-raising. fixes #3419
* - revise the last commit with a more traditional approachMike Bayer2015-04-301-29/+14
| | | | using descriptors; ensure that mock.patch() honors descriptor setters
* - work the wrapping of the "creator" to be as resilient toMike Bayer2015-04-301-8/+31
| | | | | old / new style, direct access, and ad-hoc patching and unpatching as possible
* - New features added to support engine/pool plugins with advancedMike Bayer2015-04-301-13/+73
| | | | | | | | | | | | | | | | | | | | | | | | | functionality. Added a new "soft invalidate" feature to the connection pool at the level of the checked out connection wrapper as well as the :class:`._ConnectionRecord`. This works similarly to a modern pool invalidation in that connections aren't actively closed, but are recycled only on next checkout; this is essentially a per-connection version of that feature. A new event :class:`.PoolEvents.soft_invalidate` is added to complement it. fixes #3379 - Added new flag :attr:`.ExceptionContext.invalidate_pool_on_disconnect`. Allows an error handler within :meth:`.ConnectionEvents.handle_error` to maintain a "disconnect" condition, but to handle calling invalidate on individual connections in a specific manner within the event. - Added new event :class:`.DialectEvents.do_connect`, which allows interception / replacement of when the :meth:`.Dialect.connect` hook is called to create a DBAPI connection. Also added dialect plugin hooks :meth:`.Dialect.get_dialect_cls` and :meth:`.Dialect.engine_created` which allow external plugins to add events to existing dialects using entry points. fixes #3355
* - add a warning to SingletonThreadPool that it isn't for general useMike Bayer2015-04-211-0/+13
|
* - Added the string value ``"none"`` to those accepted by theMike Bayer2015-04-211-1/+5
| | | | | | | | :paramref:`.Pool.reset_on_return` parameter as a synonym for ``None``, so that string values can be used for all settings, allowing .ini file utilities like :func:`.engine_from_config` to be usable without issue. fixes #3375
* - copyright 2015Mike Bayer2015-03-101-1/+1
|
* - Fixed bug in :class:`.Connection` and pool where theMike Bayer2015-02-041-0/+1
| | | | | | | | | :meth:`.Connection.invalidate` method, or an invalidation due to a database disconnect, would fail if the ``isolation_level`` parameter had been used with :meth:`.Connection.execution_options`; the "finalizer" that resets the isolation level would be called on the no longer opened connection. fixes #3302
* - wip - start factoring events so that we aren't using descriptors for dispatch,Mike Bayer2015-01-041-0/+1
| | | | allowing us to move to __slots__
* - correctionsMike Bayer2014-12-271-3/+3
| | | | - attempt to add a script to semi-automate the fixing of links
* cleanup exception handling - use new exception hierarchy (since python 2.5)pr/140ndparker2014-10-021-8/+4
|
* improve exception vs. exit handlingndparker2014-09-231-4/+4
|
* Fix doc typo 'conjunection'pr/130Gunnlaugur Þór Briem2014-08-211-1/+1
|
* - Fixed bug in connection pool logging where the "connection checked out"Mike Bayer2014-08-201-10/+12
| | | | | | | | debug logging message would not emit if the logging were set up using ``logging.setLevel()``, rather than using the ``echo_pool`` flag. Tests to assert this logging have been added. This is a regression that was introduced in 0.9.0. fixes #3168
* PEP8 style fixesBrian Jarrett2014-07-131-99/+115
|
* - break up the <authors> copyright comment as part of a passMike Bayer2014-07-091-1/+2
| | | | to get all flake8 passing
* - Fixed some "double invalidate" situations were detected whereMike Bayer2014-05-101-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | a connection invalidation could occur within an already critical section like a connection.close(); ultimately, these conditions are caused by the change in :ticket:`2907`, in that the "reset on return" feature calls out to the Connection/Transaction in order to handle it, where "disconnect detection" might be caught. However, it's possible that the more recent change in :ticket:`2985` made it more likely for this to be seen as the "connection invalidate" operation is much quicker, as the issue is more reproducible on 0.9.4 than 0.9.3. Checks are now added within any section that an invalidate might occur to halt further disallowed operations on the invalidated connection. This includes two fixes both at the engine level and at the pool level. While the issue was observed with highly concurrent gevent cases, it could in theory occur in any kind of scenario where a disconnect occurs within the connection close operation. fixes #3043 ref #2985 ref #2907 - add some defensive checks during an invalidate situation: 1. _ConnectionRecord.invalidate might be called twice within finalize_fairy if the _reset() raises an invalidate condition, invalidates, raises and then goes to invalidate the CR. so check for this. 2. similarly within Conneciton, anytime we do handle_dbapi_error(), we might become invalidated. so a following finally must check self.__invalid before dealing with the connection any futher.
* - work on fixing some race-condition failures:Mike Bayer2014-03-261-2/+5
| | | | | | | | | | | 1. make sure pool._invalidate() sets the timestamp up before invalidating the target connection. we can otherwise show how the conn.invalidate() + pool._invalidate() can lead to an extra connection being made. 2. to help with that, soften up the check on connection.invalidate() when connection is already closed. a warning is fine here 3. add a mutex to test_max_overflow() when we connect, because the way we're using mock depends on an iterator, that needs to be synchronized
* - A major improvement made to the mechanics by which the :class:`.Engine`Mike Bayer2014-03-221-19/+27
| | | | | | | | | | | | recycles the connection pool when a "disconnect" condition is detected; instead of discarding the pool and explicitly closing out connections, the pool is retained and a "generational" timestamp is updated to reflect the current time, thereby causing all existing connections to be recycled when they are next checked out. This greatly simplifies the recycle process, removes the need for "waking up" connect attempts waiting on the old pool and eliminates the race condition that many immediately-discarded "pool" objects could be created during the recycle operation. fixes #2985
* - Fixed small issue in :class:`.SingletonThreadPool` where the currentMike Bayer2014-03-051-3/+3
| | | | | connection to be returned might get inadvertently cleaned out during the "cleanup" process. Patch courtesy jd23.
* - don't duplicate docs for Pool within QueuePoolMike Bayer2014-01-311-71/+68
| | | | - add huge warning regarding how use_threadlocal probably not what you want
* - :class:`.Connection` now associates a newMike Bayer2014-01-121-12/+43
| | | | | | | | | | | | | | | | | | | | | | :class:`.RootTransaction` or :class:`.TwoPhaseTransaction` with its immediate :class:`._ConnectionFairy` as a "reset handler" for the span of that transaction, which takes over the task of calling commit() or rollback() for the "reset on return" behavior of :class:`.Pool` if the transaction was not otherwise completed. This resolves the issue that a picky transaction like that of MySQL two-phase will be properly closed out when the connection is closed without an explicit rollback or commit (e.g. no longer raises "XAER_RMFAIL" in this case - note this only shows up in logging as the exception is not propagated within pool reset). This issue would arise e.g. when using an orm :class:`.Session` with ``twophase`` set, and then :meth:`.Session.close` is called without an explicit rollback or commit. The change also has the effect that you will now see an explicit "ROLLBACK" in the logs when using a :class:`.Session` object in non-autocommit mode regardless of how that session was discarded. Thanks to Jeff Dairiki and Laurence Rowe for isolating the issue here. [ticket:2907]
* - add new event PoolEvents.invalidate(). allows interception of invalidationMike Bayer2014-01-121-17/+118
| | | | | | | | | | | | | | | events including auto-invalidation, which is useful both for tests here as well as detecting failure conditions within the "reset" or "close" cases. - rename the argument for PoolEvents.reset() to dbapi_connection and connection_record to be consistent with everything else. - add new documentation sections on invalidation, including auto-invalidation and the invalidation process within the pool. - add _ConnectionFairy and _ConnectionRecord to the pool documentation. Establish docs for common _ConnectionFairy/_ConnectionRecord methods and accessors and have PoolEvents docs refer to _ConnectionRecord, since it is passed to all events. Rename a few _ConnectionFairy methods that are actually private to pool such as _checkout(), _checkin() and _checkout_existing(); there should not be any external code calling these
* - happy new yearMike Bayer2014-01-051-1/+1
|
* - restore having the connection closed before decrementing the overflow counterMike Bayer2013-12-061-2/+4
|
* - The :class:`.QueuePool` has been enhanced to not block new connectionMike Bayer2013-12-061-31/+33
| | | | | | | | attempts when an existing connection attempt is blocking. Previously, the production of new connections was serialized within the block that monitored overflow; the overflow counter is now altered within it's own critical section outside of the connection process itself. [ticket:2880]
* move FAQ to the docs, [ticket:2133]Mike Bayer2013-08-211-4/+4
|
* - apply an import refactoring to the ORM as wellMike Bayer2013-08-141-3/+1
| | | | | | | | | - rework the event system so that event modules load after their targets, dependencies are reversed - create an improved strategy lookup system for the ORM - rework the ORM to have very few import cycles - move out "importlater" to just util.dependency - other tricks to cross-populate modules in as clear a way as possible
* - assorted fixes raised by pypy 2.1beta2, but all of which are goodMike Bayer2013-08-011-1/+2
| | | | | | | | | | | | | | | ideas in general: - pypy2.1 w/ sqlite3 is the first DBAPI we're seeing returning unicode in cursor.description without being py3k. add a new on-connect check for this, if we get back a u"", just don't do description decoding, should be OK for now. - the set tests in test_collection were assuming the two sets would be ordered the same when it tested pop(), can't really assume that. - test_serializer gets worse and worse, pickle is just not really viable here, ding out pypy - pypy2.1b2 seems to allow cursor.lastrowid to work (or we changed something?) - pool._threadconns.current() is a weakref, it can be None - another one of those logging.handlers imports
* Fixed bug where :class:`.QueuePool` would lose the correctMike Bayer2013-07-041-1/+6
| | | | | | checked out count if an existing pooled connection failed to reconnect after an invalidate or recycle event. Also in 0.8.3. [ticket:2772]
* - refactor pool a bit so that intent between ↵Mike Bayer2013-07-021-86/+112
| | | | | | | | | | | | | | ConnectionRecord/ConnectionFairy is clear; make sure that the DBAPI connection passed to the reset-on-return events/dialect hooks is also a "fairy", so that dictionaries like "info" are available. [ticket:2770] - rework the execution_options system so that the dialect is given the job of making any immediate adjustments based on a set event. move the "isolation level" logic to use this new system. Also work things out so that even engine-level execution options can be used for things like isolation level; the dialect attaches a connect-event handler in this case to handle the task. - to support this new system as well as further extensibiltiy of execution options add events engine_connect(), set_connection_execution_options(), set_engine_execution_options()
* Preserve reset_on_return when recreating a Pool.pr/6Eevee2013-06-101-0/+3
|
* Added pool logging for "rollback-on-return" and the less usedMike Bayer2013-06-091-6/+13
| | | | | | "commit-on-return". This is enabled with the rest of pool "debug" logging. [ticket:2752]
* a pass where we try to squash down as many list()/keys() combinationsMike Bayer2013-05-261-1/+1
| | | | as possible
* - the raw 2to3 runMike Bayer2013-04-271-6/+6
| | | | - went through examples/ and cleaned out excess list() calls
* - remove all compat items that are pre-2.5 (hooray)Mike Bayer2013-03-091-2/+2
| | | | | | - other cleanup - don't need compat.decimal, that approach never panned out. hopefully outside libs aren't pulling it in, they shouldn't be
* happy new year (see #2645)Diana Clarke2013-01-011-1/+1
|
* - recognize that do_rollback() and do_commit() work with a DBAPI connection,Mike Bayer2012-11-221-26/+50
| | | | | | | | | | | | | | | | | | whereas the other do_rollback_twophase(), savepoint etc. work with :class:`.Connection`. the context on these are different as twophase/savepoint are available at the :class:`.Connection` level, whereas commit/rollback are needed at a lower level as well. Rename the argument to "dbapi_connection" when the conneciton is in fact the DBAPI interface. - start thinking about being able to track "autocommit" vs. "commit", but not sure we have a need for this yet. - have Pool call out to a Dialect for all rollback/commit/close operations now. Pool no longer calls DBAPI methods directly. May use this for a workaround for [ticket:2611] - add a new Pool event reset() to allow the pool's reset of the connection to be intercepted. - remove methods in Informix dialect which appear to be hardcoding some isolation settings on new Transaction only; the isolation API should be implemented for Informix. also removed "flag" for transaction commit/rollback being not available; this should be based on server/DBAPI version and we will need someone with test access in order to help determine how this should work
* just a pep8 pass of lib/sqlalchemy/Diana Clarke2012-11-191-4/+20
|
* - [feature] Added support for .info dictionary argument toMike Bayer2012-08-241-17/+17
| | | | | | column_property(), relationship(), composite(). All MapperProperty classes have an auto-creating .info dict available overall.
* -whitespace bonanza, contdMike Bayer2012-07-281-48/+48
|
* absolute imports in core, sqlMike Bayer2012-06-231-3/+3
|
* - [bug] Fixed bug wherebyMike Bayer2012-06-221-33/+49
| | | | | | | | | | | | a disconnect detect + dispose that occurs when the QueuePool has threads waiting for connections would leave those threads waiting for the duration of the timeout on the old pool. The fix now notifies those waiters with a special exception case and has them move onto the new pool. This fix may or may not be ported to 0.7. [ticket:2522]
* - [feature] Dramatic improvement in memoryMike Bayer2012-06-201-1/+3
| | | | | | | | usage of the event system; instance-level collections are no longer created for a particular type of event until instance-level listeners are established for that event. [ticket:2516] Also in 0.7.9.
* Add some `Sphinx` paragraph level versions informations markups,Mike Bayer2012-06-081-22/+25
| | | | such as ``.. versionadded::``, ``.. versionchanged::`` and ``.. deprecated::``.
* typoDiana Clarke2012-03-161-1/+1
|
* accept the symbols so recreate worksMike Bayer2012-02-011-4/+5
|
* - [feature] Added pool_reset_on_return argumentMike Bayer2012-02-011-7/+48
| | | | | | | | to create_engine, allows control over "connection return" behavior. Also added new arguments 'rollback', 'commit', None to pool.reset_on_return to allow more control over connection return activity. [ticket:2378]
* - [bug] Added a boolean check for the "finalize"Mike Bayer2012-01-271-1/+1
| | | | | | | | | function within the pool connection proxy's weakref callback before calling it, so that a warning isn't emitted that this function is None when the application is exiting and gc has removed the function from the module before the weakref callback was invoked. [ticket:2383]