diff --git a/src/networking.cpp b/src/networking.cpp index c51a02a1d..6f4aa6268 100644 --- a/src/networking.cpp +++ b/src/networking.cpp @@ -1782,7 +1782,7 @@ int writeToClient(client *c, int handler_installed) { // } - if (nwritten == nrequested){ + if (nwritten == nrequested && g_pserver->repl_backlog_idx == c->repl_curr_idx){ c->repl_curr_idx = -1; /* -1 denotes no more replica writes */ } else if (nwritten > 0) diff --git a/src/replication.cpp b/src/replication.cpp index 60f25052a..d3df6d12a 100644 --- a/src/replication.cpp +++ b/src/replication.cpp @@ -90,7 +90,7 @@ void resizeReplicationBacklogForClients(long long newsize); void setReplIdx(client *c, long long idx, long long off){ // serverLog(LL_NOTICE, "calling this garbage function w/ idx and off: %lld, %lld, %lld", idx, off, off-idx); // serverLog(LL_NOTICE, "Repl Index started at: %lld", c->repl_curr_idx); - if (c->repl_curr_idx == -1){ + if (c->repl_curr_idx == -1 && off >= c->repl_curr_off){ if (prepareClientToWrite(c) != C_OK) return; c->repl_curr_idx = idx; c->repl_curr_off = off;