Search in sources :

Example 1 with BasicQueryStats

use of io.trino.server.BasicQueryStats in project trino by trinodb.

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 failureCause = this.failureCause.get();
        if (failureCause != null) {
            errorCode = failureCause.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.getPhysicalInputDataSize(), stageStats.getCumulativeUserMemory(), stageStats.getFailedCumulativeUserMemory(), stageStats.getUserMemoryReservation(), stageStats.getTotalMemoryReservation(), succinctBytes(getPeakUserMemoryInBytes()), succinctBytes(getPeakTotalMemoryInBytes()), stageStats.getTotalCpuTime(), stageStats.getFailedCpuTime(), stageStats.getTotalScheduledTime(), stageStats.getFailedScheduledTime(), stageStats.isFullyBlocked(), stageStats.getBlockedReasons(), stageStats.getProgressPercentage());
    return new BasicQueryInfo(queryId, session.toSessionRepresentation(), Optional.of(resourceGroup), state, stageStats.isScheduled(), self, query, Optional.ofNullable(updateType.get()), preparedQuery, queryStats, errorCode == null ? null : errorCode.getType(), errorCode, queryType);
}
Also used : BasicQueryStats(io.trino.server.BasicQueryStats) BasicQueryInfo(io.trino.server.BasicQueryInfo) ErrorCode(io.trino.spi.ErrorCode)

Example 2 with BasicQueryStats

use of io.trino.server.BasicQueryStats in project trino by trinodb.

the class TestMemoryManager method isBlockedWaitingForMemory.

private static boolean isBlockedWaitingForMemory(BasicQueryInfo info) {
    BasicQueryStats stats = info.getQueryStats();
    boolean isWaitingForMemory = stats.getBlockedReasons().contains(WAITING_FOR_MEMORY);
    if (!isWaitingForMemory) {
        return false;
    }
    // queries are not marked as fully blocked if there are no running drivers
    return stats.isFullyBlocked() || stats.getRunningDrivers() == 0;
}
Also used : BasicQueryStats(io.trino.server.BasicQueryStats)

Aggregations

BasicQueryStats (io.trino.server.BasicQueryStats)2 BasicQueryInfo (io.trino.server.BasicQueryInfo)1 ErrorCode (io.trino.spi.ErrorCode)1