This is an automated email from the ASF dual-hosted git repository.
qiaojialin pushed a commit to branch add_get_sleep
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git
The following commit(s) were added to refs/heads/add_get_sleep by this push:
new 28e1a74 fix bug
28e1a74 is described below
commit 28e1a747e7143cbc2f57f8e18d72fe815579435d
Author: qiaojialin <[email protected]>
AuthorDate: Wed Jun 3 15:59:47 2020 +0800
fix bug
---
.../engine/storagegroup/StorageGroupProcessor.java | 5 +-
.../org/apache/iotdb/db/metadata/MManager.java | 89 ++++++----------------
.../iotdb/db/metadata/mnode/InternalMNode.java | 5 +-
.../apache/iotdb/db/qp/executor/PlanExecutor.java | 33 ++++----
.../iotdb/db/qp/physical/crud/InsertPlan.java | 8 +-
.../db/qp/physical/crud/InsertTabletPlan.java | 6 +-
6 files changed, 51 insertions(+), 95 deletions(-)
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 facce34..1615ac5 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
@@ -768,8 +768,7 @@ public class StorageGroupProcessor {
String[] measurementList = plan.getMeasurements();
for (int i = 0; i < measurementList.length; i++) {
// Update cached last value with high priority
- ((LeafMNode) manager.getChild(node, measurementList[i],
- plan.getDeviceId() + " in StorageGroupProcessor-771"))
+ ((LeafMNode) node.getChild(measurementList[i]))
.updateCachedLast(plan.composeLastTimeValuePair(i), true,
latestFlushedTime);
}
} catch (MetadataException e) {
@@ -824,7 +823,7 @@ public class StorageGroupProcessor {
continue;
}
// Update cached last value with high priority
- ((LeafMNode) manager.getChild(node, measurementList[i],
plan.getDeviceId()+ " in StorageGroupProcessor-826"))
+ ((LeafMNode) node.getChild(measurementList[i]))
.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 f383f0c..b14d92f 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
@@ -74,7 +74,7 @@ public class MManager {
private TagLogFile tagLogFile;
private boolean writeToLog;
// device -> DeviceMNode
-// private RandomDeleteCache<String, MNode> mNodeCache;
+ private RandomDeleteCache<String, MNode> mNodeCache;
// tag key -> tag value -> LeafMNode
private Map<String, Map<String, Set<LeafMNode>>> tagIndex = new HashMap<>();
@@ -111,21 +111,21 @@ public class MManager {
writeToLog = false;
int cacheSize = config.getmManagerCacheSize();
-// mNodeCache =
-// new RandomDeleteCache<String, MNode>(cacheSize) {
-//
-// @Override
-// public MNode loadObjectByKey(String key) throws CacheException {
-// lock.readLock().lock();
-// try {
-// return mtree.getNodeByPathWithStorageGroupCheck(key);
-// } catch (MetadataException e) {
-// throw new CacheException(e);
-// } finally {
-// lock.readLock().unlock();
-// }
-// }
-// };
+ mNodeCache =
+ new RandomDeleteCache<String, MNode>(cacheSize) {
+
+ @Override
+ public MNode loadObjectByKey(String key) throws CacheException {
+ lock.readLock().lock();
+ try {
+ return mtree.getNodeByPathWithStorageGroupCheck(key);
+ } catch (MetadataException e) {
+ throw new CacheException(e);
+ } finally {
+ lock.readLock().unlock();
+ }
+ }
+ };
}
public static MManager getInstance() {
@@ -189,7 +189,7 @@ public class MManager {
lock.writeLock().lock();
try {
this.mtree = new MTree();
-// this.mNodeCache.clear();
+ this.mNodeCache.clear();
this.tagIndex.clear();
this.seriesNumberInStorageGroups.clear();
this.maxSeriesNumberAmongStorageGroup = 0;
@@ -379,7 +379,7 @@ public class MManager {
}
}
-// mNodeCache.clear();
+ mNodeCache.clear();
}
try {
Set<String> emptyStorageGroups = new HashSet<>();
@@ -445,7 +445,7 @@ public class MManager {
String storageGroupName = pair.left;
// TODO: delete the path node and all its ancestors
-// mNodeCache.clear();
+ mNodeCache.clear();
try {
IoTDBConfigDynamicAdapter.getInstance().addOrDeleteTimeSeries(-1);
} catch (ConfigAdjusterException e) {
@@ -513,7 +513,7 @@ public class MManager {
for (LeafMNode leafMNode : leafMNodes) {
removeFromTagInvertedIndex(leafMNode);
}
-// mNodeCache.clear();
+ mNodeCache.clear();
if (config.isEnableParameterAdapter()) {
IoTDBConfigDynamicAdapter.getInstance().addOrDeleteStorageGroup(-1);
@@ -868,45 +868,6 @@ public class MManager {
}
}
- public MNode getChild(MNode parent, String child, String info) {
- MNode childNode = parent.getChild(child);
- int tempCount = 0;
- while (childNode == null) {
- tempCount ++;
- try {
- Thread.sleep(1);
- } catch (InterruptedException e) {
- Thread.currentThread().interrupt();
- logger.warn("Current thread is interrupted, ignore");
- }
- if (tempCount % 1000 == 0) {
- MNode realDevice = null;
- try {
- realDevice = getNodeByPath(parent.getFullPath());
- MNode realChild = realDevice.getChild(child);
- if (realChild == null) {
- MNode fullNode = getNodeByPath(parent.getFullPath() +
IoTDBConstant.PATH_SEPARATOR + child);
- if (fullNode == null) {
- logger.warn("realChild is null, qilepale");
- } else {
- logger.warn("got it, origin device {}, child {}, current node
{}", parent.getFullPath(), child, fullNode.getFullPath());
- return fullNode;
- }
- } else {
- logger.warn("current device: == realDevice ? {}",
parent.equals(realDevice));
- logger.warn("current device {} realDevice {}", parent, realDevice);
- return realChild;
- }
- } catch (MetadataException e) {
- e.printStackTrace();
- }
- logger.warn("try to get child {} for {} times from {}", child,
tempCount, info);
- }
- childNode = parent.getChild(child);
- }
- return childNode;
- }
-
/**
* Get storage group node by path. If storage group is not set,
StorageGroupNotSetException will
* be thrown
@@ -933,9 +894,9 @@ public class MManager {
MNode node = null;
boolean shouldSetStorageGroup;
try {
- node = mtree.getNodeByPathWithStorageGroupCheck(path);
+ node = mNodeCache.get(path);
return node;
- } catch (MetadataException e) {
+ } catch (CacheException e) {
if (!autoCreateSchema) {
throw new PathNotExistException(path);
}
@@ -949,10 +910,10 @@ public class MManager {
lock.writeLock().lock();
try {
try {
- node = mtree.getNodeByPathWithStorageGroupCheck(path);
+ node = mNodeCache.get(path);
return node;
- } catch (MetadataException e) {
- shouldSetStorageGroup = e instanceof StorageGroupNotSetException;
+ } catch (CacheException e) {
+ shouldSetStorageGroup = e.getCause() instanceof
StorageGroupNotSetException;
}
if (shouldSetStorageGroup) {
diff --git
a/server/src/main/java/org/apache/iotdb/db/metadata/mnode/InternalMNode.java
b/server/src/main/java/org/apache/iotdb/db/metadata/mnode/InternalMNode.java
index 2d199cb..b590170 100644
--- a/server/src/main/java/org/apache/iotdb/db/metadata/mnode/InternalMNode.java
+++ b/server/src/main/java/org/apache/iotdb/db/metadata/mnode/InternalMNode.java
@@ -18,6 +18,7 @@
*/
package org.apache.iotdb.db.metadata.mnode;
+import java.util.concurrent.ConcurrentHashMap;
import org.apache.iotdb.db.exception.metadata.DeleteFailedException;
import java.util.LinkedHashMap;
@@ -39,8 +40,8 @@ public class InternalMNode extends MNode {
public InternalMNode(MNode parent, String name) {
super(parent, name);
- this.children = new LinkedHashMap<>();
- this.aliasChildren = new LinkedHashMap<>();
+ this.children = new ConcurrentHashMap<>();
+ this.aliasChildren = new ConcurrentHashMap<>();
}
@Override
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 da4c161..e0f0fde 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
@@ -875,7 +875,7 @@ public class PlanExecutor implements IPlanExecutor {
MeasurementSchema[] schemas = new
MeasurementSchema[measurementList.length];
for (int i = 0; i < measurementList.length; i++) {
- String measurement = measurementList[i];
+ String measurement = measurementList[i].trim();
try {
if (!node.hasChild(measurement)) {
if
(!IoTDBDescriptor.getInstance().getConfig().isAutoCreateSchemaEnabled()) {
@@ -886,11 +886,11 @@ public class PlanExecutor implements IPlanExecutor {
Path path = new Path(deviceId, measurement);
internalCreateTimeseries(path.toString(), dataType);
}
- LeafMNode measurementNode = (LeafMNode)
MManager.getInstance().getChild(node, measurement, deviceId + "
PlanExecutor-889");
+ LeafMNode measurementNode = (LeafMNode) node.getChild(measurement);
schemas[i] = measurementNode.getSchema();
// reset measurement to common name instead of alias
- measurementList[i] = measurementNode.getName();
+ measurementList[i] = measurement;
if (!insertPlan.isInferType()) {
checkType(insertPlan, i, measurementNode.getSchema().getType());
@@ -977,10 +977,8 @@ public class PlanExecutor implements IPlanExecutor {
Collections.emptyMap());
} catch (PathAlreadyExistException e) {
if (logger.isDebugEnabled()) {
- logger.debug(
- "Ignore PathAlreadyExistException when Concurrent inserting"
- + " a non-exist time series {}",
- path);
+ logger.debug("Ignore PathAlreadyExistException when Concurrent
inserting"
+ + " a non-exist time series {}", path);
}
}
}
@@ -1020,29 +1018,26 @@ public class PlanExecutor implements IPlanExecutor {
IoTDBConfig conf = IoTDBDescriptor.getInstance().getConfig();
MeasurementSchema[] schemas = new
MeasurementSchema[measurementList.length];
+ String measurement;
for (int i = 0; i < measurementList.length; i++) {
+ measurement = measurementList[i].trim();
// check if timeseries exists
- if (!node.hasChild(measurementList[i])) {
+ if (!node.hasChild(measurement)) {
if (!conf.isAutoCreateSchemaEnabled()) {
- throw new QueryProcessException(
- String.format(
- "Current deviceId[%s] does not contain measurement:%s",
- deviceId, measurementList[i]));
+ throw new QueryProcessException(String.format(
+ "Current deviceId[%s] does not contain measurement:%s",
deviceId, measurement));
}
- Path path = new Path(deviceId, measurementList[i]);
+ Path path = new Path(deviceId, measurement);
TSDataType dataType = dataTypes[i];
internalCreateTimeseries(path.getFullPath(), dataType);
}
- LeafMNode measurementNode = (LeafMNode) MManager.getInstance()
- .getChild(node, measurementList[i], deviceId + "
PlanExecutor-1036");
+ LeafMNode measurementNode = (LeafMNode) node.getChild(measurement);
// check data type
if (measurementNode.getSchema().getType() !=
insertTabletPlan.getDataTypes()[i]) {
- throw new QueryProcessException(
- String.format(
+ throw new QueryProcessException(String.format(
"Datatype mismatch, Insert measurement %s type %s, metadata
tree type %s",
- measurementList[i],
- insertTabletPlan.getDataTypes()[i],
+ measurement, insertTabletPlan.getDataTypes()[i],
measurementNode.getSchema().getType()));
}
schemas[i] = measurementNode.getSchema();
diff --git
a/server/src/main/java/org/apache/iotdb/db/qp/physical/crud/InsertPlan.java
b/server/src/main/java/org/apache/iotdb/db/qp/physical/crud/InsertPlan.java
index 21aee59..a5ec2cb 100644
--- a/server/src/main/java/org/apache/iotdb/db/qp/physical/crud/InsertPlan.java
+++ b/server/src/main/java/org/apache/iotdb/db/qp/physical/crud/InsertPlan.java
@@ -224,7 +224,7 @@ public class InsertPlan extends PhysicalPlan {
}
public void setDeviceId(String deviceId) {
- this.deviceId = deviceId;
+ this.deviceId = deviceId.trim();
}
public String[] getMeasurements() {
@@ -278,9 +278,9 @@ public class InsertPlan extends PhysicalPlan {
}
}
- for (int i = 0; i < measurements.length; i++) {
- if (measurements[i] != null) {
- schemas[i].serializeTo(stream);
+ for (MeasurementSchema schema: schemas) {
+ if (schema != null) {
+ schema.serializeTo(stream);
}
}
diff --git
a/server/src/main/java/org/apache/iotdb/db/qp/physical/crud/InsertTabletPlan.java
b/server/src/main/java/org/apache/iotdb/db/qp/physical/crud/InsertTabletPlan.java
index 4fcd813..20ab59b 100644
---
a/server/src/main/java/org/apache/iotdb/db/qp/physical/crud/InsertTabletPlan.java
+++
b/server/src/main/java/org/apache/iotdb/db/qp/physical/crud/InsertTabletPlan.java
@@ -73,18 +73,18 @@ public class InsertTabletPlan extends PhysicalPlan {
public InsertTabletPlan(String deviceId, List<String> measurements) {
super(false, OperatorType.BATCHINSERT);
- this.deviceId = deviceId;
+ this.deviceId = deviceId.trim();
setMeasurements(measurements);
}
public InsertTabletPlan(String deviceId, String[] measurements) {
super(false, OperatorType.BATCHINSERT);
- this.deviceId = deviceId;
+ this.deviceId = deviceId.trim();
setMeasurements(measurements);
}
public InsertTabletPlan(String deviceId, String[] measurements,
List<Integer> dataTypes) {
super(false, OperatorType.BATCHINSERT);
- this.deviceId = deviceId;
+ this.deviceId = deviceId.trim();
this.measurements = measurements;
setDataTypes(dataTypes);
}