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
(cherry picked from commit b7c9dc9f0a
)
This commit is contained in:
parent
592fd236eb
commit
f971e5d1a4
|
@ -99,8 +99,15 @@ class Transaction(api.Transaction):
|
||||||
# idl.run() again. So, call idl.run() here just in case.
|
# idl.run() again. So, call idl.run() here just in case.
|
||||||
self.api.idl.run()
|
self.api.idl.run()
|
||||||
continue
|
continue
|
||||||
elif status == txn.ERROR:
|
elif status in (txn.ERROR, txn.NOT_LOCKED):
|
||||||
msg = "OVSDB Error: %s" % txn.get_error()
|
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:
|
if self.log_errors:
|
||||||
LOG.error(msg)
|
LOG.error(msg)
|
||||||
if self.check_error:
|
if self.check_error:
|
||||||
|
@ -114,6 +121,8 @@ class Transaction(api.Transaction):
|
||||||
LOG.debug("Transaction caused no change")
|
LOG.debug("Transaction caused no change")
|
||||||
elif status == txn.SUCCESS:
|
elif status == txn.SUCCESS:
|
||||||
self.post_commit(txn)
|
self.post_commit(txn)
|
||||||
|
else:
|
||||||
|
LOG.debug("Transaction returned an unknown status: %s", status)
|
||||||
|
|
||||||
return [cmd.result for cmd in self.commands]
|
return [cmd.result for cmd in self.commands]
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue