FrankChen021 commented on code in PR #19393:
URL: https://github.com/apache/druid/pull/19393#discussion_r3173283444
##########
server/src/main/java/org/apache/druid/server/SetAndVerifyContextQueryRunner.java:
##########
@@ -70,13 +70,19 @@ public Query<T>
withTimeoutAndMaxScatterGatherBytes(Query<T> query, ServerConfig
);
// DirectDruidClient.QUERY_FAIL_TIME is used by DirectDruidClient and
JsonParserIterator to determine when to
// fail with a timeout exception
- final long failTime;
final QueryContext context = newQuery.context();
+ final long existingFailTime =
context.getLong(DirectDruidClient.QUERY_FAIL_TIME, -1L);
+ final long computedFailTime;
if (context.hasTimeout()) {
- failTime = this.startTimeMillis + context.getTimeout();
+ computedFailTime = this.startTimeMillis + context.getTimeout();
} else {
- failTime = this.startTimeMillis + serverConfig.getMaxQueryTimeout();
+ computedFailTime = this.startTimeMillis +
serverConfig.getMaxQueryTimeout();
}
+ // Never extend an existing deadline. This prevents nested native queries
(e.g. those generated by the SQL
+ // planner mid-execution) and queued historicals from pushing the
effective timeout past the original deadline.
+ final long failTime = (existingFailTime > 0)
Review Comment:
[P2] Saturate computed deadline before min
If context.getTimeout() or serverConfig.getMaxQueryTimeout() is
Long.MAX_VALUE, startTimeMillis + timeout overflows negative;
Math.min(existingFailTime, computedFailTime) then selects that negative value
and the final write normalizes it to Long.MAX_VALUE, extending a finite
existing deadline. Normalize or saturate the computed deadline before comparing
with the existing QUERY_FAIL_TIME.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]