[Sqlalchemy-tickets] Issue #4252: double checkin due to handle_error called inside of _finalize_fai
Brought to you by:
zzzeek
From: Michael B. <iss...@bi...> - 2018-05-15 18:58:18
|
New issue 4252: double checkin due to handle_error called inside of _finalize_fairy -> reset https://bitbucket.org/zzzeek/sqlalchemy/issues/4252/double-checkin-due-to-handle_error-called Michael Bayer: ``` #!python from sqlalchemy import create_engine import mock import psycopg2 e = create_engine("postgresql://scott:tiger@localhost/test") # fill pool with one connection e.connect().close() print(e.pool._pool.queue) # have an exception be a disconnect error e.dialect.is_disconnect = lambda *arg, **kw: True conn = e.connect() trans = conn.begin() # have a rollback raise, will cause disconnect + invalidate with mock.patch.object( conn.connection, "rollback", side_effect=psycopg2.OperationalError("something went wrong with the rollback") ): conn.close() # connection is checked in twice print(e.pool._pool.queue) ``` at the end we get: ``` #!python sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) something went wrong with the rollback (Background on this error at: http://sqlalche.me/e/e3q8) deque([<sqlalchemy.pool._ConnectionRecord object at 0x7f71910976a0>, <sqlalchemy.pool._ConnectionRecord object at 0x7f71910976a0>]) ``` this is due to the reset agent calling _handle_error which then goes and does the invalidation sequence. |