You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ja...@apache.org on 2023/06/30 12:36:18 UTC

[iotdb] branch ty/CQBug created (now 0651b7d721a)

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

jackietien pushed a change to branch ty/CQBug
in repository https://gitbox.apache.org/repos/asf/iotdb.git


      at 0651b7d721a Fix CQ bug in ns time precision

This branch includes the following new commits:

     new 0651b7d721a Fix CQ bug in ns time precision

The 1 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/01: Fix CQ bug in ns time precision

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

jackietien pushed a commit to branch ty/CQBug
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit 0651b7d721a5c6287f2707a3abd8f36b1beea33a
Author: JackieTien97 <ja...@gmail.com>
AuthorDate: Fri Jun 30 20:34:58 2023 +0800

    Fix CQ bug in ns time precision
---
 .../confignode/manager/cq/CQScheduleTask.java      | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/cq/CQScheduleTask.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/cq/CQScheduleTask.java
index 73de8bc54a6..879ff1751f5 100644
--- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/cq/CQScheduleTask.java
+++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/cq/CQScheduleTask.java
@@ -22,6 +22,7 @@ package org.apache.iotdb.confignode.manager.cq;
 import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation;
 import org.apache.iotdb.common.rpc.thrift.TSStatus;
 import org.apache.iotdb.commons.client.async.AsyncDataNodeInternalServiceClient;
+import org.apache.iotdb.commons.conf.CommonDescriptor;
 import org.apache.iotdb.commons.cq.TimeoutPolicy;
 import org.apache.iotdb.confignode.client.async.AsyncDataNodeClientPool;
 import org.apache.iotdb.confignode.consensus.request.write.cq.UpdateCQLastExecTimePlan;
@@ -46,6 +47,22 @@ public class CQScheduleTask implements Runnable {
 
   private static final long DEFAULT_RETRY_WAIT_TIME_IN_MS = 20L * 1_000;
 
+  // ms is 1
+  // us is 1_000
+  // ns is 1_000_000
+  private static final long FACTOR;
+
+  static {
+    String timestampPrecision = CommonDescriptor.getInstance().getConfig().getTimestampPrecision();
+    if ("us".equals(timestampPrecision)) {
+      FACTOR = 1_000;
+    } else if ("ns".equals(timestampPrecision)) {
+      FACTOR = 1_000_000;
+    } else {
+      FACTOR = 1;
+    }
+  }
+
   private final String cqId;
   private final long everyInterval;
   private final long startTimeOffset;
@@ -129,7 +146,7 @@ public class CQScheduleTask implements Runnable {
     this.username = username;
     this.executor = executor;
     this.configManager = configManager;
-    this.retryWaitTimeInMS = Math.min(DEFAULT_RETRY_WAIT_TIME_IN_MS, everyInterval);
+    this.retryWaitTimeInMS = Math.min(DEFAULT_RETRY_WAIT_TIME_IN_MS, everyInterval / FACTOR);
     this.executionTime = executionTime;
   }
 
@@ -183,7 +200,8 @@ public class CQScheduleTask implements Runnable {
   }
 
   public void submitSelf() {
-    submitSelf(Math.max(0, executionTime - System.currentTimeMillis()), TimeUnit.MILLISECONDS);
+    submitSelf(
+        Math.max(0, executionTime / FACTOR - System.currentTimeMillis()), TimeUnit.MILLISECONDS);
   }
 
   private void submitSelf(long delay, TimeUnit unit) {