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

gian pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/druid.git


The following commit(s) were added to refs/heads/master by this push:
     new 90531fd53f Do not alter query timeout in ScanQueryEngine (#12271)
90531fd53f is described below

commit 90531fd53fafd3af37b4d403b3bb8eea5d13e456
Author: machine424 <[email protected]>
AuthorDate: Thu May 19 18:24:42 2022 +0200

    Do not alter query timeout in ScanQueryEngine (#12271)
    
    Add test to detect timeout mutability
---
 .../main/java/org/apache/druid/query/context/ResponseContext.java   | 3 ---
 .../src/main/java/org/apache/druid/query/scan/ScanQueryEngine.java  | 6 ------
 .../test/java/org/apache/druid/query/scan/ScanQueryRunnerTest.java  | 4 +++-
 3 files changed, 3 insertions(+), 10 deletions(-)

diff --git 
a/processing/src/main/java/org/apache/druid/query/context/ResponseContext.java 
b/processing/src/main/java/org/apache/druid/query/context/ResponseContext.java
index 62d995ad40..163b70383e 100644
--- 
a/processing/src/main/java/org/apache/druid/query/context/ResponseContext.java
+++ 
b/processing/src/main/java/org/apache/druid/query/context/ResponseContext.java
@@ -408,7 +408,6 @@ public abstract class ResponseContext
 
     /**
      * Query fail time (current time + timeout).
-     * It is not updated continuously as {@link Keys#TIMEOUT_AT}.
      */
     public static final Key QUERY_FAIL_DEADLINE_MILLIS = new LongKey(
         "queryFailTime",
@@ -417,8 +416,6 @@ public abstract class ResponseContext
     /**
      * This variable indicates when a running query should be expired,
      * and is effective only when 'timeout' of queryContext has a positive 
value.
-     * Continuously updated by {@link 
org.apache.druid.query.scan.ScanQueryEngine}
-     * by reducing its value on the time of every scan iteration.
      */
     public static final Key TIMEOUT_AT = new LongKey(
         "timeoutAt",
diff --git 
a/processing/src/main/java/org/apache/druid/query/scan/ScanQueryEngine.java 
b/processing/src/main/java/org/apache/druid/query/scan/ScanQueryEngine.java
index fccc3a2c86..b61ffa4bf4 100644
--- a/processing/src/main/java/org/apache/druid/query/scan/ScanQueryEngine.java
+++ b/processing/src/main/java/org/apache/druid/query/scan/ScanQueryEngine.java
@@ -80,7 +80,6 @@ public class ScanQueryEngine
     }
     final boolean hasTimeout = QueryContexts.hasTimeout(query);
     final Long timeoutAt = responseContext.getTimeoutTime();
-    final long start = System.currentTimeMillis();
     final StorageAdapter adapter = segment.asStorageAdapter();
 
     if (adapter == null) {
@@ -192,11 +191,6 @@ public class ScanQueryEngine
                               throw new UOE("resultFormat[%s] is not 
supported", resultFormat.toString());
                             }
                             responseContext.addRowScanCount(offset - 
lastOffset);
-                            if (hasTimeout) {
-                              responseContext.putTimeoutTime(
-                                  timeoutAt - (System.currentTimeMillis() - 
start)
-                              );
-                            }
                             return new ScanResultValue(segmentId.toString(), 
allColumns, events);
                           }
 
diff --git 
a/processing/src/test/java/org/apache/druid/query/scan/ScanQueryRunnerTest.java 
b/processing/src/test/java/org/apache/druid/query/scan/ScanQueryRunnerTest.java
index 5cd0e0802e..31a7a454f3 100644
--- 
a/processing/src/test/java/org/apache/druid/query/scan/ScanQueryRunnerTest.java
+++ 
b/processing/src/test/java/org/apache/druid/query/scan/ScanQueryRunnerTest.java
@@ -909,7 +909,8 @@ public class ScanQueryRunnerTest extends 
InitializedNullHandlingTest
         .context(ImmutableMap.of(QueryContexts.TIMEOUT_KEY, 1))
         .build();
     ResponseContext responseContext = DefaultResponseContext.createEmpty();
-    responseContext.putTimeoutTime(System.currentTimeMillis());
+    final long timeoutAt = System.currentTimeMillis();
+    responseContext.putTimeoutTime(timeoutAt);
     try {
       runner.run(QueryPlus.wrap(query), responseContext).toList();
       Assert.fail("didn't timeout");
@@ -917,6 +918,7 @@ public class ScanQueryRunnerTest extends 
InitializedNullHandlingTest
     catch (RuntimeException e) {
       Assert.assertTrue(e instanceof QueryTimeoutException);
       Assert.assertEquals("Query timeout", ((QueryTimeoutException) 
e).getErrorCode());
+      Assert.assertEquals(timeoutAt, 
responseContext.getTimeoutTime().longValue());
     }
   }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to