Class DeadlockRetryHelper
Retries an async operation on SQL deadlock (MsSql error 1205, Postgres state 40P01).
Cluster-safe: each connection independently detects and retries.
Never retries inside an ambient : the server has already rolled
the deadlock victim's transaction back, so the command run again inside it fails with a second error (PostgreSQL
25P02, an aborted transaction on SQL Server) that replaces the deadlock. The original leaves at once, and the unit
of work that owns the transaction runs it again.
public static class DeadlockRetryHelper
Inheritance
Methods
ExecuteWithRetryAsync(Func<Task>, int, int, CancellationToken)
public static Task ExecuteWithRetryAsync(Func<Task> operation, int maxRetries = 3, int baseDelayMs = 50, CancellationToken cancellationToken = default)
ExecuteWithRetryAsync<T>(Func<Task<T>>, int, int, CancellationToken)
public static Task<T> ExecuteWithRetryAsync<T>(Func<Task<T>> operation, int maxRetries = 3, int baseDelayMs = 50, CancellationToken cancellationToken = default)