You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ha...@apache.org on 2022/11/16 10:04:20 UTC

[iotdb] branch IoTDB_4948 created (now e7d0aa18ee)

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

haonan pushed a change to branch IoTDB_4948
in repository https://gitbox.apache.org/repos/asf/iotdb.git


      at e7d0aa18ee fix tests

This branch includes the following new commits:

     new c6624dc55c [IOTDB-4948] Optimize out-of-ttl error message
     new e7d0aa18ee fix tests

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[iotdb] 01/02: [IOTDB-4948] Optimize out-of-ttl error message

Posted by ha...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

haonan pushed a commit to branch IoTDB_4948
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit c6624dc55c428a04e3a27192d51d6b1380365b2e
Author: HTHou <hh...@outlook.com>
AuthorDate: Wed Nov 16 17:57:03 2022 +0800

    [IOTDB-4948] Optimize out-of-ttl error message
---
 .../statemachine/visitor/DataExecutionVisitor.java | 35 +++++++++++++++++-----
 .../iotdb/db/engine/storagegroup/DataRegion.java   | 14 ++++-----
 .../db/exception/query/OutOfTTLException.java      |  6 ++--
 3 files changed, 36 insertions(+), 19 deletions(-)

diff --git a/server/src/main/java/org/apache/iotdb/db/consensus/statemachine/visitor/DataExecutionVisitor.java b/server/src/main/java/org/apache/iotdb/db/consensus/statemachine/visitor/DataExecutionVisitor.java
index 63d5b62c2c..1146d3a527 100644
--- a/server/src/main/java/org/apache/iotdb/db/consensus/statemachine/visitor/DataExecutionVisitor.java
+++ b/server/src/main/java/org/apache/iotdb/db/consensus/statemachine/visitor/DataExecutionVisitor.java
@@ -25,6 +25,7 @@ import org.apache.iotdb.db.engine.storagegroup.DataRegion;
 import org.apache.iotdb.db.exception.BatchProcessException;
 import org.apache.iotdb.db.exception.TriggerExecutionException;
 import org.apache.iotdb.db.exception.WriteProcessException;
+import org.apache.iotdb.db.exception.query.OutOfTTLException;
 import org.apache.iotdb.db.mpp.plan.planner.plan.node.PlanNode;
 import org.apache.iotdb.db.mpp.plan.planner.plan.node.PlanVisitor;
 import org.apache.iotdb.db.mpp.plan.planner.plan.node.write.DeleteDataNode;
@@ -33,6 +34,8 @@ import org.apache.iotdb.db.mpp.plan.planner.plan.node.write.InsertRowNode;
 import org.apache.iotdb.db.mpp.plan.planner.plan.node.write.InsertRowsNode;
 import org.apache.iotdb.db.mpp.plan.planner.plan.node.write.InsertRowsOfOneDeviceNode;
 import org.apache.iotdb.db.mpp.plan.planner.plan.node.write.InsertTabletNode;
+import org.apache.iotdb.rpc.RpcUtils;
+import org.apache.iotdb.rpc.TSStatusCode;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -53,9 +56,12 @@ public class DataExecutionVisitor extends PlanVisitor<TSStatus, DataRegion> {
     try {
       dataRegion.insert(node);
       return StatusUtils.OK;
+    } catch (OutOfTTLException e) {
+      LOGGER.warn("Error in executing plan node: {}", node, e.getMessage());
+      return RpcUtils.getStatus(e.getErrorCode(), e.getMessage());
     } catch (WriteProcessException | TriggerExecutionException e) {
       LOGGER.error("Error in executing plan node: {}", node, e);
-      return StatusUtils.EXECUTE_STATEMENT_ERROR;
+      return RpcUtils.getStatus(e.getErrorCode(), e.getMessage());
     }
   }
 
