Search in sources :

Example 1 with EXCEEDED_TIME_LIMIT

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));
        }
    }
}
Also used : EXCEEDED_TIME_LIMIT(com.facebook.presto.spi.StandardErrorCode.EXCEEDED_TIME_LIMIT) Duration(io.airlift.units.Duration) PrestoException(com.facebook.presto.spi.PrestoException) DateTime(org.joda.time.DateTime)

Aggregations

PrestoException (com.facebook.presto.spi.PrestoException)1 EXCEEDED_TIME_LIMIT (com.facebook.presto.spi.StandardErrorCode.EXCEEDED_TIME_LIMIT)1 Duration (io.airlift.units.Duration)1 DateTime (org.joda.time.DateTime)1