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 62d995ad40a..163b70383ef 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 fccc3a2c86a..b61ffa4bf4a 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 5cd0e0802e3..31a7a454f37 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()); } }