diff mbox series

[ovs-dev] ovsdb-idl: Add function to reset min_index.

Message ID 20200501191308.94486-1-mmichels@redhat.com
State Accepted
Delegated to: Ilya Maximets
Headers show
Series [ovs-dev] ovsdb-idl: Add function to reset min_index. | expand

Commit Message

Mark Michelson May 1, 2020, 7:13 p.m. UTC
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>
---
 lib/ovsdb-idl.c | 10 ++++++++++
 lib/ovsdb-idl.h |  1 +
 2 files changed, 11 insertions(+)

Comments

Han Zhou May 4, 2020, 4:17 p.m. UTC | #1
On Fri, May 1, 2020 at 12:13 PM Mark Michelson <mmichels@redhat.com> wrote:
>
> 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>
> ---
>  lib/ovsdb-idl.c | 10 ++++++++++
>  lib/ovsdb-idl.h |  1 +
>  2 files changed, 11 insertions(+)
>
> diff --git a/lib/ovsdb-idl.c b/lib/ovsdb-idl.c
> index 1535ad7b5..9c66a6d4f 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);
> --
> 2.25.4
>
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Acked-by: Han Zhou <hzhou@ovn.org>
Ilya Maximets May 28, 2020, 5:03 p.m. UTC | #2
On 5/4/20 6:17 PM, Han Zhou wrote:
> On Fri, May 1, 2020 at 12:13 PM Mark Michelson <mmichels@redhat.com> wrote:
>>
>> 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>

Thanks, Mark and Han!  Applied to master.

Best regards, Ilya Maximets.
diff mbox series

Patch

diff --git a/lib/ovsdb-idl.c b/lib/ovsdb-idl.c
index 1535ad7b5..9c66a6d4f 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);