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

[release/8.0] Revert Azure SQL streaming breaking change #32069

Merged
merged 1 commit into from
Oct 17, 2023
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 @@ -114,12 +114,7 @@ public virtual SqlServerOptionsExtension WithCompatibilityLevel(int? compatibili
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public virtual bool IsAzureSql
=> _azureSql ?? IsAzureSqlDefault;

private bool IsAzureSqlDefault
=> (ConnectionString ?? Connection?.ConnectionString)
?.Contains(".database.windows.net", StringComparison.InvariantCultureIgnoreCase)
== true;
=> _azureSql ?? false;

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
Expand Down
6 changes: 3 additions & 3 deletions src/EFCore.SqlServer/SqlServerRetryingExecutionStrategy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ public class SqlServerRetryingExecutionStrategy : ExecutionStrategy
private readonly HashSet<int>? _additionalErrorNumbers;

/// <summary>
/// The default minimum time delay between retries for Azure SQL.
/// The default minimum time delay between retries for throttling errors.
/// </summary>
protected static readonly TimeSpan DefaultMinDelayAzureSql = TimeSpan.FromSeconds(5);
protected static readonly TimeSpan DefaultMinDelayThrottling = TimeSpan.FromSeconds(5);

/// <summary>
/// Creates a new instance of <see cref="SqlServerRetryingExecutionStrategy" />.
Expand Down Expand Up @@ -193,7 +193,7 @@ protected override bool ShouldRetryOn(Exception exception)
return CallOnWrappedException(lastException, IsMemoryOptimizedError)
? TimeSpan.FromMilliseconds(baseDelay.Value.TotalSeconds)
: CallOnWrappedException(lastException, IsThrottlingError)
? baseDelay + DefaultMinDelayAzureSql
? baseDelay + DefaultMinDelayThrottling
: baseDelay;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -462,26 +462,20 @@ public class AzureSqlDatabase
[InlineData(true)]
[InlineData(false)]
[ConditionalTheory]
public void Retry_on_failure_enabled_by_default_on_Azure_SQL(bool azure)
public void Retry_on_failure_not_enabled_by_default_on_Azure_SQL(bool configured)
{
using var context = new NorthwindContext(azure);
if (azure)
{
Assert.IsType<SqlServerRetryingExecutionStrategy>(context.Database.CreateExecutionStrategy());
}
else
{
Assert.IsType<SqlServerExecutionStrategy>(context.Database.CreateExecutionStrategy());
}
using var context = new NorthwindContext(configured);

Assert.IsType<SqlServerExecutionStrategy>(context.Database.CreateExecutionStrategy());
}

private class NorthwindContext : DbContext
{
private readonly bool _isAzure;
private readonly bool _azureConfigured;

public NorthwindContext(bool azure)
public NorthwindContext(bool configured)
{
_isAzure = azure;
_azureConfigured = configured;
}

public DbSet<Customer> Customers { get; set; }
Expand All @@ -493,7 +487,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
@"Server=test.database.windows.net:4040;Database=Test;ConnectRetryCount=0",
a =>
{
if (!_isAzure)
if (_azureConfigured)
{
a.UseAzureSqlDefaults(false);
}
Expand All @@ -509,10 +503,10 @@ public class NonDefaultAzureSqlDatabase
[InlineData(true)]
[InlineData(false)]
[ConditionalTheory]
public void Retry_on_failure_enabled_if_Azure_SQL_configured(bool azure)
public void Retry_on_failure_enabled_if_Azure_SQL_configured(bool configured)
{
using var context = new NorthwindContext(azure);
if (azure)
using var context = new NorthwindContext(configured);
if (configured)
{
Assert.IsType<SqlServerRetryingExecutionStrategy>(context.Database.CreateExecutionStrategy());
}
Expand Down
Loading