Search in sources :

Example 6 with ErrorCode

use of io.prestosql.spi.ErrorCode in project hetu-core by openlookeng.

the class QueryStateMachine method getBasicQueryInfo.

public BasicQueryInfo getBasicQueryInfo(Optional<BasicStageStats> rootStage) {
    // Query state must be captured first in order to provide a
    // correct view of the query.  For example, building this
    // information, the query could finish, and the task states would
    // never be visible.
    QueryState state = queryState.get();
    ErrorCode errorCode = null;
    if (state == FAILED) {
        ExecutionFailureInfo localFailureCause = this.failureCause.get();
        if (localFailureCause != null) {
            errorCode = localFailureCause.getErrorCode();
        }
    }
    BasicStageStats stageStats = rootStage.orElse(EMPTY_STAGE_STATS);
    BasicQueryStats queryStats = new BasicQueryStats(queryStateTimer.getCreateTime(), getEndTime().orElse(null), queryStateTimer.getQueuedTime(), queryStateTimer.getElapsedTime(), queryStateTimer.getExecutionTime(), stageStats.getTotalDrivers(), stageStats.getQueuedDrivers(), stageStats.getRunningDrivers(), stageStats.getCompletedDrivers(), stageStats.getRawInputDataSize(), stageStats.getRawInputPositions(), stageStats.getCumulativeUserMemory(), stageStats.getUserMemoryReservation(), stageStats.getTotalMemoryReservation(), succinctBytes(getPeakUserMemoryInBytes()), succinctBytes(getPeakTotalMemoryInBytes()), stageStats.getTotalCpuTime(), stageStats.getTotalScheduledTime(), stageStats.isFullyBlocked(), stageStats.getBlockedReasons(), stageStats.getProgressPercentage());
    return new BasicQueryInfo(queryId, session.toSessionRepresentation(), Optional.of(resourceGroup), state, memoryPool.get().getId(), stageStats.isScheduled(), self, query, preparedQuery, queryStats, errorCode == null ? null : errorCode.getType(), errorCode);
}
Also used : BasicQueryStats(io.prestosql.server.BasicQueryStats) BasicQueryInfo(io.prestosql.server.BasicQueryInfo) ErrorCode(io.prestosql.spi.ErrorCode)

Example 7 with ErrorCode

use of io.prestosql.spi.ErrorCode in project hetu-core by openlookeng.

the class Query method toQueryError.

private static QueryError toQueryError(QueryInfo queryInfo) {
    QueryState state = queryInfo.getState();
    if (state != FAILED) {
        return null;
    }
    ExecutionFailureInfo executionFailure;
    if (queryInfo.getFailureInfo() != null) {
        executionFailure = queryInfo.getFailureInfo();
    } else {
        log.warn("Query %s in state %s has no failure info", queryInfo.getQueryId(), state);
        executionFailure = toFailure(new RuntimeException(format("Query is %s (reason unknown)", state)));
    }
    FailureInfo failure = executionFailure.toFailureInfoWithoutStack();
    ErrorCode errorCode;
    if (queryInfo.getErrorCode() != null) {
        errorCode = queryInfo.getErrorCode();
    } else {
        errorCode = GENERIC_INTERNAL_ERROR.toErrorCode();
        log.warn("Failed query %s has no error code", queryInfo.getQueryId());
    }
    return new QueryError(firstNonNull(failure.getMessage(), "Internal error"), null, errorCode.getCode(), errorCode.getName(), executionFailure.getSemanticErrorCode().map(SemanticErrorCode::name), errorCode.getType().toString(), failure.getErrorLocation(), failure);
}
Also used : FailureInfo(io.prestosql.client.FailureInfo) ExecutionFailureInfo(io.prestosql.execution.ExecutionFailureInfo) QueryState(io.prestosql.execution.QueryState) SemanticErrorCode(io.prestosql.sql.analyzer.SemanticErrorCode) ErrorCode(io.prestosql.spi.ErrorCode) QueryError(io.prestosql.client.QueryError) ExecutionFailureInfo(io.prestosql.execution.ExecutionFailureInfo)

Aggregations

ErrorCode (io.prestosql.spi.ErrorCode)7 BasicQueryInfo (io.prestosql.server.BasicQueryInfo)4 Duration (io.airlift.units.Duration)2 ExecutionFailureInfo (io.prestosql.execution.ExecutionFailureInfo)2 SemanticErrorCode (io.prestosql.sql.analyzer.SemanticErrorCode)2 Returns (org.mockito.internal.stubbing.answers.Returns)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 DataSize (io.airlift.units.DataSize)1 SessionRepresentation (io.prestosql.SessionRepresentation)1 FailureInfo (io.prestosql.client.FailureInfo)1 QueryError (io.prestosql.client.QueryError)1 DispatchQuery (io.prestosql.dispatcher.DispatchQuery)1 LocalDispatchQuery (io.prestosql.dispatcher.LocalDispatchQuery)1 Failure (io.prestosql.execution.Failure)1 QueryOutputInfo (io.prestosql.execution.QueryExecution.QueryOutputInfo)1 QueryInfo (io.prestosql.execution.QueryInfo)1 QueryState (io.prestosql.execution.QueryState)1 RemoteTask (io.prestosql.execution.RemoteTask)1 BlockedReason (io.prestosql.operator.BlockedReason)1 BasicQueryStats (io.prestosql.server.BasicQueryStats)1