Skip to content
Snippets Groups Projects
Commit 68de8753 authored by Vladislav Shpilevoy's avatar Vladislav Shpilevoy
Browse files

raft: replace raft_start_candidate with _promote

raft_state_candiate() made the instance a candidate until it was
reconfigured or raft_stop_candidate() was called. It was used
during promotion of a 'manual' instance.

This however was relatively hard to use - raft_stop_candidate()
had a flag 'do_demote' which was passed as true only by Raft
internally, and it also wasn't very consistent with box.promote()
which works for one term only.

One of the next patches is going to need Raft promotion again but
for just one term. In order not to use raft_start/stop_leader()
again, this patch replaces them with raft_promote() and
raft_restore().

raft_promote() works very similar to box.promote() - it bumps the
term and makes the instance a candidate for this term. If it wins,
it stays a leader until next term happens.

Otherwise either a new term is started and the node stops being a
leader, or another node becomes a leader. In the former case
raft_promote() might be called again to retry.

Replacement couldn't be done independently from box/ changes,
because raft_start/stop_candidate couldn't be kept - any term
bump runs raft_restore() which is the same as
raft_stop_candidate(do_demote=true), and that makes the old
functions useless. Hence the patch also includes box/ changes.

Part of #6018
parent 6a0b861a
No related branches found
No related tags found
Loading
Loading
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