use of com.palantir.atlasdb.cassandra.backup.transaction.TransactionTableEntry in project atlasdb by palantir.
the class TransactionAborter method tryAbortTransactions.
private boolean tryAbortTransactions(String keyspace, TransactionsTableInteraction txnInteraction, Statement abortStatement, Statement checkStatement, long startTs, long commitTs) {
log.info("Aborting transaction", SafeArg.of("startTs", startTs), SafeArg.of("commitTs", commitTs), SafeArg.of("keyspace", keyspace));
ResultSet abortResultSet = cqlSession.execute(abortStatement);
if (abortResultSet.wasApplied()) {
return true;
}
log.debug("Executing check statement", SafeArg.of("startTs", startTs), SafeArg.of("commitTs", commitTs), SafeArg.of("keyspace", keyspace));
ResultSet checkResultSet = cqlSession.execute(checkStatement);
Row result = Iterators.getOnlyElement(checkResultSet.all().iterator());
TransactionTableEntry transactionTableEntry = txnInteraction.extractTimestamps(result);
if (isAborted(transactionTableEntry)) {
return true;
}
log.warn("Retrying abort statement", SafeArg.of("startTs", startTs), SafeArg.of("commitTs", commitTs), SafeArg.of("keyspace", keyspace));
return false;
}
use of com.palantir.atlasdb.cassandra.backup.transaction.TransactionTableEntry in project atlasdb by palantir.
the class TransactionAborter method abortTransactions.
private void abortTransactions(CqlMetadata clusterMetadata, String keyspaceName, long timestamp, TransactionsTableInteraction txnInteraction) {
log.info("Aborting transactions after backup timestamp", SafeArg.of("backupTimestamp", timestamp), SafeArg.of("keyspace", keyspaceName), SafeArg.of("table", txnInteraction.getTransactionsTableName()));
TableMetadata transactionsTable = ClusterMetadataUtils.getTableMetadata(clusterMetadata, keyspaceName, txnInteraction.getTransactionsTableName());
PreparedStatement preparedAbortStatement = txnInteraction.prepareAbortStatement(transactionsTable, cqlSession);
PreparedStatement preparedCheckStatement = txnInteraction.prepareCheckStatement(transactionsTable, cqlSession);
Stream<TransactionTableEntry> keysToAbort = getTransactionsToAbort(keyspaceName, txnInteraction, transactionsTable, timestamp);
executeTransactionAborts(keyspaceName, txnInteraction, preparedAbortStatement, preparedCheckStatement, keysToAbort);
}
use of com.palantir.atlasdb.cassandra.backup.transaction.TransactionTableEntry in project atlasdb by palantir.
the class TransactionAborterTest method executeWithRetryTriesSingleTimeIfAbortSucceeds.
@Test
public void executeWithRetryTriesSingleTimeIfAbortSucceeds() {
ResultSet abortResponse = createAbortResponse(true);
when(cqlSession.execute(abortStatement)).thenReturn(abortResponse);
Stream<TransactionTableEntry> entries = Stream.of(TransactionTableEntries.committedLegacy(100L, 101L));
transactionAborter.executeTransactionAborts(transactionInteraction, preparedAbortStatement, preparedCheckStatement, entries);
verify(cqlSession).execute(abortStatement);
}
use of com.palantir.atlasdb.cassandra.backup.transaction.TransactionTableEntry in project atlasdb by palantir.
the class TransactionAborter method abortTransactions.
private void abortTransactions(CqlMetadata clusterMetadata, long timestamp, TransactionsTableInteraction txnInteraction) {
log.info("Aborting transactions after backup timestamp", SafeArg.of("backupTimestamp", timestamp), SafeArg.of("keyspace", namespace), SafeArg.of("table", txnInteraction.getTransactionsTableName()));
TableMetadata transactionsTable = ClusterMetadataUtils.getTableMetadata(clusterMetadata, namespace, txnInteraction.getTransactionsTableName());
PreparedStatement preparedAbortStatement = txnInteraction.prepareAbortStatement(transactionsTable, cqlSession);
PreparedStatement preparedCheckStatement = txnInteraction.prepareCheckStatement(transactionsTable, cqlSession);
Stream<TransactionTableEntry> keysToAbort = getTransactionsToAbort(txnInteraction, transactionsTable, timestamp);
executeTransactionAborts(txnInteraction, preparedAbortStatement, preparedCheckStatement, keysToAbort);
}
Aggregations