You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by qi...@apache.org on 2022/06/01 15:24:40 UTC
[iotdb] branch master updated: [IOTDB-3327] Fix data region is created twice (#6136)
This is an automated email from the ASF dual-hosted git repository.
qiaojialin 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 eff66ef3a3 [IOTDB-3327] Fix data region is created twice (#6136)
eff66ef3a3 is described below
commit eff66ef3a3739da432af15933bc3cdea212ef49d
Author: Liu Xuxin <37...@users.noreply.github.com>
AuthorDate: Wed Jun 1 23:24:34 2022 +0800
[IOTDB-3327] Fix data region is created twice (#6136)
---
.../org/apache/iotdb/db/engine/StorageEngineV2.java | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/server/src/main/java/org/apache/iotdb/db/engine/StorageEngineV2.java b/server/src/main/java/org/apache/iotdb/db/engine/StorageEngineV2.java
index a3fc388024..7f7aa5ee80 100644
--- a/server/src/main/java/org/apache/iotdb/db/engine/StorageEngineV2.java
+++ b/server/src/main/java/org/apache/iotdb/db/engine/StorageEngineV2.java
@@ -79,6 +79,7 @@ import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicReference;
public class StorageEngineV2 implements IService {
private static final Logger logger = LoggerFactory.getLogger(StorageEngineV2.class);
@@ -587,8 +588,21 @@ public class StorageEngineV2 implements IService {
// the local engine before adding the corresponding consensusGroup to the consensus layer
public DataRegion createDataRegion(DataRegionId regionId, String sg, long ttl)
throws DataRegionException {
- DataRegion dataRegion = buildNewDataRegion(sg, String.valueOf(regionId.getId()), ttl);
- dataRegionMap.put(regionId, dataRegion);
+ AtomicReference<DataRegionException> exceptionAtomicReference = new AtomicReference<>(null);
+ DataRegion dataRegion =
+ dataRegionMap.computeIfAbsent(
+ regionId,
+ x -> {
+ try {
+ return buildNewDataRegion(sg, String.valueOf(x.getId()), ttl);
+ } catch (DataRegionException e) {
+ exceptionAtomicReference.set(e);
+ }
+ return null;
+ });
+ if (exceptionAtomicReference.get() != null) {
+ throw exceptionAtomicReference.get();
+ }
return dataRegion;
}