summaryrefslogtreecommitdiff
path: root/oslo_db/sqlalchemy/utils.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2019-06-07 11:52:40 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2019-06-07 11:53:46 -0400
commit459de143578367c00fb508edeea68eb96531724c (patch)
tree100314111f683b7cd73d891a2765d6c688bfb1a6 /oslo_db/sqlalchemy/utils.py
parent2f8250f3f747473c8f4258b148f2f7ded0a95084 (diff)
downloadoslo-db-459de143578367c00fb508edeea68eb96531724c.tar.gz
Rollback existing nested transacvtion before restarting5.0.1
SQLAlchemy 1.4 will be adding stricter rules to Connection objects such that a new transaction cannot be started while an old one hasn't been cleared. Ensure this particular test fixture clears the "savepoint" transaction first before starting a new one. References: https://github.com/sqlalchemy/sqlalchemy/issues/4712 Change-Id: Idcb616fd3add4d58f22b91865cec8a54fe492093
Diffstat (limited to 'oslo_db/sqlalchemy/utils.py')
-rw-r--r--oslo_db/sqlalchemy/utils.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/oslo_db/sqlalchemy/utils.py b/oslo_db/sqlalchemy/utils.py
index b54774d..02992f0 100644
--- a/oslo_db/sqlalchemy/utils.py
+++ b/oslo_db/sqlalchemy/utils.py
@@ -1227,12 +1227,16 @@ class NonCommittingConnectable(object):
"""
+ _nested_trans = None
+
def __init__(self, connection):
self.connection = connection
self._trans = connection.begin()
self._restart_nested()
def _restart_nested(self):
+ if self._nested_trans is not None:
+ self._nested_trans.rollback()
self._nested_trans = self.connection.begin_nested()
def _dispose(self):