Disable subtransactions in table locking transaction

disable subtransactions to prevent interrupting
DB requests from interefering with table lock. Main issue is
synchronizer interrupting and using the same session, leading
MySQL to complain about subtransaction not locking tables

Change-Id: Ia1031961c83e83d4b996d9eedc7261edd6a91e17
This commit is contained in:
Eric K 2016-09-29 22:46:25 -07:00
parent 89cf265900
commit ea9e8b877c
1 changed files with 6 additions and 1 deletions

View File

@ -67,7 +67,12 @@ def add_policy(id_, name, abbreviation, description, owner, kind,
(cfg.CONF.database.connection.split(':/')[0] == 'postgresql' or
cfg.CONF.database.connection.split('+')[0] == 'postgresql'))
try:
with session.begin(subtransactions=True):
with session.begin(subtransactions=False):
# Note(ekcs): disable subtransactions to prevent interrupting
# DB requests from interefering with table lock. Main issue is
# synchronizer interrupting and using the same session, leading
# MySQL to complain about subtransaction not locking tables
# lock policies table to prevent duplicate named policy being added
# after duplicate check but before transaction closes.
# supported DBs are SQLite and MySQL and Postgres