Search in sources :

Example 6 with BasicQueryInfo

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());
        }
    }
}
Also used : DistributedQueryRunner(com.facebook.presto.tests.DistributedQueryRunner) BasicQueryInfo(com.facebook.presto.server.BasicQueryInfo) TestingPrestoServer(com.facebook.presto.server.testing.TestingPrestoServer)

Example 7 with BasicQueryInfo

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());
    }
}
Also used : QueryId(com.facebook.presto.spi.QueryId) BasicQueryInfo(com.facebook.presto.server.BasicQueryInfo) QueryManager(com.facebook.presto.execution.QueryManager) Test(org.testng.annotations.Test)

Example 8 with BasicQueryInfo

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());
    }
}
Also used : QueryId(com.facebook.presto.spi.QueryId) BasicQueryInfo(com.facebook.presto.server.BasicQueryInfo) QueryManager(com.facebook.presto.execution.QueryManager) Test(org.testng.annotations.Test)

Example 9 with BasicQueryInfo

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");
            }
        }
    }
}
Also used : BasicQueryInfo(com.facebook.presto.server.BasicQueryInfo) TransactionInfo(com.facebook.presto.transaction.TransactionInfo) Session(com.facebook.presto.Session) Test(org.testng.annotations.Test)

Example 10 with BasicQueryInfo

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);
    }
}
Also used : BasicQueryInfo(com.facebook.presto.server.BasicQueryInfo) Test(org.testng.annotations.Test)

Aggregations

BasicQueryInfo (com.facebook.presto.server.BasicQueryInfo)32 Test (org.testng.annotations.Test)19 QueryId (com.facebook.presto.spi.QueryId)12 QueryManager (com.facebook.presto.execution.QueryManager)9 TestingPrestoServer (com.facebook.presto.server.testing.TestingPrestoServer)4 Session (com.facebook.presto.Session)3 DispatchManager (com.facebook.presto.dispatcher.DispatchManager)3 ExecutionFailureInfo (com.facebook.presto.execution.ExecutionFailureInfo)3 QueryInfo (com.facebook.presto.execution.QueryInfo)3 PrestoException (com.facebook.presto.spi.PrestoException)3 DistributedQueryRunner (com.facebook.presto.tests.DistributedQueryRunner)3 ImmutableList (com.google.common.collect.ImmutableList)2 Connection (java.sql.Connection)2 ResultSet (java.sql.ResultSet)2 Statement (java.sql.Statement)2 ArrayList (java.util.ArrayList)2 GET (javax.ws.rs.GET)2 Assertions (com.facebook.airlift.testing.Assertions)1 SystemSessionProperties (com.facebook.presto.SystemSessionProperties)1 QUERY_MAX_MEMORY (com.facebook.presto.SystemSessionProperties.QUERY_MAX_MEMORY)1