- All Implemented Interfaces:
- org.neo4j.kernel.lifecycle.Lifecycle
public class RaftMembershipState
extends org.neo4j.kernel.lifecycle.LifecycleAdapter
Represents the current state of membership in RAFT and exposes operations
for modifying the state. The valid states and transitions are represented
by the following table:
state valid transitions
1: [ - , - ] 2 (append)
2: [ - , appended ] 1,4 (commit or truncate)
3: [ committed, appended ] 4 (commit or truncate)
4: [ committed, - ] 3 (append)
The transition from 3->4 is either because the appended entry became
the new committed entry or because the appended entry was truncated.
A committed entry can never be truncated and there can only be a single
outstanding appended entry which usually is committed shortly
thereafter, but it might also be truncated.
Recovery must in-order replay all the log entries whose effects are not
guaranteed to have been persisted. The handling of these events is
idempotent so it is safe to replay entries which might have been
applied already.
Note that commit updates occur separately from append/truncation in RAFT
so it is possible to for example observe several membership entries in a row
being appended on a particular member without an intermediate commit, even
though this is not possible in the system as a whole because the leader which
drives the membership change work will not spawn a new entry until it knows
that the previous one has been appended with a quorum, i.e. committed. This
is the reason why that this class is very lax when it comes to updating the
state and not making hard assertions which on a superficial level might
seem obvious. The consensus system as a whole and the membership change
driving logic is relied upon for achieving the correct system level
behaviour.