use of com.facebook.presto.server.BasicQueryInfo in project presto by prestodb.
the class TestMemoryManager method testNoLeak.
private void testNoLeak(@Language("SQL") String query) throws Exception {
Map<String, String> properties = ImmutableMap.<String, String>builder().put("task.verbose-stats", "true").build();
try (DistributedQueryRunner queryRunner = createQueryRunner(properties)) {
executor.submit(() -> queryRunner.execute(query)).get();
for (BasicQueryInfo info : queryRunner.getCoordinator().getQueryManager().getQueries()) {
assertEquals(info.getState(), FINISHED);
}
// Make sure we didn't leak any memory on the workers
for (TestingPrestoServer worker : queryRunner.getServers()) {
Optional<MemoryPool> reserved = worker.getLocalMemoryManager().getReservedPool();
assertTrue(reserved.isPresent());
assertEquals(reserved.get().getMaxBytes(), reserved.get().getFreeBytes());
MemoryPool general = worker.getLocalMemoryManager().getGeneralPool();
assertEquals(general.getMaxBytes(), general.getFreeBytes());
}
}
}
use of com.facebook.presto.server.BasicQueryInfo in project presto by prestodb.
the class TestQueryManager method testQueryScanExceeded.
@Test(timeOut = 60_000L)
public void testQueryScanExceeded() throws Exception {
try (DistributedQueryRunner queryRunner = TpchQueryRunnerBuilder.builder().setSingleExtraProperty("query.max-scan-raw-input-bytes", "0B").build()) {
QueryId queryId = createQuery(queryRunner, TEST_SESSION, "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_SCAN_RAW_BYTES_READ_LIMIT.toErrorCode());
}
}
use of com.facebook.presto.server.BasicQueryInfo in project presto by prestodb.
the class TestQueryManager method testQueryOutputSizeExceeded.
@Test(timeOut = 60_000L)
public void testQueryOutputSizeExceeded() throws Exception {
try (DistributedQueryRunner queryRunner = TpchQueryRunnerBuilder.builder().setSingleExtraProperty("query.max-output-size", "1B").build()) {
QueryId queryId = createQuery(queryRunner, TEST_SESSION, "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_OUTPUT_SIZE_LIMIT.toErrorCode());
}
}
use of com.facebook.presto.server.BasicQueryInfo in project presto by prestodb.
the class TestBrutalShutdown method testTransactionalQueryRetryOnShutdown.
@Test(timeOut = SHUTDOWN_TIMEOUT_MILLIS)
public void testTransactionalQueryRetryOnShutdown() throws Exception {
try (DistributedQueryRunner queryRunner = createQueryRunner(ImmutableMap.of())) {
executor.submit(() -> queryRunner.execute(TINY_SESSION, "START TRANSACTION")).get();
TransactionInfo transactionInfo = queryRunner.getCoordinator().getTransactionManager().getAllTransactionInfos().get(0);
Session session = testSessionBuilder().setCatalog("tpch").setSchema("tiny").setTransactionId(transactionInfo.getTransactionId()).build();
// only send 1 query as the first failed query will abort the transaction
queryRetryOnShutdown(session, queryRunner, executor, 1);
List<BasicQueryInfo> queryInfos = queryRunner.getCoordinator().getQueryManager().getQueries();
for (BasicQueryInfo info : queryInfos) {
if (info.getQuery().contains("-- retry query")) {
fail("no retry query is allowed within a transaction");
}
}
}
}
use of com.facebook.presto.server.BasicQueryInfo in project presto by prestodb.
the class TestBrutalShutdown method testQueryRetryOnShutdown.
@Test(timeOut = SHUTDOWN_TIMEOUT_MILLIS)
public void testQueryRetryOnShutdown() throws Exception {
int totalQueries = 5;
try (DistributedQueryRunner queryRunner = createQueryRunner(ImmutableMap.of())) {
queryRetryOnShutdown(TINY_SESSION, queryRunner, executor, totalQueries);
int totalSuccessfulQueries = 0;
List<BasicQueryInfo> queryInfos = queryRunner.getCoordinator().getQueryManager().getQueries();
for (BasicQueryInfo info : queryInfos) {
if (info.getQuery().contains("-- retry query")) {
assertEquals(info.getState(), FINISHED);
}
if (info.getState() == FINISHED) {
totalSuccessfulQueries++;
}
}
assertEquals(totalSuccessfulQueries, totalQueries);
}
}
Aggregations