use of com.facebook.presto.transaction.TransactionInfo 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.transaction.TransactionInfo in project presto by prestodb.
the class TestStartTransactionTask method testStartTransaction.
@Test
public void testStartTransaction() {
Session session = sessionBuilder().setClientTransactionSupport().build();
TransactionManager transactionManager = createTestTransactionManager();
QueryStateMachine stateMachine = createQueryStateMachine("START TRANSACTION", session, true, transactionManager, executor, metadata);
assertFalse(stateMachine.getSession().getTransactionId().isPresent());
StartTransactionTask startTransactionTask = new StartTransactionTask();
getFutureValue(startTransactionTask.execute(new StartTransaction(ImmutableList.of()), transactionManager, metadata, new AllowAllAccessControl(), stateMachine, emptyList()));
assertFalse(stateMachine.getQueryInfo(Optional.empty()).isClearTransactionId());
assertTrue(stateMachine.getQueryInfo(Optional.empty()).getStartedTransactionId().isPresent());
assertEquals(transactionManager.getAllTransactionInfos().size(), 1);
TransactionInfo transactionInfo = transactionManager.getTransactionInfo(stateMachine.getQueryInfo(Optional.empty()).getStartedTransactionId().get());
assertFalse(transactionInfo.isAutoCommitContext());
}
use of com.facebook.presto.transaction.TransactionInfo in project presto by prestodb.
the class TestStartTransactionTask method testStartTransactionExplicitModes.
@Test
public void testStartTransactionExplicitModes() {
Session session = sessionBuilder().setClientTransactionSupport().build();
TransactionManager transactionManager = createTestTransactionManager();
QueryStateMachine stateMachine = createQueryStateMachine("START TRANSACTION", session, true, transactionManager, executor, metadata);
assertFalse(stateMachine.getSession().getTransactionId().isPresent());
StartTransactionTask startTransactionTask = new StartTransactionTask();
getFutureValue(startTransactionTask.execute(new StartTransaction(ImmutableList.of(new Isolation(Isolation.Level.SERIALIZABLE), new TransactionAccessMode(true))), transactionManager, metadata, new AllowAllAccessControl(), stateMachine, emptyList()));
assertFalse(stateMachine.getQueryInfo(Optional.empty()).isClearTransactionId());
assertTrue(stateMachine.getQueryInfo(Optional.empty()).getStartedTransactionId().isPresent());
assertEquals(transactionManager.getAllTransactionInfos().size(), 1);
TransactionInfo transactionInfo = transactionManager.getTransactionInfo(stateMachine.getQueryInfo(Optional.empty()).getStartedTransactionId().get());
assertEquals(transactionInfo.getIsolationLevel(), IsolationLevel.SERIALIZABLE);
assertTrue(transactionInfo.isReadOnly());
assertFalse(transactionInfo.isAutoCommitContext());
}
Aggregations