Search in sources :

Example 11 with DispatchManager

use of com.facebook.presto.dispatcher.DispatchManager in project presto by prestodb.

the class TestQueues method testRejection.

private void testRejection() throws Exception {
    try (DistributedQueryRunner queryRunner = createQueryRunner()) {
        queryRunner.installPlugin(new ResourceGroupManagerPlugin());
        queryRunner.getCoordinator().getResourceGroupManager().get().setConfigurationManager("file", ImmutableMap.of("resource-groups.config-file", getResourceFilePath("resource_groups_config_dashboard.json")));
        QueryId queryId = createQuery(queryRunner, newRejectionSession(), LONG_LASTING_QUERY);
        waitForQueryState(queryRunner, queryId, FAILED);
        DispatchManager dispatchManager = queryRunner.getCoordinator().getDispatchManager();
        assertEquals(dispatchManager.getQueryInfo(queryId).getErrorCode(), QUERY_REJECTED.toErrorCode());
    }
}
Also used : DistributedQueryRunner(com.facebook.presto.tests.DistributedQueryRunner) DispatchManager(com.facebook.presto.dispatcher.DispatchManager) QueryId(com.facebook.presto.spi.QueryId) ResourceGroupManagerPlugin(com.facebook.presto.resourceGroups.ResourceGroupManagerPlugin)

Example 12 with DispatchManager

use of com.facebook.presto.dispatcher.DispatchManager in project presto by prestodb.

the class TestQueuesDb method testQueryExecutionTimeLimit.

@Test(timeOut = 60_000)
public void testQueryExecutionTimeLimit() throws Exception {
    QueryManager queryManager = queryRunner.getCoordinator().getQueryManager();
    InternalResourceGroupManager manager = queryRunner.getCoordinator().getResourceGroupManager().get();
    ReloadingResourceGroupConfigurationManager reloadingConfigurationManager = (ReloadingResourceGroupConfigurationManager) manager.getConfigurationManager();
    QueryId firstQuery = createQuery(queryRunner, testSessionBuilder().setCatalog("tpch").setSchema("sf100000").setSource("dashboard").setSystemProperty(QUERY_MAX_EXECUTION_TIME, "1ms").build(), LONG_LASTING_QUERY);
    waitForQueryState(queryRunner, firstQuery, FAILED);
    assertEquals(queryManager.getFullQueryInfo(firstQuery).getErrorCode(), EXCEEDED_TIME_LIMIT.toErrorCode());
    assertContains(queryManager.getFullQueryInfo(firstQuery).getFailureInfo().getMessage(), "Query exceeded the maximum execution time limit of 1.00ms");
    // set max running queries to 0 for the dashboard resource group so that new queries get queued immediately
    dao.updateResourceGroup(5, "dashboard-${USER}", "1MB", 1, null, 0, null, null, null, null, null, null, null, null, 3L, TEST_ENVIRONMENT);
    reloadingConfigurationManager.load();
    QueryId secondQuery = createQuery(queryRunner, testSessionBuilder().setCatalog("tpch").setSchema("sf100000").setSource("dashboard").setSystemProperty(QUERY_MAX_EXECUTION_TIME, "1ms").build(), LONG_LASTING_QUERY);
    // this query should immediately get queued
    waitForQueryState(queryRunner, secondQuery, QUEUED);
    // after a 5s wait this query should still be QUEUED, not FAILED as the max execution time should be enforced after the query starts running
    Thread.sleep(5_000);
    DispatchManager dispatchManager = queryRunner.getCoordinator().getDispatchManager();
    assertEquals(dispatchManager.getQueryInfo(secondQuery).getState(), QUEUED);
    // reconfigure the resource group to run the second query
    dao.updateResourceGroup(5, "dashboard-${USER}", "1MB", 1, null, 1, null, null, null, null, null, null, null, null, 3L, TEST_ENVIRONMENT);
    reloadingConfigurationManager.load();
    // cancel the first one and let the second one start
    dispatchManager.cancelQuery(firstQuery);
    // wait until the second one is FAILED
    waitForQueryState(queryRunner, secondQuery, FAILED);
}
Also used : ReloadingResourceGroupConfigurationManager(com.facebook.presto.resourceGroups.reloading.ReloadingResourceGroupConfigurationManager) DispatchManager(com.facebook.presto.dispatcher.DispatchManager) QueryId(com.facebook.presto.spi.QueryId) QueryManager(com.facebook.presto.execution.QueryManager) InternalResourceGroupManager(com.facebook.presto.execution.resourceGroups.InternalResourceGroupManager) Test(org.testng.annotations.Test)

Aggregations

DispatchManager (com.facebook.presto.dispatcher.DispatchManager)12 QueryId (com.facebook.presto.spi.QueryId)7 Test (org.testng.annotations.Test)7 QueryManager (com.facebook.presto.execution.QueryManager)5 BasicQueryInfo (com.facebook.presto.server.BasicQueryInfo)4 TestingSessionContext (com.facebook.presto.execution.TestingSessionContext)3 InternalResourceGroupManager (com.facebook.presto.execution.resourceGroups.InternalResourceGroupManager)3 ReloadingResourceGroupConfigurationManager (com.facebook.presto.resourceGroups.reloading.ReloadingResourceGroupConfigurationManager)3 QueryInfo (com.facebook.presto.execution.QueryInfo)2 QueryState (com.facebook.presto.execution.QueryState)2 TestQueryRunnerUtil.waitForQueryState (com.facebook.presto.execution.TestQueryRunnerUtil.waitForQueryState)2 PrestoException (com.facebook.presto.spi.PrestoException)2 AfterMethod (org.testng.annotations.AfterMethod)2 Assertions (com.facebook.airlift.testing.Assertions)1 Session (com.facebook.presto.Session)1 SystemSessionProperties (com.facebook.presto.SystemSessionProperties)1 QUERY_MAX_MEMORY (com.facebook.presto.SystemSessionProperties.QUERY_MAX_MEMORY)1 VARCHAR (com.facebook.presto.common.type.VarcharType.VARCHAR)1 INFORMATION_SCHEMA (com.facebook.presto.connector.informationSchema.InformationSchemaMetadata.INFORMATION_SCHEMA)1 TestQueues.createResourceGroupId (com.facebook.presto.execution.TestQueues.createResourceGroupId)1