liyuheng55555 commented on code in PR #12246:
URL: https://github.com/apache/iotdb/pull/12246#discussion_r1544035115


##########
iotdb-core/confignode/src/test/resources/confignode1conf/iotdb-common.properties:
##########
@@ -20,8 +20,8 @@
 timestamp_precision=ms
 
data_region_consensus_protocol_class=org.apache.iotdb.consensus.iot.IoTConsensus
 
schema_region_consensus_protocol_class=org.apache.iotdb.consensus.ratis.RatisConsensus
-schema_replication_factor=3
-data_replication_factor=3
+schema_replication_factor=2
+data_replication_factor=2

Review Comment:
   revert ?



##########
integration-test/src/test/java/org/apache/iotdb/confignode/it/regionmigration/IoTDBRegionMigrateReliabilityTestFramework.java:
##########
@@ -90,195 +88,182 @@ public void tearDown() throws InterruptedException {
     EnvFactory.getEnv().cleanClusterEnvironment();
   }
 
-  // region Normal tests
-
-  @Test
-  public void normal1C2DTest() throws Exception {
-    generalTest(1, 1, 1, 2, buildSet(), buildSet());
-  }
-
-  @Test
-  public void normal3C3DTest() throws Exception {
-    generalTest(2, 3, 3, 3, buildSet(), buildSet());
-  }
-
-  // endregion
-
-  // region ConfigNode crash tests
-  @Test
-  public void cnCrashDuringPreCheck() throws Exception {
-    generalTest(
-        1, 1, 1, 2, 
buildSet(RegionTransitionState.REGION_MIGRATE_PREPARE.toString()), buildSet());
-  }
-
-  @Test
-  public void cnCrashDuringCreatePeer() throws Exception {
-    generalTest(
-        1, 1, 1, 2, 
buildSet(AddRegionPeerState.CREATE_NEW_REGION_PEER.toString()), buildSet());
-  }
-
-  @Test
-  public void cnCrashDuringDoAddPeer() throws Exception {
-    generalTest(1, 1, 1, 2, 
buildSet(AddRegionPeerState.DO_ADD_REGION_PEER.toString()), buildSet());
-  }
-
-  @Test
-  public void cnCrashDuringUpdateCache() throws Exception {
-    generalTest(
-        1,
-        1,
-        1,
-        2,
-        buildSet(AddRegionPeerState.UPDATE_REGION_LOCATION_CACHE.toString()),
-        buildSet());
-  }
-
-  @Test
-  public void cnCrashDuringChangeRegionLeader() throws Exception {
-    generalTest(
-        1, 1, 1, 2, 
buildSet(RegionTransitionState.CHANGE_REGION_LEADER.toString()), buildSet());
-  }
-
-  @Test
-  public void cnCrashDuringRemoveRegionPeer() throws Exception {
-    generalTest(
-        1, 1, 1, 2, 
buildSet(RemoveRegionPeerState.REMOVE_REGION_PEER.toString()), buildSet());
-  }
-
-  @Test
-  public void cnCrashDuringDeleteOldRegionPeer() throws Exception {
-    generalTest(
-        1, 1, 1, 2, 
buildSet(RemoveRegionPeerState.DELETE_OLD_REGION_PEER.toString()), buildSet());
-  }
-
-  @Test
-  public void cnCrashDuringRemoveRegionLocationCache() throws Exception {
-    generalTest(
-        1,
-        1,
-        1,
-        2,
-        
buildSet(RemoveRegionPeerState.REMOVE_REGION_LOCATION_CACHE.toString()),
-        buildSet());
-  }
-
-  @Test
-  public void cnCrashTest() throws Exception {
-    KeySetView<String, Boolean> killConfigNodeKeywords = buildSet();
-    killConfigNodeKeywords.addAll(
-        Arrays.stream(AddRegionPeerState.values())
-            .map(Enum::toString)
-            .collect(Collectors.toList()));
-    killConfigNodeKeywords.addAll(
-        Arrays.stream(RemoveRegionPeerState.values())
-            .map(Enum::toString)
-            .collect(Collectors.toList()));
-    generalTest(1, 1, 1, 2, killConfigNodeKeywords, buildSet());
-  }
-
-  @Ignore
-  @Test
-  public void badKillPoint() throws Exception {
-    generalTest(1, 1, 1, 2, buildSet("??"), buildSet());
-  }
-
-  // endregion
-
-  // region coordinator DataNode crash tests
-
-  @Test
-  public void coordinatorCrashDuringRemovePeer() throws Exception {
-    generalTest(1, 1, 1, 2, buildSet(), 
buildSet(DataNodeKillPoints.CoordinatorRemovePeer.name()));
-  }
-
-  // endregion
-
-  // region original DataNode crash tests
-
-  @Test
-  public void originalCrashDuringRemovePeer() throws Exception {
-    generalTest(1, 1, 1, 2, buildSet(), 
buildSet(DataNodeKillPoints.OriginalRemovePeer.name()));
+  public void generalTest(
+      final int dataReplicateFactor,
+      final int schemaReplicationFactor,
+      final int configNodeNum,
+      final int dataNodeNum,
+      KeySetView<String, Boolean> killConfigNodeKeywords,
+      KeySetView<String, Boolean> killDataNodeKeywords)
+      throws Exception {
+    generalTestWithAllOptions(
+        dataReplicateFactor,
+        schemaReplicationFactor,
+        configNodeNum,
+        dataNodeNum,
+        killConfigNodeKeywords,
+        killDataNodeKeywords,
+        true,
+        true,
+        0,
+        true);
   }
 
-  @Test
-  public void originalCrashDuringDeleteLocalPeer() throws Exception {
-    generalTest(
-        1, 1, 1, 2, buildSet(), 
buildSet(DataNodeKillPoints.OriginalDeleteOldRegionPeer.name()));
+  public void failTest(
+      final int dataReplicateFactor,
+      final int schemaReplicationFactor,
+      final int configNodeNum,
+      final int dataNodeNum,
+      KeySetView<String, Boolean> killConfigNodeKeywords,
+      KeySetView<String, Boolean> killDataNodeKeywords)
+      throws Exception {
+    generalTestWithAllOptions(
+        dataReplicateFactor,
+        schemaReplicationFactor,
+        configNodeNum,
+        dataNodeNum,
+        killConfigNodeKeywords,
+        killDataNodeKeywords,
+        true,
+        true,
+        30,
+        false);
   }
 
-  // region Helpers
-
-  public void generalTest(
+  public void generalTestWithAllOptions(
       final int dataReplicateFactor,
       final int schemaReplicationFactor,
       final int configNodeNum,
       final int dataNodeNum,
       KeySetView<String, Boolean> killConfigNodeKeywords,
-      KeySetView<String, Boolean> killDataNodeKeywords)
+      KeySetView<String, Boolean> killDataNodeKeywords,
+      final boolean checkOriginalRegionDirDeleted,
+      final boolean checkConfigurationFileDeleted,
+      final int restartTime,
+      final boolean isMigrateSuccess)
       throws Exception {
     // prepare env
     EnvFactory.getEnv()
         .getConfig()
         .getCommonConfig()
         .setDataReplicationFactor(dataReplicateFactor)
         .setSchemaReplicationFactor(schemaReplicationFactor);
+    EnvFactory.getEnv().registerConfigNodeKillPoints(new 
ArrayList<>(killConfigNodeKeywords));
+    EnvFactory.getEnv().registerDataNodeKillPoints(new 
ArrayList<>(killDataNodeKeywords));
     EnvFactory.getEnv().initClusterEnvironment(configNodeNum, dataNodeNum);
 
-    ExecutorService service = 
IoTDBThreadPoolFactory.newCachedThreadPool("regionMigrateIT");
-    EnvFactory.getEnv()
-        .getConfigNodeWrapperList()
-        .forEach(
-            configNodeWrapper ->
-                service.submit(() -> nodeLogKillPoint(configNodeWrapper, 
killConfigNodeKeywords)));
-    EnvFactory.getEnv()
-        .getDataNodeWrapperList()
-        .forEach(
-            dataNodeWrapper ->
-                service.submit(() -> nodeLogKillPoint(dataNodeWrapper, 
killDataNodeKeywords)));
-
     try (final Connection connection = EnvFactory.getEnv().getConnection();
-        final Statement statement = connection.createStatement();
-        final SyncConfigNodeIServiceClient configClient =
-            (SyncConfigNodeIServiceClient) 
EnvFactory.getEnv().getLeaderConfigNodeConnection()) {
+        final Statement statement = connection.createStatement()) {
 
       statement.execute(INSERTION);
 
       ResultSet result = statement.executeQuery(SHOW_REGIONS);
       Map<Integer, Set<Integer>> regionMap = getRegionMap(result);
 
       result = statement.executeQuery(SHOW_DATANODES);
-      Set<Integer> dataNodeSet = new HashSet<>();
+      Set<Integer> allDataNode = new HashSet<>();
       while (result.next()) {
-        dataNodeSet.add(result.getInt(ColumnHeaderConstant.NODE_ID));
+        allDataNode.add(result.getInt(ColumnHeaderConstant.NODE_ID));
       }
 
       final int selectedRegion = selectRegion(regionMap);
       final int originalDataNode = selectOriginalDataNode(regionMap, 
selectedRegion);
-      final int destDataNode = selectDestDataNode(dataNodeSet, regionMap, 
selectedRegion);
+      final int destDataNode = selectDestDataNode(allDataNode, regionMap, 
selectedRegion);
+
+      checkRegionFileExist(originalDataNode);
+      checkPeersExist(regionMap.get(selectedRegion), originalDataNode, 
selectedRegion);
 
+      // set kill points
+      setConfigNodeKillPoints(killConfigNodeKeywords, restartTime);
+      setDataNodeKillPoints(killDataNodeKeywords, restartTime);
+
+      // region migration start
       statement.execute(regionMigrateCommand(selectedRegion, originalDataNode, 
destDataNode));
 
-      awaitUntilSuccess(statement, selectedRegion, originalDataNode, 
destDataNode);
+      boolean success = false;
+      try {
+        awaitUntilSuccess(statement, selectedRegion, originalDataNode, 
destDataNode);
+        success = true;
+      } catch (ConditionTimeoutException e) {
+        LOGGER.error("Region migrate failed", e);
+      }
+      Assert.assertTrue(isMigrateSuccess == success);

Review Comment:
   Does this line mean 'If the expected region migration is not successful, 
then the test can stop running here' ?



##########
integration-test/src/test/java/org/apache/iotdb/confignode/it/regionmigration/IoTDBRegionMigrateReliabilityTestFramework.java:
##########
@@ -90,195 +88,182 @@ public void tearDown() throws InterruptedException {
     EnvFactory.getEnv().cleanClusterEnvironment();
   }
 
-  // region Normal tests
-
-  @Test
-  public void normal1C2DTest() throws Exception {
-    generalTest(1, 1, 1, 2, buildSet(), buildSet());
-  }
-
-  @Test
-  public void normal3C3DTest() throws Exception {
-    generalTest(2, 3, 3, 3, buildSet(), buildSet());
-  }
-
-  // endregion
-
-  // region ConfigNode crash tests
-  @Test
-  public void cnCrashDuringPreCheck() throws Exception {
-    generalTest(
-        1, 1, 1, 2, 
buildSet(RegionTransitionState.REGION_MIGRATE_PREPARE.toString()), buildSet());
-  }
-
-  @Test
-  public void cnCrashDuringCreatePeer() throws Exception {
-    generalTest(
-        1, 1, 1, 2, 
buildSet(AddRegionPeerState.CREATE_NEW_REGION_PEER.toString()), buildSet());
-  }
-
-  @Test
-  public void cnCrashDuringDoAddPeer() throws Exception {
-    generalTest(1, 1, 1, 2, 
buildSet(AddRegionPeerState.DO_ADD_REGION_PEER.toString()), buildSet());
-  }
-
-  @Test
-  public void cnCrashDuringUpdateCache() throws Exception {
-    generalTest(
-        1,
-        1,
-        1,
-        2,
-        buildSet(AddRegionPeerState.UPDATE_REGION_LOCATION_CACHE.toString()),
-        buildSet());
-  }
-
-  @Test
-  public void cnCrashDuringChangeRegionLeader() throws Exception {
-    generalTest(
-        1, 1, 1, 2, 
buildSet(RegionTransitionState.CHANGE_REGION_LEADER.toString()), buildSet());
-  }
-
-  @Test
-  public void cnCrashDuringRemoveRegionPeer() throws Exception {
-    generalTest(
-        1, 1, 1, 2, 
buildSet(RemoveRegionPeerState.REMOVE_REGION_PEER.toString()), buildSet());
-  }
-
-  @Test
-  public void cnCrashDuringDeleteOldRegionPeer() throws Exception {
-    generalTest(
-        1, 1, 1, 2, 
buildSet(RemoveRegionPeerState.DELETE_OLD_REGION_PEER.toString()), buildSet());
-  }
-
-  @Test
-  public void cnCrashDuringRemoveRegionLocationCache() throws Exception {
-    generalTest(
-        1,
-        1,
-        1,
-        2,
-        
buildSet(RemoveRegionPeerState.REMOVE_REGION_LOCATION_CACHE.toString()),
-        buildSet());
-  }
-
-  @Test
-  public void cnCrashTest() throws Exception {
-    KeySetView<String, Boolean> killConfigNodeKeywords = buildSet();
-    killConfigNodeKeywords.addAll(
-        Arrays.stream(AddRegionPeerState.values())
-            .map(Enum::toString)
-            .collect(Collectors.toList()));
-    killConfigNodeKeywords.addAll(
-        Arrays.stream(RemoveRegionPeerState.values())
-            .map(Enum::toString)
-            .collect(Collectors.toList()));
-    generalTest(1, 1, 1, 2, killConfigNodeKeywords, buildSet());
-  }
-
-  @Ignore
-  @Test
-  public void badKillPoint() throws Exception {
-    generalTest(1, 1, 1, 2, buildSet("??"), buildSet());
-  }
-
-  // endregion
-
-  // region coordinator DataNode crash tests
-
-  @Test
-  public void coordinatorCrashDuringRemovePeer() throws Exception {
-    generalTest(1, 1, 1, 2, buildSet(), 
buildSet(DataNodeKillPoints.CoordinatorRemovePeer.name()));
-  }
-
-  // endregion
-
-  // region original DataNode crash tests
-
-  @Test
-  public void originalCrashDuringRemovePeer() throws Exception {
-    generalTest(1, 1, 1, 2, buildSet(), 
buildSet(DataNodeKillPoints.OriginalRemovePeer.name()));
+  public void generalTest(
+      final int dataReplicateFactor,
+      final int schemaReplicationFactor,
+      final int configNodeNum,
+      final int dataNodeNum,
+      KeySetView<String, Boolean> killConfigNodeKeywords,
+      KeySetView<String, Boolean> killDataNodeKeywords)
+      throws Exception {
+    generalTestWithAllOptions(
+        dataReplicateFactor,
+        schemaReplicationFactor,
+        configNodeNum,
+        dataNodeNum,
+        killConfigNodeKeywords,
+        killDataNodeKeywords,
+        true,
+        true,
+        0,
+        true);
   }
 
-  @Test
-  public void originalCrashDuringDeleteLocalPeer() throws Exception {
-    generalTest(
-        1, 1, 1, 2, buildSet(), 
buildSet(DataNodeKillPoints.OriginalDeleteOldRegionPeer.name()));
+  public void failTest(
+      final int dataReplicateFactor,
+      final int schemaReplicationFactor,
+      final int configNodeNum,
+      final int dataNodeNum,
+      KeySetView<String, Boolean> killConfigNodeKeywords,
+      KeySetView<String, Boolean> killDataNodeKeywords)
+      throws Exception {
+    generalTestWithAllOptions(
+        dataReplicateFactor,
+        schemaReplicationFactor,
+        configNodeNum,
+        dataNodeNum,
+        killConfigNodeKeywords,
+        killDataNodeKeywords,
+        true,
+        true,
+        30,
+        false);
   }
 
-  // region Helpers
-
-  public void generalTest(
+  public void generalTestWithAllOptions(
       final int dataReplicateFactor,
       final int schemaReplicationFactor,
       final int configNodeNum,
       final int dataNodeNum,
       KeySetView<String, Boolean> killConfigNodeKeywords,
-      KeySetView<String, Boolean> killDataNodeKeywords)
+      KeySetView<String, Boolean> killDataNodeKeywords,
+      final boolean checkOriginalRegionDirDeleted,
+      final boolean checkConfigurationFileDeleted,
+      final int restartTime,
+      final boolean isMigrateSuccess)
       throws Exception {
     // prepare env
     EnvFactory.getEnv()
         .getConfig()
         .getCommonConfig()
         .setDataReplicationFactor(dataReplicateFactor)
         .setSchemaReplicationFactor(schemaReplicationFactor);
+    EnvFactory.getEnv().registerConfigNodeKillPoints(new 
ArrayList<>(killConfigNodeKeywords));
+    EnvFactory.getEnv().registerDataNodeKillPoints(new 
ArrayList<>(killDataNodeKeywords));
     EnvFactory.getEnv().initClusterEnvironment(configNodeNum, dataNodeNum);
 
-    ExecutorService service = 
IoTDBThreadPoolFactory.newCachedThreadPool("regionMigrateIT");
-    EnvFactory.getEnv()
-        .getConfigNodeWrapperList()
-        .forEach(
-            configNodeWrapper ->
-                service.submit(() -> nodeLogKillPoint(configNodeWrapper, 
killConfigNodeKeywords)));
-    EnvFactory.getEnv()
-        .getDataNodeWrapperList()
-        .forEach(
-            dataNodeWrapper ->
-                service.submit(() -> nodeLogKillPoint(dataNodeWrapper, 
killDataNodeKeywords)));
-
     try (final Connection connection = EnvFactory.getEnv().getConnection();
-        final Statement statement = connection.createStatement();
-        final SyncConfigNodeIServiceClient configClient =
-            (SyncConfigNodeIServiceClient) 
EnvFactory.getEnv().getLeaderConfigNodeConnection()) {
+        final Statement statement = connection.createStatement()) {
 
       statement.execute(INSERTION);
 
       ResultSet result = statement.executeQuery(SHOW_REGIONS);
       Map<Integer, Set<Integer>> regionMap = getRegionMap(result);
 
       result = statement.executeQuery(SHOW_DATANODES);
-      Set<Integer> dataNodeSet = new HashSet<>();
+      Set<Integer> allDataNode = new HashSet<>();
       while (result.next()) {
-        dataNodeSet.add(result.getInt(ColumnHeaderConstant.NODE_ID));
+        allDataNode.add(result.getInt(ColumnHeaderConstant.NODE_ID));
       }
 
       final int selectedRegion = selectRegion(regionMap);
       final int originalDataNode = selectOriginalDataNode(regionMap, 
selectedRegion);
-      final int destDataNode = selectDestDataNode(dataNodeSet, regionMap, 
selectedRegion);
+      final int destDataNode = selectDestDataNode(allDataNode, regionMap, 
selectedRegion);
+
+      checkRegionFileExist(originalDataNode);
+      checkPeersExist(regionMap.get(selectedRegion), originalDataNode, 
selectedRegion);
 
+      // set kill points
+      setConfigNodeKillPoints(killConfigNodeKeywords, restartTime);
+      setDataNodeKillPoints(killDataNodeKeywords, restartTime);
+
+      // region migration start
       statement.execute(regionMigrateCommand(selectedRegion, originalDataNode, 
destDataNode));
 
-      awaitUntilSuccess(statement, selectedRegion, originalDataNode, 
destDataNode);
+      boolean success = false;
+      try {
+        awaitUntilSuccess(statement, selectedRegion, originalDataNode, 
destDataNode);
+        success = true;
+      } catch (ConditionTimeoutException e) {
+        LOGGER.error("Region migrate failed", e);
+      }
+      Assert.assertTrue(isMigrateSuccess == success);
 
       // make sure all kill points have been triggered
-      Assert.assertTrue(killConfigNodeKeywords.isEmpty());
-      Assert.assertTrue(killDataNodeKeywords.isEmpty());
+      checkKillPointsAllTriggered(killConfigNodeKeywords);
+      checkKillPointsAllTriggered(killDataNodeKeywords);
+
+      if (!isMigrateSuccess) {
+        restartAllDataNodes();
+      }
+
+      // check if there is anything remain
+      if (checkOriginalRegionDirDeleted) {
+        if (isMigrateSuccess) {
+          checkRegionFileClear(originalDataNode);
+          checkRegionFileExist(destDataNode);
+        } else {
+          checkRegionFileClear(destDataNode);
+          checkRegionFileExist(originalDataNode);
+        }
+      }
+      if (checkConfigurationFileDeleted) {
+        if (isMigrateSuccess) {
+          checkPeersClear(allDataNode, originalDataNode, selectedRegion);
+        } else {
+          checkPeersClear(allDataNode, destDataNode, selectedRegion);
+        }
+      }
 
-      checkRegionFileClear(originalDataNode);
     } catch (InconsistentDataException ignore) {

Review Comment:
   Who will throw this ?



##########
iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/iot/IoTConsensusServerImpl.java:
##########
@@ -643,28 +650,18 @@ public void recoverConfiguration() {
 
   // @Compatibility
   private void recoverFromOldConfigurationFile(Path oldConfigurationPath) 
throws IOException {
+    // recover from old configuration file
     ByteBuffer buffer = 
ByteBuffer.wrap(Files.readAllBytes(oldConfigurationPath));
     int size = buffer.getInt();
     for (int i = 0; i < size; i++) {
       configuration.add(Peer.deserialize(buffer));
     }
-    persistConfiguration();
+    // TODO: delete old file before new file persisted is unsafe
     Files.delete(oldConfigurationPath);
   }

Review Comment:
   Seems unsafe if delete old file before store new file ?



##########
iotdb-core/datanode/src/test/resources/datanode2conf/iotdb-datanode.properties:
##########
@@ -21,10 +21,10 @@ dn_rpc_address=127.0.0.1
 dn_internal_address=127.0.0.1
 
 dn_rpc_port=6668
-dn_internal_port=10731
-dn_mpp_data_exchange_port=10741
-dn_schema_region_consensus_port=10751
-dn_data_region_consensus_port=10761
+dn_internal_port=10831
+dn_mpp_data_exchange_port=10841
+dn_schema_region_consensus_port=10851
+dn_data_region_consensus_port=10861

Review Comment:
   revert ?



##########
iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/iot/IoTConsensusServerImpl.java:
##########
@@ -593,7 +593,20 @@ public void removeSyncLogChannel(Peer targetPeer) throws 
ConsensusGroupModifyPee
 
   public void persistConfiguration() {
     try {
-      serializeConfigurationAndFsyncToDisk(CONFIGURATION_FILE_NAME);
+      try (Stream<Path> stream = Files.walk(Paths.get(storageDir))) {
+        stream
+            .filter(Files::isRegularFile)
+            .filter(filePath -> 
filePath.getFileName().toString().contains("configuration"))
+            .forEach(
+                filePath -> {
+                  try {
+                    Files.delete(filePath);
+                  } catch (IOException e) {
+                    logger.error("Unexpected error occurs when deleting old 
configuration file", e);
+                  }
+                });
+      }
+      serializeConfigurationAndFsyncToDisk();

Review Comment:
   Seems unsafe if delete old file before store new file ?



##########
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/sync/SyncDataNodeClientPool.java:
##########
@@ -52,7 +52,7 @@ public class SyncDataNodeClientPool {
 
   private static final Logger LOGGER = 
LoggerFactory.getLogger(SyncDataNodeClientPool.class);
 
-  private static final int DEFAULT_RETRY_NUM = 6;
+  private static final int DEFAULT_RETRY_NUM = 1;

Review Comment:
   revert ?



##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/service/DataNode.java:
##########
@@ -450,6 +457,34 @@ private void sendRegisterRequestToConfigNode() throws 
StartupException, IOExcept
     }
   }
 
+  private List<ConsensusGroupId> getConsensusGroupId() {
+    List<ConsensusGroupId> consensusGroupIds = new ArrayList<>();
+    String dataRegionConsensusDir = config.getDataRegionConsensusDir();
+    try (DirectoryStream<Path> stream =
+        Files.newDirectoryStream(new File(dataRegionConsensusDir).toPath())) {
+      for (Path path : stream) {
+        String[] items = path.getFileName().toString().split("_");
+        ConsensusGroupId consensusGroupId =
+            ConsensusGroupId.Factory.create(Integer.parseInt(items[0]), 
Integer.parseInt(items[1]));
+        consensusGroupIds.add(consensusGroupId);
+      }
+    } catch (IOException e) {
+      logger.error("Cannot get consensus group id from {}", 
dataRegionConsensusDir, e);
+    }
+    return consensusGroupIds;
+  }
+
+  private void clearInvalidConsensusGroup(List<ConsensusGroupId> 
configNodeConsensusGroupIds) {
+    List<ConsensusGroupId> dataNodeConsensusGroupIds = getConsensusGroupId();
+    String dataRegionConsensusDir = config.getDataRegionConsensusDir();
+    for (ConsensusGroupId consensusGroupId : dataNodeConsensusGroupIds) {
+      if (!configNodeConsensusGroupIds.contains(consensusGroupId)) {
+        String path = IoTConsensus.buildPeerDir(new 
File(dataRegionConsensusDir), consensusGroupId);
+        FileUtils.deleteDirectory(new File(path));

Review Comment:
   Maybe rename dir, or move dir to somewhere else ?



-- 
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]

Reply via email to