From 7f6de086fe74dac7bdbee57d71b409635b368960 Mon Sep 17 00:00:00 2001 From: Binbin Date: Thu, 12 Oct 2023 00:15:25 -0500 Subject: [PATCH] Fix crash when running rebalance command in a mixed cluster of 7.0 and 7.2 (#12604) In #10536, we introduced the assert, some older versions of servers (like 7.0) doesn't gossip shard_id, so we will not add the node to cluster->shards, and node->shard_id is filled in randomly and may not be found here. It causes that if we add a 7.2 node to a 7.0 cluster and allocate slots to the 7.2 node, the 7.2 node will crash when it hits this assert. Somehow like #12538. In this PR, we remove the assert and replace it with an unconditional removal. (cherry picked from commit e5ef161374155bb84a5720387836415ef3217963) --- src/cluster.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/cluster.c b/src/cluster.c index 9cfa99a32..0cb61d858 100644 --- a/src/cluster.c +++ b/src/cluster.c @@ -4936,12 +4936,8 @@ int clusterDelSlot(int slot) { if (!n) return C_ERR; /* Cleanup the channels in master/replica as part of slot deletion. */ - list *nodes_for_slot = clusterGetNodesInMyShard(n); - serverAssert(nodes_for_slot != NULL); - listNode *ln = listSearchKey(nodes_for_slot, myself); - if (ln != NULL) { - removeChannelsInSlot(slot); - } + removeChannelsInSlot(slot); + /* Clear the slot bit. */ serverAssert(clusterNodeClearSlotBit(n,slot) == 1); server.cluster->slots[slot] = NULL; return C_OK;