final class DeadlockRetry (View source)

Re-runs a whole transaction the database rolled back because it lost a lock race.

Only for callers that own the transaction: a deadlock victim is rolled back as a whole, so the attempt must begin and commit it again, and an outer transaction cannot be replayed.

Constants

MAX_ATTEMPTS

private SQLSTATES

SQLSTATE values for a serialization failure (MySQL, PostgreSQL) and a PostgreSQL deadlock.

private DRIVER_CODES

MySQL driver code for a deadlock; a lock wait timeout (1205) already cost a full wait, so it is not replayed.

Methods

static mixed
run(callable $attempt, callable|null $pause = null, int $maxAttempts = self::MAX_ATTEMPTS)

No description

static bool
isRetryable(Throwable $e)

No description

Details

static mixed run(callable $attempt, callable|null $pause = null, int $maxAttempts = self::MAX_ATTEMPTS)

No description

Parameters

callable $attempt

Begins, runs and commits the transaction, rolling back on failure

callable|null $pause

Waits before the given retry number; null sleeps with jitter

int $maxAttempts

Return Value

mixed

static bool isRetryable(Throwable $e)

No description

Parameters

Throwable $e

Return Value

bool