From ab26f24b184e602d392dcde31e148a45488d0d5a Mon Sep 17 00:00:00 2001 From: Oran Agra Date: Sun, 3 Jan 2021 11:56:26 +0200 Subject: [PATCH] fix crash in redis-cli after making cluster backup (#8267) getRDB is "designed" to work in two modes: one for redis-cli --rdb and one for redis-cli --cluster backup. in the later case it uses the hiredis connection from the cluster nodes and it used to free it without nullifying the context, so a later attempt to free the context would crash. I suppose the reason it seems to want to free the hiredis context ASAP is that it wants to disconnect the replica link, so that replication buffers will not be accumulated. (cherry picked from commit 93b8b139305a99678528fabc9bf9cc5e9133b5a4) --- src/redis-cli.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/redis-cli.c b/src/redis-cli.c index 45a1228e6..5456d3cb9 100644 --- a/src/redis-cli.c +++ b/src/redis-cli.c @@ -7073,7 +7073,9 @@ static void getRDB(clusterManagerNode *node) { } else { fprintf(stderr,"Transfer finished with success.\n"); } - redisFree(s); /* Close the file descriptor ASAP as fsync() may take time. */ + redisFree(s); /* Close the connection ASAP as fsync() may take time. */ + if (node) + node->context = NULL; fsync(fd); close(fd); fprintf(stderr,"Transfer finished with success.\n");