From 1810faecc9ad2345f3e2f9185ac64194c5a0d711 Mon Sep 17 00:00:00 2001 From: Terry Wilson Date: Wed, 24 Jan 2018 03:41:13 +0000 Subject: [PATCH] Ensure idl.run() called on TRY_AGAIN If the DB connection drops after Connection.run() calls idl.run() but before Transaction.do_commit(), then it is possible for idl.commit() to return TRY_AGAIN due to the failure of session.send(). This prevents commit_block() from running idl.run() which would actually trigger the DB reconnect, causing each successive call to commit_block() to fail in the same way until we stop trying again due to timeout and Connection.run() calls idl.run() again. For now, we can just ensure that idl.run() is called when we get a TRY_AGAIN. It might be worth it to refactor this a bit to not even use commit_block(). Change-Id: I77402bde3fc4d45c770b9f48882870cfc91d719d Closes-Bug: #1741889 --- ovsdbapp/backend/ovs_idl/transaction.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ovsdbapp/backend/ovs_idl/transaction.py b/ovsdbapp/backend/ovs_idl/transaction.py index a10ac27f..0e3328da 100644 --- a/ovsdbapp/backend/ovs_idl/transaction.py +++ b/ovsdbapp/backend/ovs_idl/transaction.py @@ -91,6 +91,13 @@ class Transaction(api.Transaction): status = txn.commit_block() if status == txn.TRY_AGAIN: LOG.debug("OVSDB transaction returned TRY_AGAIN, retrying") + # In the case that there is a reconnection after + # Connection.run() calls self.idl.run() but before do_commit() + # is called, commit_block() can loop w/o calling idl.run() + # which does the reconnect logic. It will then always return + # TRY_AGAIN until we time out and Connection.run() calls + # 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()