Skip to content
Snippets Groups Projects
Commit e140e7cd authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Vladislav Shpilevoy
Browse files

cfg: rework box_check_replication_synchro_quorum


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: default avatarCyrill Gorcunov <gorcunov@gmail.com>
parent 8d090514
No related branches found
No related tags found
No related merge requests found
......@@ -565,7 +565,7 @@ box_check_replication_synchro_quorum(void)
"maximal number of replicas");
return -1;
}
return quorum;
return 0;
}
static double
......@@ -766,7 +766,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();
......@@ -911,15 +911,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;
}
......
......@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment