From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-f52.google.com (mail-lf1-f52.google.com [209.85.167.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 88BA8469710 for ; Thu, 19 Nov 2020 22:41:29 +0300 (MSK) Received: by mail-lf1-f52.google.com with SMTP id j205so9959392lfj.6 for ; Thu, 19 Nov 2020 11:41:29 -0800 (PST) From: Cyrill Gorcunov Date: Thu, 19 Nov 2020 22:40:58 +0300 Message-Id: <20201119194100.840495-3-gorcunov@gmail.com> In-Reply-To: <20201119194100.840495-1-gorcunov@gmail.com> References: <20201119194100.840495-1-gorcunov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [RFC 2/4] qsync: move synchro quorum update to separate routine List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: tml Cc: Vladislav Shpilevoy We will be updating replication_synchro_quorum parameter dynamically once we add support for number evaluation via symbolic formula, thus the update will be called not only from manual configuration changes but from cluster updates as well. Thus to reuse the code lets gather it into a separate routine. Part-of #5446 Signed-off-by: Cyrill Gorcunov --- src/box/box.cc | 4 +--- src/box/replication.cc | 18 ++++++++++++++++++ src/box/replication.h | 3 +++ 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/box/box.cc b/src/box/box.cc index 1f7dec362..5fcf28cb3 100644 --- a/src/box/box.cc +++ b/src/box/box.cc @@ -924,9 +924,7 @@ box_set_replication_synchro_quorum(void) int value = box_check_replication_synchro_quorum(); if (value < 0) return -1; - replication_synchro_quorum = value; - txn_limbo_on_parameters_change(&txn_limbo); - raft_cfg_election_quorum(box_raft()); + replication_synchro_quorum_update(value); return 0; } diff --git a/src/box/replication.cc b/src/box/replication.cc index 65512cf0f..c83392f81 100644 --- a/src/box/replication.cc +++ b/src/box/replication.cc @@ -40,7 +40,9 @@ #include "gc.h" #include "error.h" #include "relay.h" +#include "raft.h" #include "sio.h" +#include "txn_limbo.h" uint32_t instance_id = REPLICA_ID_NIL; struct tt_uuid INSTANCE_UUID; @@ -82,6 +84,22 @@ replicaset_quorum(void) return MIN(replication_connect_quorum, replicaset.applier.total); } +/** + * Update the synchro quorum number and propagate the + * change to dependent subsystems. + */ +void +replication_synchro_quorum_update(int value) +{ + assert(value > 0 && value < VCLOCK_MAX); + + say_info("replication: replication_synchro_quorum = %d", value); + + replication_synchro_quorum = value; + txn_limbo_on_parameters_change(&txn_limbo); + raft_cfg_election_quorum(box_raft()); +} + void replication_init(void) { diff --git a/src/box/replication.h b/src/box/replication.h index e57912848..ced519612 100644 --- a/src/box/replication.h +++ b/src/box/replication.h @@ -175,6 +175,9 @@ replication_disconnect_timeout(void) return replication_timeout * 4; } +void +replication_synchro_quorum_update(int value); + void replication_init(void); -- 2.26.2