This is an automated email from the ASF dual-hosted git repository.
tanxinyu pushed a commit to branch rc/1.3.3
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/rc/1.3.3 by this push:
new 029bee7bf3d [To rc/1.3.3][Region Migration]: Clear Invalid schema
region when restarting (#13185)
029bee7bf3d is described below
commit 029bee7bf3dabae621e0e1c594b6edd15efbc802
Author: 133tosakarin <[email protected]>
AuthorDate: Thu Aug 15 17:30:49 2024 +0800
[To rc/1.3.3][Region Migration]: Clear Invalid schema region when
restarting (#13185)
* merge
* split removeRegion function
---
.../java/org/apache/iotdb/db/service/DataNode.java | 59 +++++++++++++++-------
1 file changed, 41 insertions(+), 18 deletions(-)
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/service/DataNode.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/service/DataNode.java
index 0672f8d3d25..d1ea85fe4c7 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/service/DataNode.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/service/DataNode.java
@@ -461,28 +461,51 @@ public class DataNode implements DataNodeMBean {
}
private void removeInvalidRegions(List<ConsensusGroupId>
dataNodeConsensusGroupIds) {
- List<ConsensusGroupId> invalidConsensusGroupIds =
+ List<ConsensusGroupId> invalidDataRegionConsensusGroupIds =
DataRegionConsensusImpl.getInstance().getAllConsensusGroupIdsWithoutStarting().stream()
.filter(consensusGroupId ->
!dataNodeConsensusGroupIds.contains(consensusGroupId))
.collect(Collectors.toList());
- if (!invalidConsensusGroupIds.isEmpty()) {
- logger.info("Remove invalid region directories... {}",
invalidConsensusGroupIds);
- for (ConsensusGroupId consensusGroupId : invalidConsensusGroupIds) {
- File oldDir =
- new File(
- DataRegionConsensusImpl.getInstance()
- .getRegionDirFromConsensusGroupId(consensusGroupId));
- if (oldDir.exists()) {
- try {
- FileUtils.recursivelyDeleteFolder(oldDir.getPath());
- logger.info("delete {} succeed.", oldDir.getAbsolutePath());
- } catch (IOException e) {
- logger.error("delete {} failed.", oldDir.getAbsolutePath());
- }
- } else {
- logger.info("delete {} failed, because it does not exist.",
oldDir.getAbsolutePath());
- }
+
+ List<ConsensusGroupId> invalidSchemaRegionConsensusGroupIds =
+
SchemaRegionConsensusImpl.getInstance().getAllConsensusGroupIdsWithoutStarting().stream()
+ .filter(consensusGroupId ->
!dataNodeConsensusGroupIds.contains(consensusGroupId))
+ .collect(Collectors.toList());
+ removeInvalidDataRegions(invalidDataRegionConsensusGroupIds);
+ removeInvalidSchemaRegions(invalidSchemaRegionConsensusGroupIds);
+ }
+
+ private void removeInvalidDataRegions(List<ConsensusGroupId>
invalidConsensusGroupId) {
+ logger.info("Remove invalid dataRegion directories... {}",
invalidConsensusGroupId);
+ for (ConsensusGroupId consensusGroupId : invalidConsensusGroupId) {
+ File oldDir =
+ new File(
+ DataRegionConsensusImpl.getInstance()
+ .getRegionDirFromConsensusGroupId(consensusGroupId));
+ removeRegionsDir(oldDir);
+ }
+ }
+
+ private void removeInvalidSchemaRegions(List<ConsensusGroupId>
invalidConsensusGroupId) {
+ logger.info("Remove invalid schemaRegion directories... {}",
invalidConsensusGroupId);
+ for (ConsensusGroupId consensusGroupId : invalidConsensusGroupId) {
+ File oldDir =
+ new File(
+ SchemaRegionConsensusImpl.getInstance()
+ .getRegionDirFromConsensusGroupId(consensusGroupId));
+ removeRegionsDir(oldDir);
+ }
+ }
+
+ private void removeRegionsDir(File regionDir) {
+ if (regionDir.exists()) {
+ try {
+ FileUtils.recursivelyDeleteFolder(regionDir.getPath());
+ logger.info("delete {} succeed.", regionDir.getAbsolutePath());
+ } catch (IOException e) {
+ logger.error("delete {} failed.", regionDir.getAbsolutePath());
}
+ } else {
+ logger.info("delete {} failed, because it does not exist.",
regionDir.getAbsolutePath());
}
}