From b7c9dc9f0a86ddce99c8b189614bc4e39e0c59ff Mon Sep 17 00:00:00 2001 From: Lucas Alvares Gomes Date: Thu, 8 Mar 2018 16:41:02 +0000 Subject: [PATCH] Transaction: Handle NOT_LOCKED status This patch is changing the commit_block() from the Transaction class to handle the NOT_LOCKED status and treat it as an error. The reason to treat it as an error is because, when the connection with the OVSDB is reestabilished we don't know if that transaction will belong to a worker that is holding a valid lock or not, so we won't attempt to retry it. The patch is also adding a log for unknown status, in case another status that is not handled by ovsdbapp is returned the log will give us some hints about what's going on instead of failing siently. Related-Bug: #1754291 Change-Id: I5dcb226c387092cba1adb9dbf1ec782e0bac66ba --- ovsdbapp/backend/ovs_idl/transaction.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/ovsdbapp/backend/ovs_idl/transaction.py b/ovsdbapp/backend/ovs_idl/transaction.py index 0e3328da..632bef11 100644 --- a/ovsdbapp/backend/ovs_idl/transaction.py +++ b/ovsdbapp/backend/ovs_idl/transaction.py @@ -99,8 +99,15 @@ class Transaction(api.Transaction): # idl.run() again. So, call idl.run() here just in case. self.api.idl.run() continue - elif status == txn.ERROR: - msg = "OVSDB Error: %s" % txn.get_error() + elif status in (txn.ERROR, txn.NOT_LOCKED): + msg = 'OVSDB Error: ' + if status == txn.NOT_LOCKED: + msg += ("The transaction failed because the IDL has " + "been configured to require a database lock " + "but didn't get it yet or has already lost it") + else: + msg += txn.get_error() + if self.log_errors: LOG.error(msg) if self.check_error: @@ -114,6 +121,8 @@ class Transaction(api.Transaction): LOG.debug("Transaction caused no change") elif status == txn.SUCCESS: self.post_commit(txn) + else: + LOG.debug("Transaction returned an unknown status: %s", status) return [cmd.result for cmd in self.commands]