Search in sources :

Example 11 with BasicQueryInfo

use of io.prestosql.server.BasicQueryInfo 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 12 with BasicQueryInfo

use of io.prestosql.server.BasicQueryInfo in project hetu-core by openlookeng.

the class FailedDispatchQueryFactory method createFailedDispatchQuery.

public FailedDispatchQuery createFailedDispatchQuery(Session session, String query, Optional<ResourceGroupId> resourceGroup, Throwable throwable) {
    ExecutionFailureInfo failure = toFailure(throwable);
    FailedDispatchQuery failedDispatchQuery = new FailedDispatchQuery(session, query, locationFactory.createQueryLocation(session.getQueryId()), resourceGroup, failure, executor);
    BasicQueryInfo queryInfo = failedDispatchQuery.getBasicQueryInfo();
    queryMonitor.queryCreatedEvent(queryInfo);
    queryMonitor.queryImmediateFailureEvent(queryInfo, failure);
    return failedDispatchQuery;
}
Also used : BasicQueryInfo(io.prestosql.server.BasicQueryInfo) ExecutionFailureInfo(io.prestosql.execution.ExecutionFailureInfo)

Example 13 with BasicQueryInfo

use of io.prestosql.server.BasicQueryInfo in project hetu-core by openlookeng.

the class LocalDispatchQuery method getDispatchInfo.

@Override
public DispatchInfo getDispatchInfo() {
    // observe submitted before getting the state, to ensure a failed query stat is visible
    boolean dispatched = submitted.isDone();
    BasicQueryInfo queryInfo = stateMachine.getBasicQueryInfo(Optional.empty());
    if (queryInfo.getState() == FAILED) {
        ExecutionFailureInfo failureInfo = stateMachine.getFailureInfo().orElseGet(() -> toFailure(new PrestoException(GENERIC_INTERNAL_ERROR, "Query failed for an unknown reason")));
        return DispatchInfo.failed(failureInfo, queryInfo.getQueryStats().getElapsedTime(), queryInfo.getQueryStats().getQueuedTime());
    }
    if (dispatched) {
        return DispatchInfo.dispatched(new LocalCoordinatorLocation(), queryInfo.getQueryStats().getElapsedTime(), queryInfo.getQueryStats().getQueuedTime());
    }
    return DispatchInfo.queued(queryInfo.getQueryStats().getElapsedTime(), queryInfo.getQueryStats().getQueuedTime());
}
Also used : BasicQueryInfo(io.prestosql.server.BasicQueryInfo) PrestoException(io.prestosql.spi.PrestoException) ExecutionFailureInfo(io.prestosql.execution.ExecutionFailureInfo)

Example 14 with BasicQueryInfo

use of io.prestosql.server.BasicQueryInfo in project hetu-core by openlookeng.

the class ClusterMemoryLeakDetector method isLeaked.

private static boolean isLeaked(Map<QueryId, BasicQueryInfo> queryIdToInfo, QueryId queryId) {
    BasicQueryInfo queryInfo = queryIdToInfo.get(queryId);
    if (queryInfo == null) {
        return true;
    }
    DateTime queryEndTime = queryInfo.getQueryStats().getEndTime();
    if (queryInfo.getState() == RUNNING || queryEndTime == null) {
        return false;
    }
    return secondsBetween(queryEndTime, now()).getSeconds() >= DEFAULT_LEAK_CLAIM_DELTA_SEC;
}
Also used : BasicQueryInfo(io.prestosql.server.BasicQueryInfo) DateTime(org.joda.time.DateTime)

Example 15 with BasicQueryInfo

use of io.prestosql.server.BasicQueryInfo in project hetu-core by openlookeng.

the class TestOracleDistributedQueries method testQueryLoggingCount.

/**
 * testQueryLoggingCount
 */
