Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add overload to SqlServerDbContextOptionsBuilder.EnableRetryOnFailure with errorNumbersToAdd without forcing maxRetryCount and maxRetryDelay #27135

Merged
merged 1 commit into from
Jan 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,26 @@ public virtual SqlServerDbContextOptionsBuilder EnableRetryOnFailure()
public virtual SqlServerDbContextOptionsBuilder EnableRetryOnFailure(int maxRetryCount)
=> ExecutionStrategy(c => new SqlServerRetryingExecutionStrategy(c, maxRetryCount));

/// <summary>
/// Configures the context to use the default retrying <see cref="IExecutionStrategy" />.
/// </summary>
/// <remarks>
/// <para>
/// This strategy is specifically tailored to SQL Server (including SQL Azure). It is pre-configured with
/// error numbers for transient errors that can be retried.
/// </para>
/// <para>
/// Default values of 6 for the maximum retry count and 30 seconds for the maximum default delay are used.
/// </para>
/// <para>
/// See <see href="https://aka.ms/efcore-docs-connection-resiliency">Connection resiliency and database retries</see>
/// for more information and examples.
/// </para>
/// </remarks>
/// <param name="errorNumbersToAdd">Additional SQL error numbers that should be considered transient.</param>
public virtual SqlServerDbContextOptionsBuilder EnableRetryOnFailure(ICollection<int> errorNumbersToAdd)
=> ExecutionStrategy(c => new SqlServerRetryingExecutionStrategy(c, errorNumbersToAdd));

/// <summary>
/// Configures the context to use the default retrying <see cref="IExecutionStrategy" />.
/// </summary>
Expand Down
15 changes: 15 additions & 0 deletions src/EFCore.SqlServer/SqlServerRetryingExecutionStrategy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,21 @@ public SqlServerRetryingExecutionStrategy(
{
}

/// <summary>
/// Creates a new instance of <see cref="SqlServerRetryingExecutionStrategy" />.
/// </summary>
/// <remarks>
/// Default values of 6 for the maximum retry count and 30 seconds for the maximum default delay are used.
/// </remarks>
/// <param name="dependencies">Parameter object containing service dependencies.</param>
/// <param name="errorNumbersToAdd">Additional SQL error numbers that should be considered transient.</param>
public SqlServerRetryingExecutionStrategy(
ExecutionStrategyDependencies dependencies,
ICollection<int> errorNumbersToAdd)
: this(dependencies, DefaultMaxRetryCount, DefaultMaxDelay, errorNumbersToAdd)
{
}

/// <summary>
/// Creates a new instance of <see cref="SqlServerRetryingExecutionStrategy" />.
/// </summary>
Expand Down