@@ -64,9 +70,12 @@ public class DataExecutionVisitor extends PlanVisitor<TSStatus, DataRegion> {
     try {
       dataRegion.insertTablet(node);
       return StatusUtils.OK;
+    } catch (OutOfTTLException e) {
+      LOGGER.warn("Error in executing plan node: {}", node, e.getMessage());
+      return RpcUtils.getStatus(e.getErrorCode(), e.getMessage());
     } catch (TriggerExecutionException | WriteProcessException e) {
       LOGGER.error("Error in executing plan node: {}", node, e);
-      return StatusUtils.EXECUTE_STATEMENT_ERROR;
+      return RpcUtils.getStatus(e.getErrorCode(), e.getMessage());
     } catch (BatchProcessException e) {
       LOGGER.warn(
           "Batch failure in executing a InsertTabletNode. device: {}, startTime: {}, measurements: {}, failing status: {}",
@@ -74,7 +83,7 @@ public class DataExecutionVisitor extends PlanVisitor<TSStatus, DataRegion> {
           node.getTimes()[0],
           node.getMeasurements(),
           e.getFailingStatus());
-      return StatusUtils.EXECUTE_STATEMENT_ERROR;
+      return StatusUtils.getStatus(TSStatusCode.representOf(e.getErrorCode()));
     }
   }
 
@@ -85,9 +94,13 @@ public class DataExecutionVisitor extends PlanVisitor<TSStatus, DataRegion> {
       return StatusUtils.OK;
     } catch (BatchProcessException e) {
       LOGGER.warn("Batch failure in executing a InsertRowsNode.");
+      TSStatus firstStatus = null;
       // for each error
       for (Map.Entry<Integer, TSStatus> failedEntry : node.getResults().entrySet()) {
         InsertRowNode insertRowNode = node.getInsertRowNodeList().get(failedEntry.getKey());
+        if (firstStatus == null) {
+          firstStatus = failedEntry.getValue();
+        }
         LOGGER.warn(
             "Insert row failed. device: {}, time: {}, measurements: {}, failing status: {}",
             insertRowNode.getDevicePath(),
@@ -95,7 +108,7 @@ public class DataExecutionVisitor extends PlanVisitor<TSStatus, DataRegion> {
             insertRowNode.getMeasurements(),
             failedEntry.getValue());
       }
-      return StatusUtils.EXECUTE_STATEMENT_ERROR;
+      return firstStatus;
     }
   }
 
@@ -106,9 +119,13 @@ public class DataExecutionVisitor extends PlanVisitor<TSStatus, DataRegion> {
       return StatusUtils.OK;
     } catch (BatchProcessException e) {
       LOGGER.warn("Batch failure in executing a InsertMultiTabletsNode.");
+      TSStatus firstStatus = null;
       for (Map.Entry<Integer, TSStatus> failedEntry : node.getResults().entrySet()) {
         InsertTabletNode insertTabletNode =
             node.getInsertTabletNodeList().get(failedEntry.getKey());
+        if (firstStatus == null) {
+          firstStatus = failedEntry.getValue();
+        }
         LOGGER.warn(
             "Insert tablet failed. device: {}, startTime: {}, measurements: {}, failing status: {}",
             insertTabletNode.getDevicePath(),
@@ -116,7 +133,7 @@ public class DataExecutionVisitor extends PlanVisitor<TSStatus, DataRegion> {
             insertTabletNode.getMeasurements(),
             failedEntry.getValue());
       }
-      return StatusUtils.EXECUTE_STATEMENT_ERROR;
+      return firstStatus;
     }
   }
 
@@ -128,11 +145,15 @@ public class DataExecutionVisitor extends PlanVisitor<TSStatus, DataRegion> {
       return StatusUtils.OK;
     } catch (WriteProcessException | TriggerExecutionException e) {
       LOGGER.error("Error in executing plan node: {}", node, e);
-      return StatusUtils.EXECUTE_STATEMENT_ERROR;
+      return RpcUtils.getStatus(e.getErrorCode(), e.getMessage());
     } catch (BatchProcessException e) {
       LOGGER.warn("Batch failure in executing a InsertRowsOfOneDeviceNode.");
+      TSStatus firstStatus = null;
       for (Map.Entry<Integer, TSStatus> failedEntry : node.getResults().entrySet()) {
         InsertRowNode insertRowNode = node.getInsertRowNodeList().get(failedEntry.getKey());
+        if (firstStatus == null) {
+          firstStatus = failedEntry.getValue();
+        }
         LOGGER.warn(
             "Insert row failed. device: {}, time: {}, measurements: {}, failing status: {}",
             insertRowNode.getDevicePath(),
@@ -140,7 +161,7 @@ public class DataExecutionVisitor extends PlanVisitor<TSStatus, DataRegion> {
             insertRowNode.getMeasurements(),
             failedEntry.getValue());
       }
-      return StatusUtils.EXECUTE_STATEMENT_ERROR;
+      return firstStatus;
     }
   }
 
diff --git a/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/DataRegion.java b/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/DataRegion.java
index 06a0525455..23542ed75a 100755
--- a/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/DataRegion.java
+++ b/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/DataRegion.java
@@ -911,12 +911,8 @@ public class DataRegion {
         return;
       }
 
-      // fire trigger before insertion
-      // TriggerEngine.fire(TriggerEvent.BEFORE_INSERT, insertRowNode);
       // insert to sequence or unSequence file
       insertToTsFileProcessor(insertRowNode, isSequence, timePartitionId);
-      // fire trigger after insertion
-      // TriggerEngine.fire(TriggerEvent.AFTER_INSERT, insertRowNode);
     } finally {
       writeUnlock();
     }
