This is an automated email from the ASF dual-hosted git repository.

zyk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/master by this push:
     new 81c363e8dc [IOTDB-3260] Fix npe while concurrent delete storage group 
(#6428)
81c363e8dc is described below

commit 81c363e8dcc1ff0cfbde250f470015218214b0f7
Author: Marcos_Zyk <[email protected]>
AuthorDate: Mon Jun 27 15:53:07 2022 +0800

    [IOTDB-3260] Fix npe while concurrent delete storage group (#6428)
    
    [IOTDB-3260] Fix npe while concurrent delete storage group (#6428)
---
 .../persistence/partition/PartitionInfo.java       | 24 +++++++++++++++++-----
 1 file changed, 19 insertions(+), 5 deletions(-)

diff --git 
a/confignode/src/main/java/org/apache/iotdb/confignode/persistence/partition/PartitionInfo.java
 
b/confignode/src/main/java/org/apache/iotdb/confignode/persistence/partition/PartitionInfo.java
index 8716f5fe00..594778a534 100644
--- 
a/confignode/src/main/java/org/apache/iotdb/confignode/persistence/partition/PartitionInfo.java
+++ 
b/confignode/src/main/java/org/apache/iotdb/confignode/persistence/partition/PartitionInfo.java
@@ -209,12 +209,17 @@ public class PartitionInfo implements SnapshotProcessor {
     final PreDeleteStorageGroupReq.PreDeleteType preDeleteType =
         preDeleteStorageGroupReq.getPreDeleteType();
     final String storageGroup = preDeleteStorageGroupReq.getStorageGroup();
+    StorageGroupPartitionTable storageGroupPartitionTable =
+        storageGroupPartitionTables.get(storageGroup);
+    if (storageGroupPartitionTable == null) {
+      return new TSStatus(TSStatusCode.SUCCESS_STATUS.getStatusCode());
+    }
     switch (preDeleteType) {
       case EXECUTE:
-        storageGroupPartitionTables.get(storageGroup).setPredeleted(true);
+        storageGroupPartitionTable.setPredeleted(true);
         break;
       case ROLLBACK:
-        storageGroupPartitionTables.get(storageGroup).setPredeleted(false);
+        storageGroupPartitionTable.setPredeleted(false);
         break;
     }
     return new TSStatus(TSStatusCode.SUCCESS_STATUS.getStatusCode());
@@ -226,12 +231,21 @@ public class PartitionInfo implements SnapshotProcessor {
    * @param req DeleteRegionsReq
    */
   public void deleteStorageGroup(DeleteStorageGroupReq req) {
+    StorageGroupPartitionTable storageGroupPartitionTable =
+        storageGroupPartitionTables.get(req.getName());
+    if (storageGroupPartitionTable == null) {
+      return;
+    }
     // Cache RegionReplicaSets
     synchronized (deletedRegionSet) {
-      
deletedRegionSet.addAll(storageGroupPartitionTables.get(req.getName()).getAllReplicaSets());
+      storageGroupPartitionTable = 
storageGroupPartitionTables.get(req.getName());
+      if (storageGroupPartitionTable == null) {
+        return;
+      }
+      deletedRegionSet.addAll(storageGroupPartitionTable.getAllReplicaSets());
+      // Clean the cache
+      storageGroupPartitionTables.remove(req.getName());
     }
-    // Clean the cache
-    storageGroupPartitionTables.remove(req.getName());
   }
 
   /** @return The Regions that should be deleted among the DataNodes */

Reply via email to