@Override
public void testQueryLoggingCount() {
    QueryManager queryManager = ((DistributedQueryRunner) getQueryRunner()).getCoordinator().getQueryManager();
    executeExclusively(() -> {
        assertUntilTimeout(() -> assertEquals(queryManager.getQueries().stream().map(BasicQueryInfo::getQueryId).map(queryManager::getFullQueryInfo).filter(info -> !info.isFinalQueryInfo()).collect(toList()), ImmutableList.of()), new Duration(1, MINUTES));
        DispatchManager dispatchManager = ((DistributedQueryRunner) getQueryRunner()).getCoordinator().getDispatchManager();
        long beforeCompletedQueriesCount = waitUntilStable(() -> dispatchManager.getStats().getCompletedQueries().getTotalCount(), new Duration(NUMBER_5, SECONDS));
        long beforeSubmittedQueriesCount = dispatchManager.getStats().getSubmittedQueries().getTotalCount();
        assertUpdate("CREATE TABLE test_query_logging_count AS SELECT 1 foo_1, 2 foo_2_4", 1);
        assertQuery("SELECT foo_1, foo_2_4 FROM test_query_logging_count", "SELECT 1, 2");
        assertUpdate("DROP TABLE test_query_logging_count");
        assertQueryFails("SELECT * FROM test_query_logging_count", ".*Table .* does not exist");
        assertUntilTimeout(() -> assertEquals(dispatchManager.getStats().getCompletedQueries().getTotalCount() - beforeCompletedQueriesCount, NUMBER_4), new Duration(1, MINUTES));
        assertEquals(dispatchManager.getStats().getSubmittedQueries().getTotalCount() - beforeSubmittedQueriesCount, NUMBER_4);
    });
}
Also used : IntStream.range(java.util.stream.IntStream.range) SystemSessionProperties(io.prestosql.SystemSessionProperties) QueryInfo(io.prestosql.execution.QueryInfo) Test(org.testng.annotations.Test) Thread.currentThread(java.lang.Thread.currentThread) INFORMATION_SCHEMA(io.prestosql.connector.informationschema.InformationSchemaMetadata.INFORMATION_SCHEMA) MaterializedResult(io.prestosql.testing.MaterializedResult) Duration(io.airlift.units.Duration) ADD_COLUMN(io.prestosql.testing.TestingAccessControlManager.TestingPrivilegeType.ADD_COLUMN) RENAME_TABLE(io.prestosql.testing.TestingAccessControlManager.TestingPrivilegeType.RENAME_TABLE) SET_SESSION(io.prestosql.testing.TestingAccessControlManager.TestingPrivilegeType.SET_SESSION) Assertions(io.airlift.testing.Assertions) QueryManager(io.prestosql.execution.QueryManager) DistributedQueryRunner(io.prestosql.tests.DistributedQueryRunner) Duration.nanosSince(io.airlift.units.Duration.nanosSince) Assert.assertFalse(org.testng.Assert.assertFalse) CREATE_TABLE(io.prestosql.testing.TestingAccessControlManager.TestingPrivilegeType.CREATE_TABLE) ImmutableSet(com.google.common.collect.ImmutableSet) ImmutableMap(com.google.common.collect.ImmutableMap) AbstractTestDistributedQueries(io.prestosql.tests.AbstractTestDistributedQueries) OracleQueryRunner.createOracleQueryRunner(io.hetu.core.plugin.oracle.OracleQueryRunner.createOracleQueryRunner) MILLISECONDS(java.util.concurrent.TimeUnit.MILLISECONDS) Uninterruptibles.sleepUninterruptibly(com.google.common.util.concurrent.Uninterruptibles.sleepUninterruptibly) DROP_COLUMN(io.prestosql.testing.TestingAccessControlManager.TestingPrivilegeType.DROP_COLUMN) String.format(java.lang.String.format) Collectors.joining(java.util.stream.Collectors.joining) TpchTable(io.airlift.tpch.TpchTable) CREATE_VIEW(io.prestosql.testing.TestingAccessControlManager.TestingPrivilegeType.CREATE_VIEW) SET_USER(io.prestosql.testing.TestingAccessControlManager.TestingPrivilegeType.SET_USER) Assert.assertNull(org.testng.Assert.assertNull) QueryAssertions.assertContains(io.prestosql.tests.QueryAssertions.assertContains) TESTING_CATALOG(io.prestosql.testing.TestingSession.TESTING_CATALOG) Assert.assertEquals(org.testng.Assert.assertEquals) MINUTES(java.util.concurrent.TimeUnit.MINUTES) Supplier(java.util.function.Supplier) TestingAccessControlManager.privilege(io.prestosql.testing.TestingAccessControlManager.privilege) ImmutableList(com.google.common.collect.ImmutableList) BasicQueryInfo(io.prestosql.server.BasicQueryInfo) Session(io.prestosql.Session) UncheckedTimeoutException(com.google.common.util.concurrent.UncheckedTimeoutException) DispatchManager(io.prestosql.dispatcher.DispatchManager) AfterClass(org.testng.annotations.AfterClass) ResultWithQueryId(io.prestosql.tests.ResultWithQueryId) Language(org.intellij.lang.annotations.Language) QUERY_MAX_MEMORY(io.prestosql.SystemSessionProperties.QUERY_MAX_MEMORY) Iterables.getOnlyElement(com.google.common.collect.Iterables.getOnlyElement) Collectors.toList(java.util.stream.Collectors.toList) DROP_TABLE(io.prestosql.testing.TestingAccessControlManager.TestingPrivilegeType.DROP_TABLE) Assert.assertTrue(org.testng.Assert.assertTrue) RENAME_COLUMN(io.prestosql.testing.TestingAccessControlManager.TestingPrivilegeType.RENAME_COLUMN) SECONDS(java.util.concurrent.TimeUnit.SECONDS) DispatchManager(io.prestosql.dispatcher.DispatchManager) QueryManager(io.prestosql.execution.QueryManager) Duration(io.airlift.units.Duration)

Aggregations

BasicQueryInfo (io.prestosql.server.BasicQueryInfo)20 Test (org.testng.annotations.Test)9 QueryManager (io.prestosql.execution.QueryManager)6 TestingPrestoServer (io.prestosql.server.testing.TestingPrestoServer)5 QueryId (io.prestosql.spi.QueryId)5 Duration (io.airlift.units.Duration)4 DispatchManager (io.prestosql.dispatcher.DispatchManager)4 QueryInfo (io.prestosql.execution.QueryInfo)4 ArrayList (java.util.ArrayList)4 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)3 ErrorCode (io.prestosql.spi.ErrorCode)3 ImmutableList (com.google.common.collect.ImmutableList)2 ImmutableMap (com.google.common.collect.ImmutableMap)2 ImmutableSet (com.google.common.collect.ImmutableSet)2 Iterables.getOnlyElement (com.google.common.collect.Iterables.getOnlyElement)2 UncheckedTimeoutException (com.google.common.util.concurrent.UncheckedTimeoutException)2 Uninterruptibles.sleepUninterruptibly (com.google.common.util.concurrent.Uninterruptibles.sleepUninterruptibly)2 Assertions (io.airlift.testing.Assertions)2 Duration.nanosSince (io.airlift.units.Duration.nanosSince)2 Session (io.prestosql.Session)2