From dc15bfd5729eb9f2b404288a4aa901c318274507 Mon Sep 17 00:00:00 2001 From: Slawek Kaplonski Date: Fri, 21 Jan 2022 10:06:33 +0100 Subject: [PATCH] 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 --- ovsdbapp/backend/ovs_idl/transaction.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ovsdbapp/backend/ovs_idl/transaction.py b/ovsdbapp/backend/ovs_idl/transaction.py index 091b6b83..403d0f72 100644 --- a/ovsdbapp/backend/ovs_idl/transaction.py +++ b/ovsdbapp/backend/ovs_idl/transaction.py @@ -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")