diff mbox series

[ovs-dev,v2,python] Avoid sending transactions when the DB is not synced up

Message ID 20210902153036.303830-1-twilson@redhat.com
State Superseded
Headers show
Series [ovs-dev,v2,python] Avoid sending transactions when the DB is not synced up | expand

Checks

Context Check Description
ovsrobot/apply-robot success apply and check: success
ovsrobot/github-robot-_Build_and_Test fail github build: failed

Commit Message

Terry Wilson Sept. 2, 2021, 3:30 p.m. UTC
This ports the C IDL change f50714b to the Python IDL:

Until now the code here would happily try to send transactions to the
database server even if the database connection was not in the correct
state.  In some cases this could lead to strange behavior, such as sending
a database transaction for a database that the IDL had just learned did not
exist on the server.

Signed-off-by: Terry Wilson <twilson@redhat.com>
---
 python/ovs/db/idl.py | 7 +++++++
 1 file changed, 7 insertions(+)
diff mbox series

Patch

diff --git a/python/ovs/db/idl.py b/python/ovs/db/idl.py
index ecae5e143..f24dc5eaf 100644
--- a/python/ovs/db/idl.py
+++ b/python/ovs/db/idl.py
@@ -1500,11 +1500,18 @@  class Transaction(object):
         the IDL's copy of the database.  If the transaction commits
         successfully, then the database server will send an update and, thus,
         the IDL will be updated with the committed changes."""
+
         # The status can only change if we're the active transaction.
         # (Otherwise, our status will change only in Idl.run().)
         if self != self.idl.txn:
             return self._status
 
+        if self.idl.state != Idl.IDL_S_MONITORING:
+            self._status = Transaction.TRY_AGAIN
+            self.__disassemble()
+            return self._status
+
+
         # If we need a lock but don't have it, give up quickly.
         if self.idl.lock_name and not self.idl.has_lock:
             self._status = Transaction.NOT_LOCKED