Skip to content

Commit e5ef161

Browse files
authored
Fix crash when running rebalance command in a mixed cluster of 7.0 and 7.2 (redis#12604)
In redis#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 redis#12538. In this PR, we remove the assert and replace it with an unconditional removal.
1 parent 4de4fcf commit e5ef161

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

src/cluster.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4935,12 +4935,8 @@ int clusterDelSlot(int slot) {
49354935
if (!n) return C_ERR;
49364936

49374937
/* Cleanup the channels in master/replica as part of slot deletion. */
4938-
list *nodes_for_slot = clusterGetNodesInMyShard(n);
4939-
serverAssert(nodes_for_slot != NULL);
4940-
listNode *ln = listSearchKey(nodes_for_slot, myself);
4941-
if (ln != NULL) {
4942-
removeChannelsInSlot(slot);
4943-
}
4938+
removeChannelsInSlot(slot);
4939+
/* Clear the slot bit. */
49444940
serverAssert(clusterNodeClearSlotBit(n,slot) == 1);
49454941
server.cluster->slots[slot] = NULL;
49464942
/* Make owner_not_claiming_slot flag consistent with slot ownership information. */

0 commit comments

Comments
 (0)