This is an automated email from the ASF dual-hosted git repository. haonan pushed a commit to branch jira3500 in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit 434dcb9a7ba35a67b5e9118f2708eca8e85db2a5 Author: HTHou <[email protected]> AuthorDate: Thu Jun 16 11:23:30 2022 +0800 [IOTDB-3500] Fix delete storage group failure in new standable IoTDB --- .../apache/iotdb/db/localconfignode/LocalDataPartitionTable.java | 8 ++++++-- .../org/apache/iotdb/db/metadata/schemaregion/SchemaEngine.java | 4 +++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/server/src/main/java/org/apache/iotdb/db/localconfignode/LocalDataPartitionTable.java b/server/src/main/java/org/apache/iotdb/db/localconfignode/LocalDataPartitionTable.java index 0d32dc5114..52662e3f9d 100644 --- a/server/src/main/java/org/apache/iotdb/db/localconfignode/LocalDataPartitionTable.java +++ b/server/src/main/java/org/apache/iotdb/db/localconfignode/LocalDataPartitionTable.java @@ -24,6 +24,7 @@ import org.apache.iotdb.commons.exception.IllegalPathException; import org.apache.iotdb.commons.path.PartialPath; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; @@ -104,7 +105,7 @@ public class LocalDataPartitionTable { } public List<DataRegionId> getDataRegionIdsByStorageGroup(PartialPath storageGroup) { - return new ArrayList<>(table.get(storageGroup)); + return table.getOrDefault(storageGroup, Collections.emptyList()); } public synchronized void setDataPartitionInfo(PartialPath storageGroup) { @@ -119,7 +120,10 @@ public class LocalDataPartitionTable { } public synchronized List<DataRegionId> deleteStorageGroup(PartialPath storageGroup) { - return table.remove(storageGroup); + if (table.containsKey(storageGroup)) { + return table.remove(storageGroup); + } + return Collections.emptyList(); } // This method may be extended to implement multi dataRegion for one storageGroup diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/schemaregion/SchemaEngine.java b/server/src/main/java/org/apache/iotdb/db/metadata/schemaregion/SchemaEngine.java index 3b850584b8..77f9d8a791 100644 --- a/server/src/main/java/org/apache/iotdb/db/metadata/schemaregion/SchemaEngine.java +++ b/server/src/main/java/org/apache/iotdb/db/metadata/schemaregion/SchemaEngine.java @@ -347,7 +347,9 @@ public class SchemaEngine { }); // remove the empty sg dir if (regionDirList == null || regionDirList.length == 0) { - FileUtils.deleteDirectory(sgDir); + if (sgDir.exists()) { + FileUtils.deleteDirectory(sgDir); + } sharedPrefixTree.deleteStorageGroup(new PartialPath(schemaRegion.getStorageGroupFullPath())); } }
