use of com.facebook.presto.spi.StandardErrorCode.EXCEEDED_TIME_LIMIT in project presto by prestodb.
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());
QueryLimit<Duration> queryMaxExecutionTime = getMinimum(createDurationLimit(getQueryMaxExecutionTime(query.getSession()), QUERY), query.getResourceGroupQueryLimits().flatMap(ResourceGroupQueryLimits::getExecutionTimeLimit).map(rgLimit -> createDurationLimit(rgLimit, RESOURCE_GROUP)).orElse(null));
Optional<DateTime> executionStartTime = query.getExecutionStartTime();
DateTime createTime = query.getCreateTime();
if (executionStartTime.isPresent() && executionStartTime.get().plus(queryMaxExecutionTime.getLimit().toMillis()).isBeforeNow()) {
query.fail(new PrestoException(EXCEEDED_TIME_LIMIT, format("Query exceeded the maximum execution time limit of %s defined at the %s level", queryMaxExecutionTime.getLimit(), queryMaxExecutionTime.getLimitSource().name())));
}
if (createTime.plus(queryMaxRunTime.toMillis()).isBeforeNow()) {
query.fail(new PrestoException(EXCEEDED_TIME_LIMIT, "Query exceeded maximum time limit of " + queryMaxRunTime));
}
}
}
Aggregations