This commit is contained in:
patpatbear 2026-02-04 04:52:38 +07:00 committed by GitHub
commit d945f4db6f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1802,7 +1802,17 @@ void disconnectSlaves(void) {
listNode *ln;
listRewind(server.slaves,&li);
while((ln = listNext(&li))) {
freeClient((client*)ln->value);
/* Attempt to flush pending replication stream before disconnecting
* slaves without blocking, increasing the chances of successful
* psync for slaves when failed over. */
client *slave = (client*)ln->value;
writeToClient(slave,0);
if (clientHasPendingReplies(slave)) {
sds client_desc = catClientInfoString(sdsempty(), slave);
serverLog(LL_NOTICE, "Slave still have pending replies when disconnect: %s", client_desc);
sdsfree(client_desc);
}
freeClient(slave);
}
}