Skip to content

Commit

Permalink
Fix fastsync test failures caused by closing due to repl buffer size …
Browse files Browse the repository at this point in the history
…too soon
  • Loading branch information
JohnSully committed Apr 5, 2024
1 parent e580a8e commit c50e2d4
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/replication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1158,10 +1158,23 @@ class replicationBuffer {
}

void putSlavesOnline() {
for (auto replica : replicas) {
std::unique_lock<fastlock> ul(replica->lock);
// If we put the replica online before the output is drained then it will get immediately closed
while (checkClientOutputBufferLimits(replica)
&& (replica->flags.load(std::memory_order_relaxed) & CLIENT_CLOSE_ASAP) == 0) {
ul.unlock();
usleep(1000); // give 1ms for the I/O before we poll again
ul.lock();
}
}

aeAcquireLock();
for (auto replica : replicas) {
replica->replstate = SLAVE_STATE_FASTSYNC_DONE;
replica->repl_put_online_on_ack = 1;
}
aeReleaseLock();
}

void abort() {
Expand Down Expand Up @@ -1282,9 +1295,7 @@ int rdbSaveSnapshotForReplication(rdbSaveInfo *rsi) {
auto usec = ustime() - timeStart;
serverLog(LL_NOTICE, "Transferred %zuMB total (%zuMB data) in %.2f seconds. (%.2fGbit/s)", spreplBuf->cbWritten()/1024/1024, cbData/1024/1024, usec/1000000.0, (spreplBuf->cbWritten()*8.0)/(usec/1000000.0)/1000000000.0);
if (retval == C_OK) {
aeAcquireLock();
replBuf.putSlavesOnline();
aeReleaseLock();
}
});

Expand Down

0 comments on commit c50e2d4

Please sign in to comment.