Interface TransactionRetryListener (6.87.0)

public interface TransactionRetryListener

Cloud Spanner can abort any read/write transaction because of potential deadlocks or other internal reasons. When a transaction is aborted, the entire transaction should be retried. A Connection can automatically retry a transaction internally and check whether the results that are returned during a retry attempt are equal to the results during the original transaction. This is done by keeping track of a SHA-256 checksum of all the results that are returned by Spanner during both transactions.

This listener class for internal transaction retries allow client applications to do additional testing or logging of transaction retries. Transaction retry listeners of a Connection can be added using Connection#addTransactionRetryListener(TransactionRetryListener).

Methods

retryDmlAsPartitionedDmlFailed(UUID executionId, Statement statement, Throwable exception)

public default void retryDmlAsPartitionedDmlFailed(UUID executionId, Statement statement, Throwable exception)

This method is called when an atomic DML statement failed to be retried as a Partitioned DML statement.

Parameters
NameDescription
executionIdUUID

the unique ID of this statement execution

statementStatement

the statement that failed to be retried as Partitioned DML

exceptionThrowable

the exception that was returned when the statement was executed as Partitioned DML

retryDmlAsPartitionedDmlFinished(UUID executionId, Statement statement, long lowerBoundUpdateCount)

public default void retryDmlAsPartitionedDmlFinished(UUID executionId, Statement statement, long lowerBoundUpdateCount)

This method is called when an atomic DML statement has been successfully retried as a Partitioned DML statement.

Parameters
NameDescription
executionIdUUID

the unique ID of this statement execution

statementStatement

the statement that was successfully retried as Partitioned DML

lowerBoundUpdateCountlong

the lower-bound update count returned by Spanner after executing the statement as Partitioned DML

retryDmlAsPartitionedDmlStarting(UUID executionId, Statement statement, TransactionMutationLimitExceededException exception)

public default void retryDmlAsPartitionedDmlStarting(UUID executionId, Statement statement, TransactionMutationLimitExceededException exception)

This method is called when an atomic DML statement is retried as a Partitioned DML statement.

Parameters
NameDescription
executionIdUUID

a generated, unique ID for this execution. The same ID is passed in to the methods #retryDmlAsPartitionedDmlFinished(UUID, Statement, long) and #retryDmlAsPartitionedDmlFailed(UUID, Statement, Throwable) when the execution finishes or fails.

statementStatement

the statement that is being retried as Partitioned DML

exceptionTransactionMutationLimitExceededException

the mutation-limit-exceeded exception that was returned by Spanner during the initial execution.

retryFinished(Timestamp transactionStarted, long transactionId, int retryAttempt, TransactionRetryListener.RetryResult result)

public abstract void retryFinished(Timestamp transactionStarted, long transactionId, int retryAttempt, TransactionRetryListener.RetryResult result)

This method is called when a retry has finished.

Parameters
NameDescription
transactionStartedcom.google.cloud.Timestamp

The start date/time of the transaction that is retrying.

transactionIdlong

An internally assigned ID of the transaction (unique during the lifetime of the JVM) that can be used to identify the transaction for logging purposes.

retryAttemptint

The number of retry attempts the current transaction has executed, including the current retry attempt.

resultTransactionRetryListener.RetryResult

The result of the retry indicating whether the retry was successful or not.

retryStarting(Timestamp transactionStarted, long transactionId, int retryAttempt)

public abstract void retryStarting(Timestamp transactionStarted, long transactionId, int retryAttempt)

This method is called when a retry is about to start.

Parameters
NameDescription
transactionStartedcom.google.cloud.Timestamp

The start date/time of the transaction that is retrying.

transactionIdlong

An internally assigned ID of the transaction (unique during the lifetime of the JVM) that can be used to identify the transaction for logging purposes.

retryAttemptint

The number of retry attempts the current transaction has executed, including the current retry attempt.