[Sqlalchemy-commits] sqlalchemy: - [bug] Fixed bug whereby if a database restart
Brought to you by:
zzzeek
From: <co...@sq...> - 2012-06-23 15:47:06
|
details: http://hg.sqlalchemy.org/sqlalchemy/sqlalchemy/rev/ee5fe8ec69f2 changeset: 8408:ee5fe8ec69f2 user: Mike Bayer <mi...@zz...> date: Fri Jun 22 12:42:01 2012 -0400 description: - [bug] Fixed bug whereby if a database restart affected multiple connections, each connection would individually invoke a new disposal of the pool, even though only one disposal is needed. [ticket:2522] Subject: sqlalchemy: callcounts, due to the DummyLock cleanup details: http://hg.sqlalchemy.org/sqlalchemy/sqlalchemy/rev/854d287b2c1a changeset: 8409:854d287b2c1a user: Mike Bayer <mi...@zz...> date: Sat Jun 23 11:46:47 2012 -0400 description: callcounts, due to the DummyLock cleanup diffstat: CHANGES | 6 ++++++ lib/sqlalchemy/engine/base.py | 5 ++++- test/aaa_profiling/test_pool.py | 6 +++--- test/engine/test_reconnect.py | 27 +++++++++++++++++++++++++++ 4 files changed, 40 insertions(+), 4 deletions(-) diffs (85 lines): diff -r 44d4aba1681f -r 854d287b2c1a CHANGES --- a/CHANGES Fri Jun 22 12:24:08 2012 -0400 +++ b/CHANGES Sat Jun 23 11:46:47 2012 -0400 @@ -157,6 +157,12 @@ the new pool. This fix may or may not be ported to 0.7. [ticket:2522] + - [bug] Fixed bug whereby if a database restart + affected multiple connections, each + connection would individually invoke a new + disposal of the pool, even though only + one disposal is needed. [ticket:2522] + - [feature] Added a new system for registration of new dialects in-process without using an entrypoint. See the diff -r 44d4aba1681f -r 854d287b2c1a lib/sqlalchemy/engine/base.py --- a/lib/sqlalchemy/engine/base.py Fri Jun 22 12:24:08 2012 -0400 +++ b/lib/sqlalchemy/engine/base.py Sat Jun 23 11:46:47 2012 -0400 @@ -1833,8 +1833,11 @@ if is_disconnect: + dbapi_conn_wrapper = self.connection self.invalidate(e) - self.engine.dispose() + if not hasattr(dbapi_conn_wrapper, '_pool') or \ + dbapi_conn_wrapper._pool is self.engine.pool: + self.engine.dispose() else: if cursor: self._safe_close_cursor(cursor) diff -r 44d4aba1681f -r 854d287b2c1a test/aaa_profiling/test_pool.py --- a/test/aaa_profiling/test_pool.py Fri Jun 22 12:24:08 2012 -0400 +++ b/test/aaa_profiling/test_pool.py Sat Jun 23 11:46:47 2012 -0400 @@ -32,9 +32,9 @@ # probably # due to the event mechanics being established # or not already... - @profiling.function_call_count(72, {'2.4': 63, '2.7':67, - '2.7+cextension':67, - '3':55}, + @profiling.function_call_count(72, {'2.4': 68, '2.7':75, + '2.7+cextension':75, + '3':62}, variance=.10) def test_first_connect(self): conn = pool.connect() diff -r 44d4aba1681f -r 854d287b2c1a test/engine/test_reconnect.py --- a/test/engine/test_reconnect.py Fri Jun 22 12:24:08 2012 -0400 +++ b/test/engine/test_reconnect.py Sat Jun 23 11:46:47 2012 -0400 @@ -264,6 +264,33 @@ conn.close() + def test_multiple_invalidate(self): + c1 = engine.connect() + c2 = engine.connect() + + eq_(c1.execute(select([1])).scalar(), 1) + + p1 = engine.pool + engine.test_shutdown() + + try: + c1.execute(select([1])) + assert False + except tsa.exc.DBAPIError, e: + assert e.connection_invalidated + + p2 = engine.pool + + try: + c2.execute(select([1])) + assert False + except tsa.exc.DBAPIError, e: + assert e.connection_invalidated + + # pool isn't replaced + assert engine.pool is p2 + + def test_ensure_is_disconnect_gets_connection(self): def is_disconnect(e, conn, cursor): # connection is still present |