From patchwork Tue Jan 7 04:54:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Numan Siddique X-Patchwork-Id: 1218588 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.138; helo=whitealder.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ovn.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47sKnM0DLGz9sRG for ; Tue, 7 Jan 2020 15:55:18 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id B799287692; Tue, 7 Jan 2020 04:55:15 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 3qdhBa6vqhuP; Tue, 7 Jan 2020 04:55:12 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by whitealder.osuosl.org (Postfix) with ESMTP id 2AB1C8609C; Tue, 7 Jan 2020 04:55:12 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 18B8CC1D83; Tue, 7 Jan 2020 04:55:12 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 7CC7EC0881 for ; Tue, 7 Jan 2020 04:55:10 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 786098836E for ; Tue, 7 Jan 2020 04:55:10 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id sTbZunbM-fi3 for ; Tue, 7 Jan 2020 04:55:09 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by hemlock.osuosl.org (Postfix) with ESMTPS id 956658836B for ; Tue, 7 Jan 2020 04:55:08 +0000 (UTC) X-Originating-IP: 125.99.230.110 Received: from nummac.local (unknown [125.99.230.110]) (Authenticated sender: numans@ovn.org) by relay9-d.mail.gandi.net (Postfix) with ESMTPSA id 11BBEFF804; Tue, 7 Jan 2020 04:55:03 +0000 (UTC) From: numans@ovn.org To: dev@openvswitch.org Date: Tue, 7 Jan 2020 10:24:48 +0530 Message-Id: <20200107045448.888583-1-numans@ovn.org> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 Subject: [ovs-dev] [PATCH v6] ovsdb replication: Provide option to configure probe interval. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" From: Numan Siddique When ovsdb-server is in backup mode and connects to the active ovsdb-server for replication, and if takes more than 5 seconds to get the dump of the whole database, it will drop the connection soon after as the default probe interval is 5 seconds. This results in a snowball effect of reconnections to the active ovsdb-server. This patch handles or mitigates this issue by setting the default probe interval value to 60 seconds and provide the option to configure this value from the unixctl command. Other option could be increase the value of 'RECONNECT_DEFAULT_PROBE_INTERVAL' to a higher value. Acked-by: Mark Michelson Signed-off-by: Numan Siddique Acked-by: Dumitru Ceara --- v5 -> v6 --- * Fixed the checkpatch line warning. v4 -> v5 --- * Added entry into NEWS. v3 -> v4 ----- * Addressed review comments from Ben NEWS | 5 +++++ ovsdb/ovsdb-server.1.in | 5 +++++ ovsdb/ovsdb-server.c | 49 +++++++++++++++++++++++++++++++++++------ ovsdb/replication.c | 12 +++++++++- ovsdb/replication.h | 5 ++++- 5 files changed, 67 insertions(+), 9 deletions(-) diff --git a/NEWS b/NEWS index 79f841399..965facaf8 100644 --- a/NEWS +++ b/NEWS @@ -29,6 +29,11 @@ Post-v2.12.0 - RSTP: * The rstp_statistics column in Port table will only be updated every stats-update-interval configured in Open_vSwtich table. + - OVSDB: + * When ovsdb-server is running in backup mode, the default value of probe + interval is increased to 60 seconds for the connection to the + replication server. This value is configurable with the unixctl + command - ovsdb-server/set-active-ovsdb-server-probe-interval. v2.12.0 - 03 Sep 2019 --------------------- diff --git a/ovsdb/ovsdb-server.1.in b/ovsdb/ovsdb-server.1.in index 21f527bc6..338f3bc29 100644 --- a/ovsdb/ovsdb-server.1.in +++ b/ovsdb/ovsdb-server.1.in @@ -288,6 +288,11 @@ Switches the server to an active role. The server stops synchronizing its databases with an active server and closes all existing client connections, which requires clients to reconnect. . +.IP "\fBovsdb\-server/set\-active\-ovsdb\-server\-probe\-interval \fIprobe interval" +Sets the probe interval (in milli seconds) for the connection to +active \fIserver\fR. +. +. .IP "\fBovsdb\-server/set\-sync\-exclude\-tables \fIdb\fB:\fItable\fR[\fB,\fIdb\fB:\fItable\fR]..." Sets the \fItable\fR within \fIdb\fR that will be excluded from synchronization. This overrides the \fB\-\-sync\-exclude-tables\fR command-line option. diff --git a/ovsdb/ovsdb-server.c b/ovsdb/ovsdb-server.c index 9827320ec..b6957d730 100644 --- a/ovsdb/ovsdb-server.c +++ b/ovsdb/ovsdb-server.c @@ -86,6 +86,7 @@ static unixctl_cb_func ovsdb_server_set_active_ovsdb_server; static unixctl_cb_func ovsdb_server_get_active_ovsdb_server; static unixctl_cb_func ovsdb_server_connect_active_ovsdb_server; static unixctl_cb_func ovsdb_server_disconnect_active_ovsdb_server; +static unixctl_cb_func ovsdb_server_set_active_ovsdb_server_probe_interval; static unixctl_cb_func ovsdb_server_set_sync_exclude_tables; static unixctl_cb_func ovsdb_server_get_sync_exclude_tables; static unixctl_cb_func ovsdb_server_get_sync_status; @@ -97,6 +98,7 @@ struct server_config { char **sync_from; char **sync_exclude; bool *is_backup; + int *replication_probe_interval; struct ovsdb_jsonrpc_server *jsonrpc; }; static unixctl_cb_func ovsdb_server_add_remote; @@ -144,9 +146,10 @@ static void load_config(FILE *config_file, struct sset *remotes, static void ovsdb_replication_init(const char *sync_from, const char *exclude, - struct shash *all_dbs, const struct uuid *server_uuid) + struct shash *all_dbs, const struct uuid *server_uuid, + int probe_interval) { - replication_init(sync_from, exclude, server_uuid); + replication_init(sync_from, exclude, server_uuid, probe_interval); struct shash_node *node; SHASH_FOR_EACH (node, all_dbs) { struct db *db = node->data; @@ -304,6 +307,7 @@ main(int argc, char *argv[]) struct server_config server_config; struct shash all_dbs; struct shash_node *node, *next; + int replication_probe_interval = REPLICATION_DEFAULT_PROBE_INTERVAL; ovs_cmdl_proctitle_init(argc, argv); set_program_name(argv[0]); @@ -351,6 +355,7 @@ main(int argc, char *argv[]) server_config.sync_from = &sync_from; server_config.sync_exclude = &sync_exclude; server_config.is_backup = &is_backup; + server_config.replication_probe_interval = &replication_probe_interval; perf_counters_init(); @@ -436,6 +441,9 @@ main(int argc, char *argv[]) unixctl_command_register("ovsdb-server/disconnect-active-ovsdb-server", "", 0, 0, ovsdb_server_disconnect_active_ovsdb_server, &server_config); + unixctl_command_register( + "ovsdb-server/set-active-ovsdb-server-probe-interval", "", 1, 1, + ovsdb_server_set_active_ovsdb_server_probe_interval, &server_config); unixctl_command_register("ovsdb-server/set-sync-exclude-tables", "", 0, 1, ovsdb_server_set_sync_exclude_tables, &server_config); @@ -454,7 +462,8 @@ main(int argc, char *argv[]) if (is_backup) { const struct uuid *server_uuid; server_uuid = ovsdb_jsonrpc_server_get_uuid(jsonrpc); - ovsdb_replication_init(sync_from, sync_exclude, &all_dbs, server_uuid); + ovsdb_replication_init(sync_from, sync_exclude, &all_dbs, server_uuid, + replication_probe_interval); } main_loop(&server_config, jsonrpc, &all_dbs, unixctl, &remotes, @@ -1317,7 +1326,8 @@ ovsdb_server_connect_active_ovsdb_server(struct unixctl_conn *conn, const struct uuid *server_uuid; server_uuid = ovsdb_jsonrpc_server_get_uuid(config->jsonrpc); ovsdb_replication_init(*config->sync_from, *config->sync_exclude, - config->all_dbs, server_uuid); + config->all_dbs, server_uuid, + *config->replication_probe_interval); if (!*config->is_backup) { *config->is_backup = true; save_config(config); @@ -1340,6 +1350,28 @@ ovsdb_server_disconnect_active_ovsdb_server(struct unixctl_conn *conn, unixctl_command_reply(conn, NULL); } +static void +ovsdb_server_set_active_ovsdb_server_probe_interval(struct unixctl_conn *conn, + int argc OVS_UNUSED, + const char *argv[], + void *config_) +{ + struct server_config *config = config_; + + int probe_interval; + if (str_to_int(argv[1], 10, &probe_interval)) { + *config->replication_probe_interval = probe_interval; + save_config(config); + if (*config->is_backup) { + replication_set_probe_interval(probe_interval); + } + unixctl_command_reply(conn, NULL); + } else { + unixctl_command_reply( + conn, "Invalid probe interval, integer value expected"); + } +} + static void ovsdb_server_set_sync_exclude_tables(struct unixctl_conn *conn, int argc OVS_UNUSED, @@ -1357,7 +1389,8 @@ ovsdb_server_set_sync_exclude_tables(struct unixctl_conn *conn, const struct uuid *server_uuid; server_uuid = ovsdb_jsonrpc_server_get_uuid(config->jsonrpc); ovsdb_replication_init(*config->sync_from, *config->sync_exclude, - config->all_dbs, server_uuid); + config->all_dbs, server_uuid, + *config->replication_probe_interval); } err = set_blacklist_tables(argv[1], false); } @@ -1568,7 +1601,8 @@ ovsdb_server_add_database(struct unixctl_conn *conn, int argc OVS_UNUSED, const struct uuid *server_uuid; server_uuid = ovsdb_jsonrpc_server_get_uuid(config->jsonrpc); ovsdb_replication_init(*config->sync_from, *config->sync_exclude, - config->all_dbs, server_uuid); + config->all_dbs, server_uuid, + *config->replication_probe_interval); } unixctl_command_reply(conn, NULL); } else { @@ -1590,7 +1624,8 @@ remove_db(struct server_config *config, struct shash_node *node, char *comment) const struct uuid *server_uuid; server_uuid = ovsdb_jsonrpc_server_get_uuid(config->jsonrpc); ovsdb_replication_init(*config->sync_from, *config->sync_exclude, - config->all_dbs, server_uuid); + config->all_dbs, server_uuid, + *config->replication_probe_interval); } } diff --git a/ovsdb/replication.c b/ovsdb/replication.c index 42e27cba0..cbbce64df 100644 --- a/ovsdb/replication.c +++ b/ovsdb/replication.c @@ -125,7 +125,7 @@ static struct replication_db *find_db(const char *db_name); void replication_init(const char *sync_from_, const char *exclude_tables, - const struct uuid *server) + const struct uuid *server, int probe_interval) { free(sync_from); sync_from = xstrdup(sync_from_); @@ -143,6 +143,8 @@ replication_init(const char *sync_from_, const char *exclude_tables, session = jsonrpc_session_open(sync_from, true); session_seqno = UINT_MAX; + jsonrpc_session_set_probe_interval(session, probe_interval); + /* Keep a copy of local server uuid. */ server_uuid = *server; @@ -979,6 +981,14 @@ is_replication_possible(struct ovsdb_schema *local_db_schema, return true; } +void +replication_set_probe_interval(int probe_interval) +{ + if (session) { + jsonrpc_session_set_probe_interval(session, probe_interval); + } +} + void replication_usage(void) { diff --git a/ovsdb/replication.h b/ovsdb/replication.h index 1f9c32fa7..c45f33e26 100644 --- a/ovsdb/replication.h +++ b/ovsdb/replication.h @@ -44,8 +44,10 @@ struct ovsdb; * used mainly by uinxctl commands. */ +#define REPLICATION_DEFAULT_PROBE_INTERVAL 60000 + void replication_init(const char *sync_from, const char *exclude_tables, - const struct uuid *server); + const struct uuid *server, int probe_interval); void replication_run(void); void replication_wait(void); void replication_destroy(void); @@ -54,6 +56,7 @@ void replication_add_local_db(const char *databse, struct ovsdb *db); bool replication_is_alive(void); int replication_get_last_error(void); char *replication_status(void); +void replication_set_probe_interval(int); char *set_blacklist_tables(const char *blacklist, bool dryrun) OVS_WARN_UNUSED_RESULT;