From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-f45.google.com (mail-lf1-f45.google.com [209.85.167.45]) (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 DEBB24765E1 for ; Tue, 22 Dec 2020 14:14:37 +0300 (MSK) Received: by mail-lf1-f45.google.com with SMTP id h22so21540755lfu.2 for ; Tue, 22 Dec 2020 03:14:37 -0800 (PST) From: Cyrill Gorcunov Date: Tue, 22 Dec 2020 14:14:05 +0300 Message-Id: <20201222111408.48368-3-gorcunov@gmail.com> In-Reply-To: <20201222111408.48368-1-gorcunov@gmail.com> References: <20201222111408.48368-1-gorcunov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH v6 2/5] cfg: rework box_check_replication_synchro_quorum List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: tml Cc: Vladislav Shpilevoy Currently the box_check_replication_synchro_quorum helper test for "replication_synchro_quorum" value being valid and returns the value itself to use later in code. This is fine for regular numbers but since we're gonna support formula evaluation the real value to use will be dynamic and returning a number "to use" won't be convenient. Thus lets change the context: make box_check_replication_synchro_quorum() to return 0|-1 for success|failure and when the real value is needed we will fetch it explicitly via cfg_geti call. To make this more explicit the real update of the appropriate variable is done via box_update_replication_synchro_quorum() helper. Part-of #5446 Signed-off-by: Cyrill Gorcunov --- src/box/box.cc | 21 ++++++++++++++------- src/box/box.h | 1 + 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/box/box.cc b/src/box/box.cc index a8bc3471d..630f579df 100644 --- a/src/box/box.cc +++ b/src/box/box.cc @@ -564,7 +564,7 @@ box_check_replication_synchro_quorum(void) "maximal number of replicas"); return -1; } - return quorum; + return 0; } static double @@ -765,7 +765,7 @@ box_check_config(void) box_check_replication_connect_timeout(); box_check_replication_connect_quorum(); box_check_replication_sync_lag(); - if (box_check_replication_synchro_quorum() < 0) + if (box_check_replication_synchro_quorum() != 0) diag_raise(); if (box_check_replication_synchro_timeout() < 0) diag_raise(); @@ -910,15 +910,22 @@ box_set_replication_sync_lag(void) replication_sync_lag = box_check_replication_sync_lag(); } +void +box_update_replication_synchro_quorum(void) +{ + int quorum = cfg_geti("replication_synchro_quorum"); + + replication_synchro_quorum = quorum; + txn_limbo_on_parameters_change(&txn_limbo); + box_raft_update_election_quorum(); +} + int box_set_replication_synchro_quorum(void) { - int value = box_check_replication_synchro_quorum(); - if (value < 0) + if (box_check_replication_synchro_quorum() != 0) return -1; - replication_synchro_quorum = value; - txn_limbo_on_parameters_change(&txn_limbo); - box_raft_update_election_quorum(); + box_update_replication_synchro_quorum(); return 0; } diff --git a/src/box/box.h b/src/box/box.h index b47a220b7..8a7cda194 100644 --- a/src/box/box.h +++ b/src/box/box.h @@ -251,6 +251,7 @@ void box_set_replication_timeout(void); void box_set_replication_connect_timeout(void); void box_set_replication_connect_quorum(void); void box_set_replication_sync_lag(void); +void box_update_replication_synchro_quorum(void); int box_set_replication_synchro_quorum(void); int box_set_replication_synchro_timeout(void); void box_set_replication_sync_timeout(void); -- 2.26.2