liyuheng55555 commented on code in PR #14505:
URL: https://github.com/apache/iotdb/pull/14505#discussion_r1893618930
##########
iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/iot/IoTConsensus.java:
##########
@@ -178,10 +180,30 @@ private void initAndRecover() throws IOException {
syncClientManager,
config);
stateMachineMap.put(consensusGroupId, consensus);
- consensus.start();
}
}
}
+ if (correctPeerListBeforeStart != null) {
+ BiConsumer<ConsensusGroupId, List<Peer>> resetPeerListWithoutThrow =
+ (consensusGroupId, peers) -> {
+ try {
+ resetPeerList(consensusGroupId, peers);
+ } catch (ConsensusGroupNotExistException ignore) {
+
+ } catch (Exception e) {
+ logger.warn("Failed to reset peer list while start", e);
+ }
+ };
+ // make peers which are in list correct
+ correctPeerListBeforeStart.forEach(resetPeerListWithoutThrow);
+ // clear peers which are not in the list
+ stateMachineMap.keySet().stream()
Review Comment:
Indeed. Copy to a new list to avoid concurrent modification.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]