use of com.facebook.presto.execution.QueryManager in project presto by prestodb.
the class TestQueues method testRejection.
@Test(timeOut = 240_000)
public void testRejection() throws Exception {
String dbConfigUrl = getDbConfigUrl();
H2ResourceGroupsDao dao = getDao(dbConfigUrl);
try (DistributedQueryRunner queryRunner = createQueryRunner(dbConfigUrl, dao)) {
// Verify the query cannot be submitted
QueryId queryId = createQuery(queryRunner, newRejectionSession(), LONG_LASTING_QUERY);
waitForQueryState(queryRunner, queryId, FAILED);
QueryManager queryManager = queryRunner.getCoordinator().getQueryManager();
assertEquals(queryManager.getQueryInfo(queryId).getErrorCode(), QUERY_REJECTED.toErrorCode());
int selectorCount = getSelectors(queryRunner).size();
dao.insertSelector(4, "user.*", "(?i).*reject.*");
assertEquals(dao.getSelectors().size(), selectorCount + 1);
//MILLISECONDS.sleep(2000);
do {
MILLISECONDS.sleep(500);
} while (getSelectors(queryRunner).size() == selectorCount);
// Verify the query can be submitted
queryId = createQuery(queryRunner, newRejectionSession(), LONG_LASTING_QUERY);
waitForQueryState(queryRunner, queryId, RUNNING);
dao.deleteSelector(4, "user.*", "(?i).*reject.*");
do {
MILLISECONDS.sleep(500);
} while (getSelectors(queryRunner).size() != selectorCount);
// Verify the query cannot be submitted
queryId = createQuery(queryRunner, newRejectionSession(), LONG_LASTING_QUERY);
waitForQueryState(queryRunner, queryId, FAILED);
}
}
use of com.facebook.presto.execution.QueryManager in project presto by prestodb.
the class TestResourceGroupPerQueryLimitEnforcement method testQueryMemoryLimit.
@Test(timeOut = 60_000L)
public void testQueryMemoryLimit() throws Exception {
QueryId queryId = createQuery(queryRunner, testSessionBuilder().setCatalog("tpch").setSchema(TINY_SCHEMA_NAME).setSource("per_query_memory_limit_test").build(), "SELECT COUNT(*) FROM lineitem");
waitForQueryState(queryRunner, queryId, FAILED);
QueryManager queryManager = queryRunner.getCoordinator().getQueryManager();
BasicQueryInfo queryInfo = queryManager.getQueryInfo(queryId);
assertEquals(queryInfo.getState(), FAILED);
assertEquals(queryInfo.getErrorCode(), EXCEEDED_GLOBAL_MEMORY_LIMIT.toErrorCode());
assertTrue(queryInfo.getFailureInfo().getMessage().contains(RESOURCE_GROUP.name()));
}
use of com.facebook.presto.execution.QueryManager in project presto by prestodb.
the class TestResourceGroupPerQueryLimitEnforcement method testQueryCpuLimit.
@Test(timeOut = 60_000L)
public void testQueryCpuLimit() throws Exception {
QueryId queryId = createQuery(queryRunner, testSessionBuilder().setCatalog("tpch").setSchema(TINY_SCHEMA_NAME).setSource("per_query_cpu_limit_test").build(), "SELECT COUNT(*) FROM lineitem");
waitForQueryState(queryRunner, queryId, FAILED);
QueryManager queryManager = queryRunner.getCoordinator().getQueryManager();
BasicQueryInfo queryInfo = queryManager.getQueryInfo(queryId);
assertEquals(queryInfo.getState(), FAILED);
assertEquals(queryInfo.getErrorCode(), EXCEEDED_CPU_LIMIT.toErrorCode());
assertTrue(queryInfo.getFailureInfo().getMessage().contains(RESOURCE_GROUP.name()));
}
use of com.facebook.presto.execution.QueryManager in project presto by prestodb.
the class TestResourceGroupPerQueryLimitEnforcement method testQueryExecutionTimeLimit.
@Test(timeOut = 60_000L)
public void testQueryExecutionTimeLimit() throws Exception {
QueryId queryId = createQuery(queryRunner, testSessionBuilder().setCatalog("tpch").setSchema(TINY_SCHEMA_NAME).setSource("per_query_execution_time_limit_test").build(), "SELECT COUNT(*) FROM lineitem");
waitForQueryState(queryRunner, queryId, FAILED);
QueryManager queryManager = queryRunner.getCoordinator().getQueryManager();
BasicQueryInfo queryInfo = queryManager.getQueryInfo(queryId);
assertEquals(queryInfo.getState(), FAILED);
assertEquals(queryInfo.getErrorCode(), EXCEEDED_TIME_LIMIT.toErrorCode());
assertTrue(queryInfo.getFailureInfo().getMessage().contains(RESOURCE_GROUP.name()));
}
use of com.facebook.presto.execution.QueryManager in project presto by prestodb.
the class TestQueuesDb method testSelectorPriority.
@Test(timeOut = 60_000)
public void testSelectorPriority() throws Exception {
InternalResourceGroupManager manager = queryRunner.getCoordinator().getResourceGroupManager().get();
QueryManager queryManager = queryRunner.getCoordinator().getQueryManager();
ReloadingResourceGroupConfigurationManager reloadingConfigurationManager = (ReloadingResourceGroupConfigurationManager) manager.getConfigurationManager();
QueryId firstQuery = createQuery(queryRunner, dashboardSession(), LONG_LASTING_QUERY);
waitForQueryState(queryRunner, firstQuery, RUNNING);
Optional<ResourceGroupId> resourceGroup = queryManager.getFullQueryInfo(firstQuery).getResourceGroupId();
assertTrue(resourceGroup.isPresent());
assertEquals(resourceGroup.get().toString(), "global.user-user.dashboard-user");
// create a new resource group that rejects all queries submitted to it
dao.insertResourceGroup(10, "reject-all-queries", "1MB", 0, 0, 0, null, null, null, null, null, null, null, null, 3L, TEST_ENVIRONMENT);
// add a new selector that has a higher priority than the existing dashboard selector and that routes queries to the "reject-all-queries" resource group
dao.insertSelector(10, 200, "user.*", "(?i).*dashboard.*", null, null, null);
// reload the configuration
reloadingConfigurationManager.load();
QueryId secondQuery = createQuery(queryRunner, dashboardSession(), LONG_LASTING_QUERY);
waitForQueryState(queryRunner, secondQuery, FAILED);
DispatchManager dispatchManager = queryRunner.getCoordinator().getDispatchManager();
BasicQueryInfo basicQueryInfo = dispatchManager.getQueryInfo(secondQuery);
assertEquals(basicQueryInfo.getErrorCode(), QUERY_QUEUE_FULL.toErrorCode());
}
Aggregations