-
Notifications
You must be signed in to change notification settings - Fork 155
Description
Sequencer Role:
In the sequencer, the following components depend on the Sequencer role:
BlobSenderSeqDBCacheWarmUpTimeOracleInner/sync_stateReplicaSyncTask
Goal
The goal of this issue is to define the steps required to transition the Sequencer from the Replica role to the Leader role.
Challenges
1. Atomicity
The transition must be atomic from the perspective of the external world. The Sequencer must never appear to be in a partially transitioned state—it should be either fully in the Replica role or fully in the Leader role.
2. Ordering
A strict ordering for switching components must be established. For example, switching Inner/sync_state to Leader mode before switching BlobSender would result in an invalid sequencer state. During the transition, the replica could start producing empty batches while BlobSender is still inactive and unable to send them, pushing the sequencer into a bad state.
3. Lifecycle of async tasks
Many of the components above (e.g., BlobSender, CacheWarmUp, TimeOracle) spawn asynchronous actors that are registered when the sequencer starts. Replicas do not start these actors. However, the system currently does not support starting these tasks after the sequencer has already been initialized.
If 2 and 3 are well designed, atomicity should follow automatically.
2. Ordering should be enforced by a dedicated component, ReplicaToLeaderTransitionManager.
During the Replica → Leader transition, the following sequence should occur:
-
ReplicaToLeaderTransitionManagerreceives a database notification indicating that the node has become the newLeader. -
It sends a shutdown request to
ReplicaSyncTaskand waits for confirmation that the task has fully stopped. -
It sends a request to
Inner/sync_stateto transition to Leader mode. -
Inner/sync_state:- Sends a request via
SideEffectsTaskinstructingBlobSenderandSeqDBto upgrade to the Leader role. - Updates its local role flag to
Leader. - To support this, we will introduce a new
ExecutorEvent::UpgradeToLeadermessage inSideEffectsTask.
- Sends a request via
-
ReplicaToLeaderTransitionManagermust provide a mechanism to wait until step 4 has fully completed. -
ReplicaToLeaderTransitionManagersends a request toCacheWarmUp, notifying it to start. -
ReplicaToLeaderTransitionManagersends a request toTimeOracle, notifying it to start.