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 2020/06/02 13:03:46 UTC
[incubator-iotdb] branch master updated: [IOTDB-735] Fix Concurrent
error for MNode when creating time series automatically (#1306)
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/incubator-iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new 6378243 [IOTDB-735] Fix Concurrent error for MNode when creating time series automatically (#1306)
6378243 is described below
commit 63782430c210296110a5d4f173554ba1d2dc3176
Author: Jialin Qiao <qj...@mails.tsinghua.edu.cn>
AuthorDate: Tue Jun 2 21:03:35 2020 +0800
[IOTDB-735] Fix Concurrent error for MNode when creating time series automatically (#1306)
---
.../src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java | 4 +++-
.../iotdb/db/engine/storagegroup/StorageGroupProcessor.java | 13 ++++++-------
.../main/java/org/apache/iotdb/db/metadata/MManager.java | 13 +++++++++++++
.../java/org/apache/iotdb/db/qp/executor/PlanExecutor.java | 5 +++--
4 files changed, 25 insertions(+), 10 deletions(-)
diff --git a/server/src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java b/server/src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java
index 93b3f41..48b5901 100644
--- a/server/src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java
+++ b/server/src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java
@@ -131,7 +131,9 @@ public class IoTDBConfig {
/**
* Is dynamic parameter adapter enable.
*/
- private boolean enableParameterAdapter = true;
+ //the default value of this parameter should be kept true in iotdb-engine.properties,
+ //we set it as false here for convenient testing.
+ private boolean enableParameterAdapter = false;
/**
* Is the write ahead log enable.
diff --git a/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/StorageGroupProcessor.java b/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/StorageGroupProcessor.java
index 32f5dfe..6d8a3fe 100755
--- a/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/StorageGroupProcessor.java
+++ b/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/StorageGroupProcessor.java
@@ -763,12 +763,12 @@ public class StorageGroupProcessor {
throws WriteProcessException {
MNode node = null;
try {
- node = MManager.getInstance().getDeviceNodeWithAutoCreateAndReadLock(plan.getDeviceId());
+ MManager manager = MManager.getInstance();
+ node = manager.getDeviceNodeWithAutoCreateAndReadLock(plan.getDeviceId());
String[] measurementList = plan.getMeasurements();
for (int i = 0; i < measurementList.length; i++) {
// Update cached last value with high priority
- MNode measurementNode = node.getChild(measurementList[i]);
- ((LeafMNode) measurementNode)
+ ((LeafMNode) manager.getChild(node, measurementList[i], plan.getDeviceId()))
.updateCachedLast(plan.composeLastTimeValuePair(i), true, latestFlushedTime);
}
} catch (MetadataException e) {
@@ -815,16 +815,15 @@ public class StorageGroupProcessor {
throws WriteProcessException {
MNode node = null;
try {
- node = MManager.getInstance().getDeviceNodeWithAutoCreateAndReadLock(plan.getDeviceId());
+ MManager manager = MManager.getInstance();
+ node = manager.getDeviceNodeWithAutoCreateAndReadLock(plan.getDeviceId());
String[] measurementList = plan.getMeasurements();
for (int i = 0; i < measurementList.length; i++) {
if (plan.getSchemas()[i] == null) {
continue;
}
// Update cached last value with high priority
- MNode measurementNode = node.getChild(measurementList[i]);
-
- ((LeafMNode) measurementNode)
+ ((LeafMNode) manager.getChild(node, measurementList[i], plan.getDeviceId()))
.updateCachedLast(plan.composeTimeValuePair(i), true, latestFlushedTime);
}
} catch (MetadataException e) {
diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/MManager.java b/server/src/main/java/org/apache/iotdb/db/metadata/MManager.java
index 62a329f..e7ae081 100644
--- a/server/src/main/java/org/apache/iotdb/db/metadata/MManager.java
+++ b/server/src/main/java/org/apache/iotdb/db/metadata/MManager.java
@@ -863,6 +863,19 @@ public class MManager {
}
}
+ public MNode getChild(MNode parent, String child, String info) {
+ MNode childNode = parent.getChild(child);
+ int tempCount = 0;
+ while (childNode == null) {
+ tempCount ++;
+ if (tempCount % 10000 == 0) {
+ logger.warn("try to get child {} 10000 times from {}", child, info);
+ }
+ childNode = parent.getChild(child);
+ }
+ return childNode;
+ }
+
/**
* Get storage group node by path. If storage group is not set, StorageGroupNotSetException will
* be thrown
diff --git a/server/src/main/java/org/apache/iotdb/db/qp/executor/PlanExecutor.java b/server/src/main/java/org/apache/iotdb/db/qp/executor/PlanExecutor.java
index f3be36d..dde4957 100644
--- a/server/src/main/java/org/apache/iotdb/db/qp/executor/PlanExecutor.java
+++ b/server/src/main/java/org/apache/iotdb/db/qp/executor/PlanExecutor.java
@@ -886,7 +886,8 @@ public class PlanExecutor implements IPlanExecutor {
Path path = new Path(deviceId, measurement);
internalCreateTimeseries(path.toString(), dataType);
}
- LeafMNode measurementNode = (LeafMNode) node.getChild(measurement);
+ LeafMNode measurementNode = (LeafMNode) MManager.getInstance().getChild(node, measurement, deviceId);
+
schemas[i] = measurementNode.getSchema();
// reset measurement to common name instead of alias
measurementList[i] = measurementNode.getName();
@@ -1032,7 +1033,7 @@ public class PlanExecutor implements IPlanExecutor {
TSDataType dataType = dataTypes[i];
internalCreateTimeseries(path.getFullPath(), dataType);
}
- LeafMNode measurementNode = (LeafMNode) node.getChild(measurementList[i]);
+ LeafMNode measurementNode = (LeafMNode) MManager.getInstance().getChild(node, measurementList[i], deviceId);
// check data type
if (measurementNode.getSchema().getType() != insertTabletPlan.getDataTypes()[i]) {