Skip to content

Commit

Permalink
Revert Azure SQL streaming breaking change (#32069)
Browse files Browse the repository at this point in the history
Fixes #32052
  • Loading branch information
AndriySvyryd authored Oct 17, 2023
1 parent 80c7aa0 commit 39da9a7
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 26 deletions.
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

0 comments on commit 39da9a7

Please sign in to comment.