Skip to content
Snippets Groups Projects
Commit ed46feb2 authored by Boris Stepanenko's avatar Boris Stepanenko Committed by Kirill Yukhin
Browse files

raft: leader fencing on quorum loss

Losing quorum didn't modify RAFT leader behaviour, this led to easy
split brain situation, when current leader gets disconnected from the
rest of the replicaset. Old leader remained RW while new leader could be
elected in the rest of the replicaset.

Now when current leader looses connection to replica (connection being
alive relay and applier for that replica) leader checks that he still
has at least quorum of alive connections to replicas. If less than
quorum of alive connection remain: leader resigns its role becoming
follower without starting new term. This makes old leader RO. Old leader
won't start new elections because of pre-vote, added in 421a0968.

Fenced leader will "freeze" its limbo, and won't CONFIRM nor ROLLBACK
any synchronous transactions until it regains leadership. If another
leader is elected while old one is fenced, once old leader is reconnected
to new one "frozen" transaction will be rolled back.

When quorum of connections is regained and new leader is not elected
old leader or another node will start elections and elect new leader.

Closes #6661

@TarantoolBot document
Title: RAFT leader fencing

RAFT documentation must include that RAFT leader will resign its
leadership if it has less than replication_synchro_quruom of alive
connections to replicas (alive connection is connected relay and applier)
if fencing is on. This applies to election_mode 'candidate' or 'manual'.
Resigning leadership is becoming follower in current RAFT term, this
leads to resigned leader becoming read-only.

Introduce a new `box.cfg` option - `election_fencing_enabled`. If set to
`true` fencing is on (default behaviour). If set to `false` fencing is off
and leader doesn't resign it's leadership when looses quorum. If enabled
on the current leader, when it doesn't have quorum of alive connections -
leader will immediately resign its leadership.
parent 2539b02a
Loading
Showing
with 561 additions and 16 deletions
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