On Fri, May 1, 2020 at 12:13 PM Mark Michelson <[email protected]> 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 <[email protected]>
> ---
>  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
> [email protected]
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Acked-by: Han Zhou <[email protected]>
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to