mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-23 00:28:26 -05:00
Replication: publish the slave_repl_offset when disconnected from master.
When a slave was disconnected from its master the replication offset was reported as -1. Now it is reported as the replication offset of the previous master, so that failover can be performed using this value in order to try to select a slave with more processed data from a set of slaves of the old master.
This commit is contained in:
parent
0a89d9a0b1
commit
a5ec247f13
@ -2522,6 +2522,13 @@ sds genRedisInfoString(char *section) {
|
|||||||
"role:%s\r\n",
|
"role:%s\r\n",
|
||||||
server.masterhost == NULL ? "master" : "slave");
|
server.masterhost == NULL ? "master" : "slave");
|
||||||
if (server.masterhost) {
|
if (server.masterhost) {
|
||||||
|
long long slave_repl_offset = 1;
|
||||||
|
|
||||||
|
if (server.master)
|
||||||
|
slave_repl_offset = server.master->reploff;
|
||||||
|
else if (server.cached_master)
|
||||||
|
slave_repl_offset = server.cached_master->reploff;
|
||||||
|
|
||||||
info = sdscatprintf(info,
|
info = sdscatprintf(info,
|
||||||
"master_host:%s\r\n"
|
"master_host:%s\r\n"
|
||||||
"master_port:%d\r\n"
|
"master_port:%d\r\n"
|
||||||
@ -2536,7 +2543,7 @@ sds genRedisInfoString(char *section) {
|
|||||||
server.master ?
|
server.master ?
|
||||||
((int)(server.unixtime-server.master->lastinteraction)) : -1,
|
((int)(server.unixtime-server.master->lastinteraction)) : -1,
|
||||||
server.repl_state == REDIS_REPL_TRANSFER,
|
server.repl_state == REDIS_REPL_TRANSFER,
|
||||||
server.master ? server.master->reploff : -1
|
slave_repl_offset
|
||||||
);
|
);
|
||||||
|
|
||||||
if (server.repl_state == REDIS_REPL_TRANSFER) {
|
if (server.repl_state == REDIS_REPL_TRANSFER) {
|
||||||
|
Loading…
Reference in New Issue
Block a user