You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by hx...@apache.org on 2019/07/13 13:23:30 UTC
[incubator-iotdb] 01/02: add pathExist() check after obtain lock
when trying to add path to metadata tree
This is an automated email from the ASF dual-hosted git repository.
hxd pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git
commit 57c49f69609c164ccd5545001995518f49950324
Author: xingtanzjr <xi...@163.com>
AuthorDate: Sat Jul 13 19:03:48 2019 +0800
add pathExist() check after obtain lock when trying to add path to metadata tree
---
iotdb/src/main/java/org/apache/iotdb/db/metadata/MManager.java | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/metadata/MManager.java b/iotdb/src/main/java/org/apache/iotdb/db/metadata/MManager.java
index 0ae3434..72346ce 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/metadata/MManager.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/metadata/MManager.java
@@ -289,6 +289,11 @@ public class MManager {
boolean isNewMeasurement = true;
// Thread safety: just one thread can access/modify the schemaMap
synchronized (schemaMap) {
+ // Need to check the path again to avoid duplicated inserting by multi concurrent thread
+ if (pathExist(path.getFullPath())) {
+ throw new MetadataErrorException(
+ String.format("Timeseries %s already exist", path.getFullPath()));
+ }
if (schemaMap.containsKey(lastNode)) {
isNewMeasurement = false;
MeasurementSchema columnSchema = schemaMap.get(lastNode);