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
This commit is contained in:
Lucas Alvares Gomes 2018-03-08 16:41:02 +00:00
parent acede4dd1c
commit b7c9dc9f0a
1 changed files with 11 additions and 2 deletions

View File

@ -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]