use of io.trino.spi.StandardErrorCode.EXCEEDED_TIME_LIMIT in project trino by trinodb.
the class QueryTracker method enforceTimeLimits.
/**
* Enforce query max runtime/execution time limits
*/
private void enforceTimeLimits() {
for (T query : queries.values()) {
if (query.isDone()) {
continue;
}
Duration queryMaxRunTime = getQueryMaxRunTime(query.getSession());
Duration queryMaxExecutionTime = getQueryMaxExecutionTime(query.getSession());
Duration queryMaxPlanningTime = getQueryMaxPlanningTime(query.getSession());
Optional<DateTime> executionStartTime = query.getExecutionStartTime();
Optional<Duration> planningTime = query.getPlanningTime();
DateTime createTime = query.getCreateTime();
if (executionStartTime.isPresent() && executionStartTime.get().plus(queryMaxExecutionTime.toMillis()).isBeforeNow()) {
query.fail(new TrinoException(EXCEEDED_TIME_LIMIT, "Query exceeded the maximum execution time limit of " + queryMaxExecutionTime));
}
planningTime.filter(duration -> duration.compareTo(queryMaxPlanningTime) > 0).ifPresent(ignored -> query.fail(new TrinoException(EXCEEDED_TIME_LIMIT, "Query exceeded the maximum planning time limit of " + queryMaxPlanningTime)));
if (createTime.plus(queryMaxRunTime.toMillis()).isBeforeNow()) {
query.fail(new TrinoException(EXCEEDED_TIME_LIMIT, "Query exceeded maximum time limit of " + queryMaxRunTime));
}
}
}
Aggregations