Commit Graph

68 Commits

Author SHA1 Message Date
Mike Bayer 9c64607572 - :class:.Connection now associates a new
: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]
2014-01-12 19:43:13 -05:00
Mike Bayer c91fd822bc - add new event PoolEvents.invalidate(). allows interception of invalidation
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
2014-01-12 17:34:20 -05:00
Mike Bayer d1cc78479d - The :class:.QueuePool has been enhanced to not block new connection
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]
2013-12-06 19:57:19 -05:00
Mike Bayer 003b288b76 - Made a slight adjustment to the logic which waits for a pooled
connection to be available, such that for a connection pool
with no timeout specified, it will every half a second break out of
the wait to check for the so-called "abort" flag, which allows the
waiter to break out in case the whole connection pool was dumped;
normally the waiter should break out due to a notify_all() but it's
possible this notify_all() is missed in very slim cases.
This is an extension of logic first introduced in 0.8.0, and the
issue has only been observed occasionally in stress tests.
2013-12-06 16:33:42 -05:00
Mike Bayer 604df86190 make sure thread.join() is used completely here 2013-11-30 16:54:44 -05:00
Mike Bayer 1a809b300e - apply a timeout to all join() calls for test_pool
- use thread.join() for waiters_handled test
2013-11-17 14:35:11 -05:00
Mike Bayer cdc9475b0b try to get this to pass on slow environmnets 2013-10-21 23:17:36 -04:00
Mike Bayer 08a6a8b519 - Removed some now unneeded version checks [ticket:2829] courtesy alex gaynor 2013-09-22 20:35:40 -04:00
Mike Bayer 59675be673 try seeing if just clearing this ahead of time helps 2013-07-27 18:32:38 -04:00
Mike Bayer 5dbe771922 further tweaking 2013-07-13 16:41:16 -04:00
Mike Bayer c896c75971 fix the scoping here 2013-07-13 16:37:10 -04:00
Mike Bayer f390639bf1 Fixed bug where :class:.QueuePool would lose the correct
checked out count if an existing pooled connection failed to reconnect
after an invalidate or recycle event.  Also in 0.8.3.
[ticket:2772]
2013-07-04 13:18:00 -04:00
Mike Bayer d3d10c982c - refactor pool a bit so that intent between 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()
2013-07-02 13:14:21 -04:00
Mike Bayer 38c5e870a7 mark the tests that seem to be segfauling py3k+coverage so that we can exclude them
at the nose command line
2013-06-30 23:55:32 -04:00
Mike Bayer b38a76cd1d - replace most explicitly-named test objects called "Mock..." with
actual mock objects from the mock library.  I'd like to use mock
for new tests so we might as well use it in obvious places.
- use unittest.mock in py3.3
- changelog
- add a note to README.unittests
- add tests_require in setup.py
- have tests import from sqlalchemy.testing.mock
- apply usage of mock to one of the event tests.  we can be using
this approach all over the place.
2013-06-30 18:35:12 -04:00
Eevee 23ce1d8b12 Preserve reset_on_return when recreating a Pool. 2013-06-10 15:04:39 -07:00
Mike Bayer cca97433c1 merge default 2013-05-05 01:42:26 -04:00
Mike Bayer 31792e86ae - cleanup
- move the timeout here to 14 seconds as jenkins still chokes occasionally
2013-05-05 01:39:35 -04:00
Mike Bayer 4b614b9b35 - the raw 2to3 run
- went through examples/ and cleaned out excess list() calls
2013-04-27 19:53:57 -04:00
Mike Bayer 0f0ce7c9b7 - recognize that do_rollback() and do_commit() work with a DBAPI connection,
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
2012-11-22 23:45:24 -05:00
Mike Bayer 20cdc64588 trying different approaches to test layout. in this one, the testing modules
become an externally usable package but still remains within the main sqlalchemy parent package.
in this system, we use kind of an ugly hack to get the noseplugin imported outside of the
"sqlalchemy" package, while still making it available within sqlalchemy for usage by
third party libraries.
2012-09-27 02:37:33 -04:00
Mike Bayer df7a3792f5 - add req's for predictable gc 2012-09-05 12:46:28 -04:00
Mike Bayer 393b294776 - [feature] Added support for .info dictionary argument to
column_property(), relationship(), composite().
All MapperProperty classes have an auto-creating .info
dict available overall.
2012-08-24 18:48:42 -04:00
Mike Bayer eaec7fd2b0 try to loosen the times up here to reduce failures due to latency 2012-07-17 09:32:11 -04:00
Mike Bayer 844831c14f notify_all workaround for 2.5 2012-06-25 14:25:36 -04:00
Mike Bayer 7b1a1a66cd - change notify to notify_all() so all waiters exit immediately,
continuing [ticket:2522]
2012-06-25 11:15:50 -04:00
Mike Bayer 5f0a7bb152 - [bug] Fixed bug whereby
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]
2012-06-22 12:24:08 -04:00
Mike Bayer 36e2b2d875 ensure sa_pool_key isn't passed to connect 2011-09-21 10:26:49 -04:00
Mike Bayer 9a2edbf3eb - The recreate() method in all pool classes uses
self.__class__ to get at the type of pool
    to produce, in the case of subclassing.  Note
    there's no usual need to subclass pools.
    [ticket:2254]
