Log what exception caused abort of the transaction

In some cases, when ovsdb transaction is aborted, knowing what error
caused that can help to understand the root cause of the problem
so this patch adds such logging on the DEBUG level.

Change-Id: Ic67575ff26c689ec8ab1a5c619ae0b0a2846b05f
This commit is contained in:
Slawek Kaplonski 2022-01-21 10:06:33 +01:00
parent 1f2b393272
commit dc15bfd572
1 changed files with 8 additions and 1 deletions

View File

@ -91,10 +91,17 @@ class Transaction(api.Transaction):
{'idx': i, 'cmd': command, 'n': attempts})
try:
command.run_idl(txn)
except Exception:
except Exception as e:
txn.abort()
if self.check_error:
raise
if self.log_errors:
LOG.error("txn n=%(n)d command(idx=%(idx)s): %(cmd)s ",
"aborted due to error: %(err)s",
{'idx': i,
'cmd': command,
'n': attempts,
'err': e})
status = txn.commit_block()
if status == txn.TRY_AGAIN:
LOG.debug("OVSDB transaction returned TRY_AGAIN, retrying")