@@ -950,7 +946,11 @@ public class DataRegion {
           results[loc] =
               RpcUtils.getStatus(
                   TSStatusCode.OUT_OF_TTL_ERROR,
-                  "time " + currTime + " in current line is out of TTL: " + dataTTL);
+                  String.format(
+                      "Insertion time [%s] is less than ttl time bound [%s]",
+                      DateTimeUtils.convertMillsecondToZonedDateTime(currTime),
+                      DateTimeUtils.convertMillsecondToZonedDateTime(
+                          DateTimeUtils.currentTime() - dataTTL)));
           loc++;
           noFailure = false;
         } else {
@@ -3108,8 +3108,6 @@ public class DataRegion {
           return;
         }
 
-        // fire trigger before insertion
-        // TriggerEngine.fire(TriggerEvent.BEFORE_INSERT, plan);
         // insert to sequence or unSequence file
         try {
           insertToTsFileProcessor(insertRowNode, isSequence, timePartitionId);
@@ -3118,8 +3116,6 @@ public class DataRegion {
               .getResults()
               .put(i, RpcUtils.getStatus(e.getErrorCode(), e.getMessage()));
         }
-        // fire trigger before insertion
-        // TriggerEngine.fire(TriggerEvent.AFTER_INSERT, plan);
       }
     } finally {
       writeUnlock();
diff --git a/server/src/main/java/org/apache/iotdb/db/exception/query/OutOfTTLException.java b/server/src/main/java/org/apache/iotdb/db/exception/query/OutOfTTLException.java
index 748f6c06e6..226442cf26 100644
--- a/server/src/main/java/org/apache/iotdb/db/exception/query/OutOfTTLException.java
+++ b/server/src/main/java/org/apache/iotdb/db/exception/query/OutOfTTLException.java
@@ -21,10 +21,9 @@
 package org.apache.iotdb.db.exception.query;
 
 import org.apache.iotdb.db.exception.WriteProcessException;
+import org.apache.iotdb.db.qp.utils.DateTimeUtils;
 import org.apache.iotdb.rpc.TSStatusCode;
 
-import java.util.Date;
-
 public class OutOfTTLException extends WriteProcessException {
 
   private static final long serialVersionUID = -1197147887094603300L;
@@ -33,7 +32,8 @@ public class OutOfTTLException extends WriteProcessException {
     super(
         String.format(
             "Insertion time [%s] is less than ttl time bound [%s]",
-            new Date(insertionTime), new Date(timeLowerBound)),
+            DateTimeUtils.convertMillsecondToZonedDateTime(insertionTime),
+            DateTimeUtils.convertMillsecondToZonedDateTime(timeLowerBound)),
         TSStatusCode.OUT_OF_TTL_ERROR.getStatusCode(),
         true);
   }


[iotdb] 02/02: fix tests

Posted by ha...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

haonan pushed a commit to branch IoTDB_4948
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit e7d0aa18ee5758f59fb8e252364a022b4c440269
Author: HTHou <hh...@outlook.com>
AuthorDate: Wed Nov 16 18:03:51 2022 +0800

    fix tests
---
 .../src/test/java/org/apache/iotdb/db/it/IoTDBTtlIT.java            | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBTtlIT.java b/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBTtlIT.java
index 3cd84d6c4c..62116eea51 100644
--- a/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBTtlIT.java
+++ b/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBTtlIT.java
@@ -133,7 +133,7 @@ public class IoTDBTtlIT {
               String.format(
                   "INSERT INTO root.TTL_SG1(timestamp, s1) VALUES (%d, %d)", now - 500000 + i, i));
         } catch (SQLException e) {
-          assertEquals(400, e.getErrorCode());
+          assertEquals(305, e.getErrorCode());
         }
       }
 
@@ -221,7 +221,7 @@ public class IoTDBTtlIT {
                   "INSERT INTO root.sg.TTL_SG3(timestamp, s1) VALUES (%d, %d)",
                   now - 5000000 + i, i));
         } catch (SQLException e) {
-          assertEquals(400, e.getErrorCode());
+          assertEquals(305, e.getErrorCode());
         }
       }
       for (int i = 100; i < 200; i++) {
@@ -232,7 +232,7 @@ public class IoTDBTtlIT {
                   "INSERT INTO root.sg.TTL_SG4(timestamp, s1) VALUES (%d, %d)",
                   now - 5000000 + i, i));
         } catch (SQLException e) {
-          assertEquals(400, e.getErrorCode());
+          assertEquals(305, e.getErrorCode());
         }
       }