提交 a5ec247f 编写于 作者: A antirez

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.
上级 0a89d9a0
......@@ -2522,6 +2522,13 @@ sds genRedisInfoString(char *section) {
"role:%s\r\n",
server.masterhost == NULL ? "master" : "slave");
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,
"master_host:%s\r\n"
"master_port:%d\r\n"
......@@ -2536,7 +2543,7 @@ sds genRedisInfoString(char *section) {
server.master ?
((int)(server.unixtime-server.master->lastinteraction)) : -1,
server.repl_state == REDIS_REPL_TRANSFER,
server.master ? server.master->reploff : -1
slave_repl_offset
);
if (server.repl_state == REDIS_REPL_TRANSFER) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册