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:19 UTC
[iotdb] 01/01: Fix CQ bug in ns time precision
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) {