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 --- test/engine/test_transaction.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/engine/test_transaction.py b/test/engine/test_transaction.py index 85f124d12..fbc1ffd83 100644 --- a/test/engine/test_transaction.py +++ b/test/engine/test_transaction.py @@ -663,7 +663,7 @@ class ResetAgentTest(fixtures.TestBase): conn.close() @testing.requires.savepoints - def test_begin_nested_trans_close(self): + def test_begin_nested_trans_close_one(self): with testing.db.connect() as connection: t1 = connection.begin() assert connection.connection._reset_agent is t1 @@ -677,6 +677,20 @@ class ResetAgentTest(fixtures.TestBase): assert connection.connection._reset_agent is None assert not t1.is_active + @testing.requires.savepoints + def test_begin_nested_trans_close_two(self): + with testing.db.connect() as connection: + t1 = connection.begin() + assert connection.connection._reset_agent is t1 + t2 = connection.begin_nested() + assert connection.connection._reset_agent is t1 + assert connection._transaction is t2 + + assert connection.connection._reset_agent is t1 + t1.close() + assert connection.connection._reset_agent is None + assert not t1.is_active + @testing.requires.savepoints def test_begin_nested_trans_rollback(self): with testing.db.connect() as connection: -- cgit v1.2.1