summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOran Agra <oran@redislabs.com>2021-01-03 11:56:26 +0200
committerGitHub <noreply@github.com>2021-01-03 11:56:26 +0200
commit41b2ed2bbc0671e43101feecc48cac26a5e312cb (patch)
treeb8fc8748c6a14833ae75b47777009e6c2180bfb3
parent71fbe6e800a10dabc81b1aec96bcca3b74af7bf4 (diff)
downloadredis-41b2ed2bbc0671e43101feecc48cac26a5e312cb.tar.gz
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.
-rw-r--r--src/redis-cli.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/redis-cli.c b/src/redis-cli.c
index ff29de748..31d2360c9 100644
--- a/src/redis-cli.c
+++ b/src/redis-cli.c
@@ -7132,7 +7132,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");