Retries and transient errors

Which transaction errors are retried and how.

Retry a transaction when it fails with a transient error. The drivers do it for you with withTransaction.

Requirements

The labels

LabelWhat to do
TransientTransactionErrorRetry the whole transaction from the start.
UnknownTransactionCommitResultRetry only commitTransaction; you do not know if it committed.

With withTransaction

withTransaction retries what it must according to those labels. If you write the loop yourself, look at the label of the error and not at the code.

Check

With two clients writing the same document at once, both end up committing thanks to the retries.

Common problems

  • A statement that finds a version inside its uncertainty window fails with WriteConflict; it is solved the same way, by retrying.

See also