Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Loading status checks…
[IOTDB-4222] Create data region repeatedly when concurrently deleting…
… and creating storage groups (#7112)
Showing
1 changed file
with
3 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| } | |||
|
|
|||
| @SuppressWarnings("java:S2445") | |||
| // actually storageGroupMNode is a unique object on the mtree, synchronize it is reasonable | |||
| public DataRegion getProcessor(IStorageGroupMNode storageGroupMNode, int dataRegionId) | |||
| throws DataRegionException, StorageEngineException { | |||
| DataRegion processor = dataRegion[dataRegionId]; | |||
| if (processor == null) { | |||
| // if finish recover | |||
| if (isDataRegionReady[dataRegionId].get()) { | |||
| synchronized (storageGroupMNode) { | |||
| // it's unsafe to synchronize MNode here because | |||
| // concurrent deletions and creations will create a new MNode | |||
| synchronized (isDataRegionReady[dataRegionId]) { | |||
| processor = dataRegion[dataRegionId]; | |||
| if (processor == null) { | |||
| processor = | |||
| StorageEngine.getInstance() | |||
| .buildNewStorageGroupProcessor( | |||
| storageGroupMNode.getPartialPath(), | |||
| storageGroupMNode, | |||
| String.valueOf(dataRegionId)); | |||
| dataRegion[dataRegionId] = processor; | |||
|
|||
|
|||
| } | |||
| } | |||
| } else { | |||
| // not finished recover, refuse the request | |||
| throw new StorageGroupNotReadyException( | |||
| storageGroupMNode.getFullPath(), TSStatusCode.STORAGE_GROUP_NOT_READY.getStatusCode()); | |||
| } | |||
| } | |||
| return processor; | |||
|
|||
|
|||
| } | |||
| /** | |||