From 561deec120436a9f83f0104f3943c03b2ecf7da8 Mon Sep 17 00:00:00 2001 From: takenliu Date: Mon, 26 Jan 2026 17:00:58 +0800 Subject: [PATCH] fix bug: switching the slots and bumping the configEpoch must be executed within the same mutex lock. --- src/tendisplus/cluster/cluster_manager.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/tendisplus/cluster/cluster_manager.cpp b/src/tendisplus/cluster/cluster_manager.cpp index 058ac4a4..d9ea5b01 100644 --- a/src/tendisplus/cluster/cluster_manager.cpp +++ b/src/tendisplus/cluster/cluster_manager.cpp @@ -1220,14 +1220,18 @@ Status ClusterState::setSlots(CNodePtr n, } ++idx; } + // NOTE(takenliu): switching the slots and bumping the configEpoch + // must be executed within the same mutex lock. + if (n == getMyselfNode()) { + Status s = clusterBumpConfigEpochWithoutConsensus(); + if (!s.ok()) { + LOG(ERROR) << "setSlots BumpConfigEpoch fail"; + return s; + } + } } if (n == getMyselfNode()) { - Status s = clusterBumpConfigEpochWithoutConsensus(); - if (!s.ok()) { - LOG(ERROR) << "setSlots BumpConfigEpoch fail"; - return s; - } // NOTE(wayenchen) broadcast gossip message if meta change finished uint64_t offset = _server->getReplManager()->replicationGetOffset(); clusterBroadcastPong(CLUSTER_BROADCAST_ALL, offset);