Skip to content

Commit

Permalink
[IOTDB-3260] Fix npe while concurrent delete storage group (apache#6428)
Browse files Browse the repository at this point in the history
[IOTDB-3260] Fix npe while concurrent delete storage group (apache#6428)
  • Loading branch information
MarcosZyk authored Jun 27, 2022
1 parent 0eb5010 commit 81c363e
Showing 1 changed file with 19 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -209,12 +209,17 @@ public TSStatus preDeleteStorageGroup(PreDeleteStorageGroupReq preDeleteStorageG
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());
Expand All @@ -226,12 +231,21 @@ public TSStatus preDeleteStorageGroup(PreDeleteStorageGroupReq preDeleteStorageG
* @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 */
Expand Down

0 comments on commit 81c363e

Please sign in to comment.