From 79de84b25e87bbb7fa94f0dd513b4abc76e05a7e Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Thu, 14 May 2020 10:51:29 -0400 Subject: Actively unset reset agent in discard transaction The assumptions in _discard_transaction from 916e1fea25afcd07fa1d1d2f72043b372cd02223 were too narrow, assuming that if the given transaction were not our "current" one, that this would not be the reset agent. however as the legacy behvaior is that even a "nested" transaction gets set as "self._transaction", this did not accommodate for the nested transaction being thrown away. We will attempt to refine all of this logic in #5327 for 1.4 /master assuming this is feasible for the full suite of current use cases. Fixes: #5326 Change-Id: I6787e82c9e50c23317f87d0d094122c6a6f066da --- lib/sqlalchemy/engine/base.py | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) (limited to 'lib/sqlalchemy/engine') diff --git a/lib/sqlalchemy/engine/base.py b/lib/sqlalchemy/engine/base.py index ed0586cc7..e617f0fad 100644 --- a/lib/sqlalchemy/engine/base.py +++ b/lib/sqlalchemy/engine/base.py @@ -821,25 +821,13 @@ class Connection(Connectable): assert trans._parent is trans self._transaction = None - # test suite w/ SingletonThreadPool will have cases - # where _reset_agent is on a different Connection - # entirely so we can't assert this here. - # if ( - # not self._is_future - # and self._still_open_and_connection_is_valid - # ): - # assert self.__connection._reset_agent is None else: assert trans._parent is not trans self._transaction = trans._parent - # not doing this assertion for now, however this is how - # it would look: - # if self._still_open_and_connection_is_valid: - # trans = self._transaction - # while not trans._is_root: - # trans = trans._parent - # assert self.__connection._reset_agent is trans + if not self._is_future and self._still_open_and_connection_is_valid: + if self.__connection._reset_agent is trans: + self.__connection._reset_agent = None def _rollback_to_savepoint_impl( self, name, context, deactivate_only=False -- cgit v1.2.1