keva
keva copied to clipboard
Improve INFO command for Sentinel internal failover feature
Redis' Info commands return a lot of information, but only these are required by Sentinel: For slave:
run_id:4ba98afd1b8655725d9cbe64d9551bde0ceeffa0
role:slave
master_host:127.0.0.1
master_port:6381
master_link_status:down
slave_repl_offset:0
master_link_down_since_seconds:-1
slave_priority:100
slave_read_only:1
replica_announced:1
connected_slaves:0
master_failover_state:no-failover
Master
run_id:5a4dfcf77726cfcda754cbdc0a42d1cec6a7348d
role:master
connected_slaves:1
slave0:ip=127.0.0.1,port=6379,state=online,offset=42,lag=0
master_failover_state:no-failover
Explain:
- master_link_down_since_seconds: now() - last successful ping to master (or last ping received from master)
- master_failover_state: TBU
- master_link_status: current slave cannot contact with master
- slave_read_only: slave only executes read request
- slave_priority: a criteria used when promoting slaves to be new master (TBU)
- slave_repl_offset: TBU
- run_id: unique id of an instance, only null on the first run
- slavex:ip=....,port=...,state=...,offset=...,lag=... information of master about slave x, there can be multiple line like this, but the index of a slave should be consistent between calls Things to consider:
- Should we still use text based protocol and read line by line
- Should these information be displayed in external info command exposed to user's client, or keep it as an internal command
- Currently slave doesn't health check master so 'master_link_status' and 'master_link_down_since_seconds' will require some work.
- I'm implementing master to health check slave in #21 so 'connected_slaves' and 'slavex' can be available.
- Writing on slave in master-slave mode is not implemented yet as well. Currently if write command is sent to slave then it only change on that slave.
- Partial sync is not implemented yet so there's no 'slave_repl_offset'.
- The INFO command can be refactor to be a JSON string or any easy to serialize format.
- I'm still hesitant to split to internal command for now unless it's really needed.