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);