From f0e17a7d04c7014d9c516d2862f1dadc053f0f82 Mon Sep 17 00:00:00 2001 From: John Sully Date: Thu, 11 Jul 2019 19:20:12 -0400 Subject: [PATCH] Fix more accounting errors with active replication and the replication offset. Specifically we don't update repl_ack_off as frequently as we do reploff_skipped Former-commit-id: 6cf85d1d01e56de0bb6e5d34590623cd8dabd32b --- src/replication.cpp | 6 +++--- src/server.cpp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/replication.cpp b/src/replication.cpp index c5d9fa6bc..b37d1b655 100644 --- a/src/replication.cpp +++ b/src/replication.cpp @@ -992,7 +992,7 @@ void replconfCommand(client *c) { if ((getLongLongFromObject(c->argv[j+1], &offset) != C_OK)) return; if (offset > c->repl_ack_off) - c->repl_ack_off = offset + c->reploff_skipped; + c->repl_ack_off = offset; c->repl_ack_time = g_pserver->unixtime; /* If this was a diskless replication, we need to really put * the slave online when the first ACK is received (which @@ -2435,7 +2435,7 @@ void roleCommand(client *c) { addReplyArrayLen(c,3); addReplyBulkCString(c,slaveip); addReplyBulkLongLong(c,slave->slave_listening_port); - addReplyBulkLongLong(c,slave->repl_ack_off); + addReplyBulkLongLong(c,slave->repl_ack_off+slave->reploff_skipped); slaves++; } setDeferredArrayLen(c,mbcount,slaves); @@ -2780,7 +2780,7 @@ int replicationCountAcksByOffset(long long offset) { client *slave = (client*)ln->value; if (slave->replstate != SLAVE_STATE_ONLINE) continue; - if (slave->repl_ack_off >= offset) count++; + if ((slave->repl_ack_off + slave->reploff_skipped) >= offset) count++; } return count; } diff --git a/src/server.cpp b/src/server.cpp index 087821078..4d2735467 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -4448,7 +4448,7 @@ sds genRedisInfoString(const char *section) { "slave%d:ip=%s,port=%d,state=%s," "offset=%lld,lag=%ld\r\n", slaveid,slaveip,slave->slave_listening_port,state, - slave->repl_ack_off, lag); + (slave->repl_ack_off + slave->reploff_skipped), lag); slaveid++; } }