-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
GraphUpdatesSqlServerTest does not use retrying execution strategy #21463
Comments
@smitpatel @AndriySvyryd I have investigated this and it appears to be a product bug. Specifically, query looks up whether or not a retrying execution strategy is in use by looking at the execution strategy configured for the context: [EntityFrameworkInternal]
public CompiledQueryCacheKeyGeneratorDependencies(
[NotNull] IModel model,
[NotNull] ICurrentDbContext currentContext,
[NotNull] IExecutionStrategyFactory executionStrategyFactory)
{
Check.NotNull(model, nameof(model));
Check.NotNull(currentContext, nameof(currentContext));
Check.NotNull(executionStrategyFactory, nameof(executionStrategyFactory));
Model = model;
CurrentContext = currentContext;
IsRetryingExecutionStrategy = executionStrategyFactory.Create().RetriesOnFailure;
} However, if an external execution strategy has been created, then looking up Here's a stand-alone repro: public class Foo
{
public int Id { get; set; }
}
public class SomeDbContext : DbContext
{
private static ILoggerFactory ContextLoggerFactory
=> LoggerFactory.Create(b => b.AddConsole().SetMinimumLevel(LogLevel.Information));
public DbSet<Foo> Foos { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
=> optionsBuilder
//.UseSqlite("Data Source=test.db")
.UseSqlServer(Your.ConnectionString, b => b.ExecutionStrategy(d => new MySqlServerRetryingExecutionStrategyDi(d)))
.UseLoggerFactory(ContextLoggerFactory)
.EnableSensitiveDataLogging();
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
}
}
public class Program
{
public static async Task Main()
{
using (var context = new SomeDbContext())
{
await context.Database.EnsureDeletedAsync();
await context.Database.EnsureCreatedAsync();
context.Add(new Foo());
await context.SaveChangesAsync();
}
using (var context = new SomeDbContext())
{
var myExecutionStrategy = new MySqlServerRetryingExecutionStrategySo(context);
myExecutionStrategy.Execute(0, (c, s) => c.Set<Foo>().ToList(), null);
}
}
}
public class MySqlServerRetryingExecutionStrategyDi : SqlServerRetryingExecutionStrategy
{
public MySqlServerRetryingExecutionStrategyDi(ExecutionStrategyDependencies dependencies) : base(dependencies)
{
}
public override bool RetriesOnFailure
{
get
{
Console.WriteLine("Calling RetriesOnFailure on D.I. execution strategy");
return base.RetriesOnFailure;
}
}
}
public class MySqlServerRetryingExecutionStrategySo : SqlServerRetryingExecutionStrategy
{
public MySqlServerRetryingExecutionStrategySo(DbContext context) : base(context)
{
}
public override bool RetriesOnFailure
{
get
{
Console.WriteLine("Calling RetriesOnFailure on stand-alone execution strategy");
return base.RetriesOnFailure;
}
}
} Output:
|
See #21441
The text was updated successfully, but these errors were encountered: