dotnet data_error ai_generated partial

Microsoft.EntityFrameworkCore.Storage.RetryLimitExceededException: The execution strategy 'SqlServerRetryingExecutionStrategy' executed the operation 6 time(s) without success.

ID: dotnet/ef-core-connection-resiliency-failed-to-retry

Also available as: JSON · Markdown · 中文
85%Fix Rate
82%Confidence
1Evidence
2023-03-15First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
Entity Framework Core 6.0.x active
Entity Framework Core 7.0.x active
Entity Framework Core 8.0.x active

Root Cause

Entity Framework Core's retry execution strategy exhausted its retry attempts due to persistent transient faults like deadlocks, timeouts, or network blips from SQL Server.

generic

中文

Entity Framework Core 的重试执行策略因 SQL Server 的持久性瞬时故障(如死锁、超时或网络波动)而耗尽重试次数。

Official Documentation

https://learn.microsoft.com/en-us/ef/core/miscellaneous/connection-resiliency

Workarounds

  1. 75% success Analyze SQL Server error logs for deadlocks or timeouts; optimize queries or indexes to reduce contention.
    Analyze SQL Server error logs for deadlocks or timeouts; optimize queries or indexes to reduce contention.
  2. 85% success Reduce retry interval and increase max retry count with exponential backoff in DbContext options.
    Reduce retry interval and increase max retry count with exponential backoff in DbContext options.
  3. 70% success Implement custom execution strategy to log and handle specific transient exceptions like deadlock (1205).
    Implement custom execution strategy to log and handle specific transient exceptions like deadlock (1205).

中文步骤

  1. Analyze SQL Server error logs for deadlocks or timeouts; optimize queries or indexes to reduce contention.
  2. Reduce retry interval and increase max retry count with exponential backoff in DbContext options.
  3. Implement custom execution strategy to log and handle specific transient exceptions like deadlock (1205).

Dead Ends

Common approaches that don't work:

  1. 90% fail

    Increasing retry count without addressing root cause just delays failure.

  2. 95% fail

    Disabling retry entirely makes app brittle to transient faults.

  3. 80% fail

    Switching to a different execution strategy doesn't fix underlying database issues.