You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by GitBox <gi...@apache.org> on 2022/08/30 01:11:17 UTC

[GitHub] [iotdb] JackieTien97 commented on a diff in pull request #7133: [IOTDB-4114] Add safety check for createPeer

JackieTien97 commented on code in PR #7133:
URL: https://github.com/apache/iotdb/pull/7133#discussion_r957914646


##########
consensus/src/main/java/org/apache/iotdb/consensus/ratis/RatisConsensus.java:
##########
@@ -256,6 +257,12 @@ public ConsensusGenericResponse createPeer(ConsensusGroupId groupId, List<Peer>
     if (!group.getPeers().contains(myself)) {
       return failed(new ConsensusGroupNotExistException(groupId));
     }
+    RaftGroupId raftGroupId = Utils.fromConsensusGroupIdToRaftGroupId(groupId);
+    RaftGroup existGroup = getGroupInfo(raftGroupId);
+    // pre-conditions: the new group not exists
+    if (existGroup != null) {
+      return failed(new ConsensusGroupAlreadyExistException(groupId));
+    }

Review Comment:
   It seems that even if you do this check, it could not totally prevent this problem because this checking and creating are not atomically.



-- 
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: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org