[Tarantool-patches] [PATCH 2/2] election: during bootstrap prefer candidates
Vladislav Shpilevoy
v.shpilevoy at tarantool.org
Sun Jul 18 20:00:41 MSK 2021
Thanks for the review!
>> diff --git a/src/box/box.cc b/src/box/box.cc
>> index ef3efe3e0..3105b04b6 100644
>> --- a/src/box/box.cc
>> +++ b/src/box/box.cc
>> @@ -3519,7 +3519,30 @@ box_cfg_xc(void)
>> * should take the control over the situation and start a new
>> * term immediately.
>> */
>> - raft_new_term(box_raft());
>> + struct raft *raft = box_raft();
>> + if (box_election_mode == ELECTION_MODE_MANUAL) {
>> + raft_start_candidate(raft);
>> + raft_new_term(raft);
>> + int rc = box_raft_wait_leader_found();
>> + /*
>> + * No need to check if the mode is still manual - it
>> + * couldn't change because box.cfg is protected with a
>> + * fiber lock.
>> + */
>> + assert(box_election_mode == ELECTION_MODE_MANUAL);
>> + raft_stop_candidate(raft, false);
>> + /*
>> + * It should not fail, because on bootstrap the node is
>> + * a single registered instance. It can't not win the
>> + * elections while being a lone participant. But still
>> + * check the result so as not to a ignore potential
>> + * problems.
>> + */
>> + if (rc != 0)
>> + diag_raise();
>> + } else {
>> + raft_new_term(raft);
>> + }
>
> Could you please extract this fix into a separate commit?
Done. See v2.
> Speaking of your problems with raft_try_candidate. I also can't think
> of a good enough alternative.
>
> For promote it would be nice to do:
>
> do {
> raft_try_candidate_for_1_term();
> } while (leader is not known);
>
> and simply
> raft_try_candidate_for_1_term();
> for bootstrap.
>
> But raft_try_candidate_for_1_term() looks hard to implement.
Yes, I had something like that in mind too. I tried to
implement it in v2.
More information about the Tarantool-patches
mailing list