Commit 04ca7d8a authored by Oran Agra's avatar Oran Agra
Browse files

Attempt to fix a rare crash in cluster tests. (#10265)

The theory is that a replica gets disconnected from within REPLCONF ACK,
so when we go up the stack, we'll crash when attempting to access
c->cmd->flags

(cherry picked from commit aa9beaca)
parent 280e6a89
...@@ -1224,6 +1224,9 @@ void updateSlavesWaitingBgsave(int bgsaveerr, int type) { ...@@ -1224,6 +1224,9 @@ void updateSlavesWaitingBgsave(int bgsaveerr, int type) {
int mincapa = -1; int mincapa = -1;
listIter li; listIter li;
/* Note: there's a chance we got here from within the REPLCONF ACK command
* so we must avoid using freeClient, otherwise we'll crash on our way up. */
listRewind(server.slaves,&li); listRewind(server.slaves,&li);
while((ln = listNext(&li))) { while((ln = listNext(&li))) {
client *slave = ln->value; client *slave = ln->value;
...@@ -1236,7 +1239,7 @@ void updateSlavesWaitingBgsave(int bgsaveerr, int type) { ...@@ -1236,7 +1239,7 @@ void updateSlavesWaitingBgsave(int bgsaveerr, int type) {
struct redis_stat buf; struct redis_stat buf;
if (bgsaveerr != C_OK) { if (bgsaveerr != C_OK) {
freeClient(slave); freeClientAsync(slave);
serverLog(LL_WARNING,"SYNC failed. BGSAVE child returned an error"); serverLog(LL_WARNING,"SYNC failed. BGSAVE child returned an error");
continue; continue;
} }
...@@ -1281,7 +1284,7 @@ void updateSlavesWaitingBgsave(int bgsaveerr, int type) { ...@@ -1281,7 +1284,7 @@ void updateSlavesWaitingBgsave(int bgsaveerr, int type) {
} else { } else {
if ((slave->repldbfd = open(server.rdb_filename,O_RDONLY)) == -1 || if ((slave->repldbfd = open(server.rdb_filename,O_RDONLY)) == -1 ||
redis_fstat(slave->repldbfd,&buf) == -1) { redis_fstat(slave->repldbfd,&buf) == -1) {
freeClient(slave); freeClientAsync(slave);
serverLog(LL_WARNING,"SYNC failed. Can't open/stat DB after BGSAVE: %s", strerror(errno)); serverLog(LL_WARNING,"SYNC failed. Can't open/stat DB after BGSAVE: %s", strerror(errno));
continue; continue;
} }
...@@ -1293,7 +1296,7 @@ void updateSlavesWaitingBgsave(int bgsaveerr, int type) { ...@@ -1293,7 +1296,7 @@ void updateSlavesWaitingBgsave(int bgsaveerr, int type) {
connSetWriteHandler(slave->conn,NULL); connSetWriteHandler(slave->conn,NULL);
if (connSetWriteHandler(slave->conn,sendBulkToSlave) == C_ERR) { if (connSetWriteHandler(slave->conn,sendBulkToSlave) == C_ERR) {
freeClient(slave); freeClientAsync(slave);
continue; continue;
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment