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

Migrate to SQL Azure retry execution strategy #19898

Closed
gazoonie opened this issue Feb 12, 2020 · 3 comments
Closed

Migrate to SQL Azure retry execution strategy #19898

gazoonie opened this issue Feb 12, 2020 · 3 comments
Labels
closed-no-further-action The issue is closed and no further action is planned. customer-reported

Comments

@gazoonie
Copy link

gazoonie commented Feb 12, 2020

We are attempting to handle transient errors when applying a migration to a SQL Azure database.

The problem is that the Max Retry Count is not being applied per command, but for the entire migration process. Our max retry count is set to 5 and I'll see in our logs where four separate commands are retried, but the 5th exception kills the process. Most of the time the migration is successful, but maybe every 6th time results in failure.

Here is what the execution strategy looks like:

IExecutionStrategy strategy = dbContext.Database.CreateExecutionStrategy();
await strategy.ExecuteAsync(async () =>
{
    await dbContext.GetService<IMigrator>().MigrateAsync(migrationId);
});

What is the recommended retry execution strategy for migrations?

Steps to reproduce

I can't think of any valuable repro steps to provide that will help further clarify the issue.
Here are the logs (trimmed for brevity and edited for privacy)
Migration Logs.txt

Further technical details

The migration is kicked off as a job in Kubernetes.

EF Core version: 3.1.1
Database provider: SQL Azure database within a Standard Tier Elastic Pool
Target framework: .NET Core 3.1
Operating system: Windows 10 Enterprise
IDE: Visual Studio 2019 16.4.5

@AndriySvyryd
Copy link
Member

You can always create a different execution strategy for a given operation:

IExecutionStrategy strategy = new SqlServerRetryingExecutionStrategy(dbContext, maxRetryCount: 10);

@AndriySvyryd AndriySvyryd added closed-no-further-action The issue is closed and no further action is planned. and removed type-bug labels Feb 13, 2020
@gazoonie
Copy link
Author

So you're telling me to just add more retry attempts? How is that an acceptable solution to retry tens-of-thousands of commands? (Probably more)
We currently have 52 migrations and more are added all the time.

Maybe you misunderstood the problem.
Let's say I have my retry count set to 5 and I have a migration that has 10 CREATE TABLE commands. The first command fails 3 times, but succeeds on the 4th retry. Awesome! Unfortunately, now all but 1 retry attempt is left. Let's hope there aren't any more transient errors.
If the retry counter was reset between commands, that would be great too, but there isn't a way to control that when applying a migration.

I need a way to wrap each command in the migration in its own Retry Execution Strategy. Is there built in way to get all the commands that run when applying a migration?

@AndriySvyryd
Copy link
Member

@gazoonie Sorry, I assumed you were only applying one migration at a time. In any case this is a duplicate of #17578

@ajcvickers ajcvickers reopened this Oct 16, 2022
@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Oct 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-no-further-action The issue is closed and no further action is planned. customer-reported
Projects
None yet
Development

No branches or pull requests

3 participants