dddd63
From 1de31c3a531f5db6793819fa18f6e69304db929c Mon Sep 17 00:00:00 2001
9219d1
From: Mark Michelson <mmichels@redhat.com>
9219d1
Date: Fri, 1 May 2020 15:13:08 -0400
dddd63
Subject: [PATCH 4/4] ovsdb-idl: Add function to reset min_index.
9219d1
9219d1
If an administrator removes all of the databases in a cluster from
9219d1
disk, then ovsdb IDL clients will have a problem. The databases will all
9219d1
reset their stored indexes to 0, so The IDL client's min_index will be
9219d1
higher than the indexes of all databases in the cluster. This results in
9219d1
the client constantly connecting to databases, detecting the data as
9219d1
"stale", and then attempting to connect to another.
9219d1
9219d1
This function provides a way to reset the IDL to an initial state with
9219d1
min_index of 0. This way, the client will not wrongly detect the
9219d1
database data as stale and will recover properly.
9219d1
9219d1
Notice that this function is not actually used anywhere in this patch.
9219d1
This will be used by OVN, though, since OVN is the primary user of
9219d1
clustered OVSDB.
9219d1
9219d1
Signed-off-by: Mark Michelson <mmichels@redhat.com>
9219d1
Acked-by: Han Zhou <hzhou@ovn.org>
9219d1
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
9219d1
9219d1
(cherry-picked from upstream ovs commit 89b522aee379f7ebd21ec67ffb622118af7e9db1)
9219d1
9219d1
Change-Id: I943ece9a07566a34b11248455cc1abbe7892d4e8
9219d1
---
9219d1
 openvswitch-2.13.0/lib/ovsdb-idl.c | 10 ++++++++++
9219d1
 openvswitch-2.13.0/lib/ovsdb-idl.h |  1 +
9219d1
 2 files changed, 11 insertions(+)
9219d1
9219d1
diff --git a/openvswitch-2.13.0/lib/ovsdb-idl.c b/openvswitch-2.13.0/lib/ovsdb-idl.c
9219d1
index 8eb421366..648c227d6 100644
9219d1
--- a/openvswitch-2.13.0/lib/ovsdb-idl.c
9219d1
+++ b/openvswitch-2.13.0/lib/ovsdb-idl.c
9219d1
@@ -561,6 +561,16 @@ ovsdb_idl_set_shuffle_remotes(struct ovsdb_idl *idl, bool shuffle)
9219d1
     idl->shuffle_remotes = shuffle;
9219d1
 }
9219d1
 
9219d1
+/* Reset min_index to 0. This prevents a situation where the client
9219d1
+ * thinks all databases have stale data, when they actually have all
9219d1
+ * been destroyed and rebuilt from scratch.
9219d1
+ */
9219d1
+void
9219d1
+ovsdb_idl_reset_min_index(struct ovsdb_idl *idl)
9219d1
+{
9219d1
+    idl->min_index = 0;
9219d1
+}
9219d1
+
9219d1
 static void
9219d1
 ovsdb_idl_db_destroy(struct ovsdb_idl_db *db)
9219d1
 {
9219d1
diff --git a/openvswitch-2.13.0/lib/ovsdb-idl.h b/openvswitch-2.13.0/lib/ovsdb-idl.h
9219d1
index 9f12ce320..c56cd19b1 100644
9219d1
--- a/openvswitch-2.13.0/lib/ovsdb-idl.h
9219d1
+++ b/openvswitch-2.13.0/lib/ovsdb-idl.h
9219d1
@@ -64,6 +64,7 @@ struct ovsdb_idl *ovsdb_idl_create_unconnected(
9219d1
     const struct ovsdb_idl_class *, bool monitor_everything_by_default);
9219d1
 void ovsdb_idl_set_remote(struct ovsdb_idl *, const char *, bool);
9219d1
 void ovsdb_idl_set_shuffle_remotes(struct ovsdb_idl *, bool);
9219d1
+void ovsdb_idl_reset_min_index(struct ovsdb_idl *);
9219d1
 void ovsdb_idl_destroy(struct ovsdb_idl *);
9219d1
 
9219d1
 void ovsdb_idl_set_leader_only(struct ovsdb_idl *, bool leader_only);
9219d1
-- 
9219d1
2.26.2
9219d1