dragonflydb / dragonflydb/dragonfly-operator
Sentinel Failover Replica Choice
- Dominant language
- Go
- Stars
- 357
- Forks
- 111
- PR merge metrics
- No merged PRs in 30d
Description
I am not sure if the operator is already implemented this way, but below is how Sentinel decides which replica to choose when performing a failover. If not, maybe the operator can use a similar logic to pick the most desired replica instance.
### Step-1 Use the replica with the lowest `replica-priority`
- As documented [here](https://github.com/redis/redis/blob/unstable/redis.conf), Sentinal prioritizes the `replica-priority` value when choosing a replica for failover.
- This value is returned by the Redis [INFO](https://redis.io/commands/info/) command as **`slave_priority`**.
- If all replicas have the same `replica-priority` value, go to Step-2.
### Step-2 Use the replica with the highest `slave_repl_offset`.
- The `slave_repl_offset` value, as returned by the [INFO](https://redis.io/commands/info/) command, reports the replication offset of the replica instance.
- A replica instance with a higher `slave_repl_offset` value means that it is the closest to the primary instance in terms of replication, thus more suitable for a promotion.
- If more than one replica instances have the same `slave_repl_offset` value, go to Step-3.
### Step-3 Use the lowest `run_id` value.
- Also returned by the [INFO](https://redis.io/commands/info/) command.
- Sentinel defaults to the replica instance with the lowest `run_id` value as the last resort.
Contributor guide
Assessment
This issue has not been assessed yet.