Interface RetryPolicy.Condition

Enclosing class:
RetryPolicy
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

Determines whether a failed transaction attempt should be retried.

Implementations should be thread-safe if the RetryPolicy is shared across threads.

Since:
4.4.0
Author:
Mark Allen
  • Method Details

    • shouldRetry

      @NonNull Boolean shouldRetry(@NonNull DatabaseException failure)
      Determines whether a failed transaction attempt should be retried.
      Parameters:
      failure - the database failure that caused the transaction attempt to fail
      Returns:
      true to retry, false to stop retrying
    • serializationFailureOrDeadlock

      Creates a condition that retries serialization failures and deadlocks.
      Returns:
      a serialization-failure-or-deadlock retry condition
    • serializationFailure

      Creates a condition that retries serialization failures.
      Returns:
      a serialization-failure retry condition
    • deadlock

      static @NonNull RetryPolicy.Condition deadlock()
      Creates a condition that retries deadlocks.
      Returns:
      a deadlock retry condition
    • timeout

      static @NonNull RetryPolicy.Condition timeout()
      Creates a condition that retries timeouts and cancellations recognized by Pyranid.

      Timeouts and cancellations are not always safe to retry: the database may have completed part or all of the work before the timeout surfaced to the caller. Use this condition only when the retried transaction body is safe to run more than once for the application workflow.

      Returns:
      a timeout retry condition