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/09/21 15:55:00 UTC

[incubator-iotdb] 01/01: catch exception

This is an automated email from the ASF dual-hosted git repository.

qiaojialin pushed a commit to branch fix_concurrent
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git

commit 67208488ca6977f04f3758620e3afd812e2278d0
Author: qiaojialin <64...@qq.com>
AuthorDate: Mon Sep 21 23:54:27 2020 +0800

    catch exception
---
 .../org/apache/iotdb/db/metadata/MManager.java     | 31 ++++++++++++++++------
 1 file changed, 23 insertions(+), 8 deletions(-)

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 3af63e1..c24c858 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
@@ -52,6 +52,7 @@ import org.apache.iotdb.db.exception.ConfigAdjusterException;
 import org.apache.iotdb.db.exception.metadata.DeleteFailedException;
 import org.apache.iotdb.db.exception.metadata.IllegalPathException;
 import org.apache.iotdb.db.exception.metadata.MetadataException;
+import org.apache.iotdb.db.exception.metadata.PathAlreadyExistException;
 import org.apache.iotdb.db.exception.metadata.PathNotExistException;
 import org.apache.iotdb.db.exception.metadata.StorageGroupAlreadySetException;
 import org.apache.iotdb.db.exception.metadata.StorageGroupNotSetException;
@@ -1960,15 +1961,9 @@ public class MManager {
                 measurementList[i]));
           }
 
-          // create it
-
           TSDataType dataType = getTypeInLoc(plan, i);
-          createTimeseries(
-              deviceId.concatNode(measurementList[i]),
-              dataType,
-              getDefaultEncoding(dataType),
-              TSFileDescriptor.getInstance().getConfig().getCompressor(),
-              Collections.emptyMap());
+          // create it, may concurrent created by multiple thread
+          internalCreateTimeseries(deviceId.concatNode(measurementList[i]), dataType);
         }
 
         MeasurementMNode measurementNode = (MeasurementMNode) getChild(deviceNode,
@@ -2022,6 +2017,26 @@ public class MManager {
     return schemas;
   }
 
+
+  /**
+   * create timeseries with ignore PathAlreadyExistException
+   */
+  private void internalCreateTimeseries(PartialPath path, TSDataType dataType) throws MetadataException {
+    try {
+      createTimeseries(
+          path,
+          dataType,
+          getDefaultEncoding(dataType),
+          TSFileDescriptor.getInstance().getConfig().getCompressor(),
+          Collections.emptyMap());
+    } catch (PathAlreadyExistException e) {
+      if (logger.isDebugEnabled()) {
+        logger.debug("Ignore PathAlreadyExistException when Concurrent inserting"
+            + " a non-exist time series {}", path);
+      }
+    }
+  }
+
   /**
    * Get default encoding by dataType
    */