summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Michelson <mmichels@redhat.com>2020-05-01 15:13:08 -0400
committerIlya Maximets <i.maximets@ovn.org>2020-05-28 18:36:48 +0200
commit89b522aee379f7ebd21ec67ffb622118af7e9db1 (patch)
tree2a09dddcbc484f1c41c8cb22facc78cd96505243
parent9ba57fc7cccca85a753bc3d5c12271defb5619c1 (diff)
downloadopenvswitch-89b522aee379f7ebd21ec67ffb622118af7e9db1.tar.gz
ovsdb-idl: Add function to reset min_index.
If an administrator removes all of the databases in a cluster from disk, then ovsdb IDL clients will have a problem. The databases will all reset their stored indexes to 0, so The IDL client's min_index will be higher than the indexes of all databases in the cluster. This results in the client constantly connecting to databases, detecting the data as "stale", and then attempting to connect to another. This function provides a way to reset the IDL to an initial state with min_index of 0. This way, the client will not wrongly detect the database data as stale and will recover properly. Notice that this function is not actually used anywhere in this patch. This will be used by OVN, though, since OVN is the primary user of clustered OVSDB. Signed-off-by: Mark Michelson <mmichels@redhat.com> Acked-by: Han Zhou <hzhou@ovn.org> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
-rw-r--r--lib/ovsdb-idl.c10
-rw-r--r--lib/ovsdb-idl.h1
2 files changed, 11 insertions, 0 deletions
diff --git a/lib/ovsdb-idl.c b/lib/ovsdb-idl.c
index 6614ea161..f54e360e3 100644
--- a/lib/ovsdb-idl.c
+++ b/lib/ovsdb-idl.c
@@ -553,6 +553,16 @@ ovsdb_idl_set_shuffle_remotes(struct ovsdb_idl *idl, bool shuffle)
idl->shuffle_remotes = shuffle;
}
+/* Reset min_index to 0. This prevents a situation where the client
+ * thinks all databases have stale data, when they actually have all
+ * been destroyed and rebuilt from scratch.
+ */
+void
+ovsdb_idl_reset_min_index(struct ovsdb_idl *idl)
+{
+ idl->min_index = 0;
+}
+
static void
ovsdb_idl_db_destroy(struct ovsdb_idl_db *db)
{
diff --git a/lib/ovsdb-idl.h b/lib/ovsdb-idl.h
index 9f12ce320..c56cd19b1 100644
--- a/lib/ovsdb-idl.h
+++ b/lib/ovsdb-idl.h
@@ -64,6 +64,7 @@ struct ovsdb_idl *ovsdb_idl_create_unconnected(
const struct ovsdb_idl_class *, bool monitor_everything_by_default);
void ovsdb_idl_set_remote(struct ovsdb_idl *, const char *, bool);
void ovsdb_idl_set_shuffle_remotes(struct ovsdb_idl *, bool);
+void ovsdb_idl_reset_min_index(struct ovsdb_idl *);
void ovsdb_idl_destroy(struct ovsdb_idl *);
void ovsdb_idl_set_leader_only(struct ovsdb_idl *, bool leader_only);