use of io.prestosql.spi.QueryId in project hetu-core by openlookeng.
the class TestQueuesDb method testTwoQueriesAtSameTime.
@Test(timeOut = 60_000)
public void testTwoQueriesAtSameTime() throws Exception {
QueryId firstDashboardQuery = createQuery(queryRunner, dashboardSession(), LONG_LASTING_QUERY);
QueryId secondDashboardQuery = createQuery(queryRunner, dashboardSession(), LONG_LASTING_QUERY);
waitForQueryState(queryRunner, firstDashboardQuery, RUNNING);
waitForQueryState(queryRunner, secondDashboardQuery, QUEUED);
}
use of io.prestosql.spi.QueryId in project hetu-core by openlookeng.
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();
DbResourceGroupConfigurationManager dbConfigurationManager = (DbResourceGroupConfigurationManager) 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
// Hetu: add parameters softReservedMemory and hardReservedConcurrency
dao.updateResourceGroup(5, "dashboard-${USER}", "1MB", "1MB", 1, null, 0, 0, null, null, null, null, null, "RECENT_QUERIES", 3L, TEST_ENVIRONMENT);
dbConfigurationManager.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
// Hetu: add parameters softReservedMemory and hardReservedConcurrency
dao.updateResourceGroup(5, "dashboard-${USER}", "1MB", "1MB", 1, null, 1, 0, null, null, null, null, null, "RECENT_QUERIES", 3L, TEST_ENVIRONMENT);
dbConfigurationManager.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);
}
use of io.prestosql.spi.QueryId in project hetu-core by openlookeng.
the class TestQueuesDb method testQueryTypeBasedSelection.
@Test
public void testQueryTypeBasedSelection() throws InterruptedException {
Session session = testSessionBuilder().setCatalog("tpch").setSchema("sf100000").build();
QueryId queryId = createQuery(queryRunner, session, "EXPLAIN " + LONG_LASTING_QUERY);
waitForQueryState(queryRunner, queryId, ImmutableSet.of(RUNNING, FINISHED));
Optional<ResourceGroupId> resourceGroupId = queryRunner.getCoordinator().getQueryManager().getFullQueryInfo(queryId).getResourceGroupId();
assertTrue(resourceGroupId.isPresent(), "Query should have a resource group");
assertEquals(resourceGroupId.get(), createResourceGroupId("explain"));
}
use of io.prestosql.spi.QueryId in project hetu-core by openlookeng.
the class TestQueues method testResourceGroupManagerWithTwoDashboardQueriesRequestedAtTheSameTime.
@Test(timeOut = 240_000)
public void testResourceGroupManagerWithTwoDashboardQueriesRequestedAtTheSameTime() 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 firstDashboardQuery = createDashboardQuery(queryRunner);
QueryId secondDashboardQuery = createDashboardQuery(queryRunner);
ImmutableSet<QueryState> queuedOrRunning = ImmutableSet.of(QUEUED, RUNNING);
waitForQueryState(queryRunner, firstDashboardQuery, queuedOrRunning);
waitForQueryState(queryRunner, secondDashboardQuery, queuedOrRunning);
}
}
use of io.prestosql.spi.QueryId in project hetu-core by openlookeng.
the class TestMemoryTracking method setUpTest.
@BeforeMethod
public void setUpTest() {
memoryPool = new MemoryPool(new MemoryPoolId("test"), memoryPoolSize);
queryContext = new QueryContext(new QueryId("test_query"), queryMaxMemory, queryMaxTotalMemory, memoryPool, new TestingGcMonitor(), notificationExecutor, yieldExecutor, queryMaxSpillSize, spillSpaceTracker, NOOP_SNAPSHOT_UTILS);
taskContext = queryContext.addTaskContext(new TaskStateMachine(new TaskId("query", 0, 0), notificationExecutor), testSessionBuilder().build(), true, true, OptionalInt.empty(), Optional.empty(), TESTING_SERDE_FACTORY);
pipelineContext = taskContext.addPipelineContext(0, true, true, false);
driverContext = pipelineContext.addDriverContext();
operatorContext = driverContext.addOperatorContext(1, new PlanNodeId("a"), "test-operator");
}
Aggregations