2011-08-14 11:55:32 -04:00
Mike Bayer e1ec36fc9e - hardcore force every connection into a strong-referenced set, rollback on every test, close on every context.
this uses pool events but bypasses the pool's fairy/record/dispose services.   pypy still seems to expose
some holes in that at least as far as what some (or maybe just one, cant find it yet) of the tests does.
haven't tested this too deeply, just on sqlite + postgres, cypthon 2.7 + pypy.   will see what the buildbot
says
2011-04-25 21:50:26 -04:00
Mike Bayer b80e9b805f - The "pool.manage" feature doesn't use pickle
anymore to hash the arguments for each pool.
2011-04-05 14:26:28 -04:00
Mike Bayer 68a350d462 - remove test.sql._base, test.engine._base, test.orm._base, move those classes to a new test.lib.fixtures module
- move testing.TestBase to test.lib.fixtures
- massive search and replace
2011-03-27 16:27:27 -04:00
Mike Bayer a294df9748 - Fixed bug in QueuePool, SingletonThreadPool whereby
connections that were discarded via overflow or periodic
cleanup() were not explicitly closed, leaving garbage
collection to the task instead.   This generally only
affects non-reference-counting backends like Jython
and Pypy.  Thanks to Jaimy Azle for spotting
this.  [ticket:2102]
2011-03-22 23:39:05 -04:00
Mike Bayer 852a1aef07 - Fixed AssertionPool regression bug. A replacement of finalize
logic did the wrong thing, but then also the logic it replaced also
doesn't seem like its needed.  If it is, would rather have a test case
first so its out for now, added tests for assertionpool.  [ticket:2097]
2011-03-16 18:15:27 -04:00
Mike Bayer 350aed3fdb - whitespace removal bonanza 2011-01-02 14:23:42 -05:00
Mike Bayer 426c4356eb - removes the "on_" prefix. 2010-12-30 14:22:43 -05:00
Mike Bayer 7f7bccfc83 - they don't want "on_". First step, change the naming convention on Events
so that non-events are just _name.
2010-12-30 13:43:39 -05:00
Mike Bayer d30678d18d new calling style: event.listen(target, identifier, fn) 2010-12-01 14:10:11 -05:00
Mike Bayer 58b2939433 - sqlalchemy.test and nose plugin moves back to being entirely
outside of "sqlalchemy" and under "test/".

Rationale:

- coverage plugin works without issue, without need for an awkward
additional package install
- command line for "nosetests" isn't polluted with SQLAlchemy options

[ticket:1949]
2010-11-28 14:19:44 -05:00
Mike Bayer e1402efb19 - move sqlalchemy.test to test.lib 2010-11-15 19:37:50 -05:00
Mike Bayer 4ac3240679 - SessionEvents is on board and the event model is done, can start building 0.7 tip soon 2010-11-14 17:51:54 -05:00
Mike Bayer 7513b46730 - pool event tests that don't depend on deprecated listener system,
attempting "test just one thing" style
- reorganize fixtures to come primarily from the base test class
2010-11-14 13:59:03 -05:00
Mike Bayer a9b270a3ed - basic docs
- poolevent accepts Engine as a target
2010-11-09 17:35:24 -05:00
Mike Bayer 4761b66cc1 ding 2010-11-07 12:54:54 -05:00
Mike Bayer 25c08f6def merge tip 2010-10-02 11:00:22 -04:00
Mike Bayer 761b4f29e2 - *Major* cleanup / modernization of the Informix
dialect for 0.6, courtesy Florian Apolloner.
[ticket:1906]
2010-10-01 21:26:05 -04:00
Mike Bayer 33b70a1f02 merge from tip 2010-09-03 17:57:20 -04:00
Mike Bayer 7d3a916fc3 - replaced all self.__connection.is_valid with
"safe" self._connection_is_valid.
- Fixed bug in Connection whereby if a "disconnect"
event occurred in the "initialize" phase of the
first connection pool connect, an AttributeError
would be raised when the Connection would attempt
to invalidate the DBAPI connection.  [ticket:1894]
- Connection.invalidate() can be called more than
once and subsequent calls do nothing.
2010-08-26 01:33:51 -04:00
Mike Bayer 87293d5b96 - reorganize events into cls->dispatch, which is an instance of _Dispatch.
cut down on extraneous stuff, cleanup
The Event class never gets instantiated and its methods stay the same
so that sphinx can get to it.
2010-08-10 00:19:50 -04:00
Mike Bayer a9288ca5bd working with how this will be documented and having some probs with sphinx 2010-08-09 20:49:08 -04:00