summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorDumitru Ceara <dceara@redhat.com>2022-01-11 17:38:14 +0100
committerIlya Maximets <i.maximets@ovn.org>2022-01-31 21:23:47 +0100
commit5202710a7862169161db4ebc84c410328a340c52 (patch)
tree5ebf03b5c6a012ecd80ed5d44f77fcd6223e8975 /python
parentc1691cceac322d8a49a6aeb52a608362385ae037 (diff)
downloadopenvswitch-5202710a7862169161db4ebc84c410328a340c52.tar.gz
python: idl: Clear last_id on reconnect if condition changes in-flight.
When reconnecting, if there are condition changes already sent to the server but not yet acked, reset the db's 'last-id', esentially clearing the local cache after reconnect. This is needed because the client cannot easily differentiate between the following cases: a. either the server already processed the requested monitor condition change but the FSM was restarted before the client was notified. In this case the client should clear its local cache because it's out of sync with the monitor view on the server side. b. OR the server hasn't processed the requested monitor condition change yet. Fixes: 46d44cf3be0d ("python: idl: Add monitor_cond_since support.") Signed-off-by: Dumitru Ceara <dceara@redhat.com> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
Diffstat (limited to 'python')
-rw-r--r--python/ovs/db/idl.py18
1 files changed, 17 insertions, 1 deletions
diff --git a/python/ovs/db/idl.py b/python/ovs/db/idl.py
index 035191fc5..4ecdcaa19 100644
--- a/python/ovs/db/idl.py
+++ b/python/ovs/db/idl.py
@@ -136,6 +136,8 @@ class ConditionState(object):
if self._new_cond is None:
self._new_cond = self._req_cond
self._req_cond = None
+ return True
+ return False
class Idl(object):
@@ -339,6 +341,19 @@ class Idl(object):
txn-id == last_id. If there were requested condition changes in flight
and the IDL client didn't set new conditions, then reset the requested
conditions to new to trigger a follow-up monitor_cond_change request.
+
+ If there were changes in flight then there are two cases:
+ a. either the server already processed the requested monitor condition
+ change but the FSM was restarted before the client was notified.
+ In this case the client should clear its local cache because it's
+ out of sync with the monitor view on the server side.
+
+ b. OR the server hasn't processed the requested monitor condition
+ change yet.
+
+ As there's no easy way to differentiate between the two, and given that
+ this condition should be rare, reset the 'last_id', essentially
+ flushing the local cached DB contents.
"""
ack_all = self.last_id == str(uuid.UUID(int=0))
for table in self.tables.values():
@@ -346,7 +361,8 @@ class Idl(object):
table.condition.request()
table.condition.ack()
else:
- table.condition.reset()
+ if table.condition.reset():
+ self.last_id = str(uuid.UUID(int=0))
self.cond_changed = True
def restart_fsm(self):