-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Relax singleton-context constraint for pending non-singleton-context reverts #10114
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
Changes from 3 commits
4481b48
e6ff7c2
676a08c
4eef9d6
481e328
f58a187
ff8d9c1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3586,6 +3586,29 @@ func (e *Executor) CompleteMigration(ctx context.Context, uuid string) (result * | |
| return e.execQuery(ctx, query) | ||
| } | ||
|
|
||
| func (e *Executor) submittedMigrationConflictsWithPendingMigrationInSingletonContext( | ||
| ctx context.Context, submittedMigration, pendingOnlineDDL *schema.OnlineDDL, | ||
| ) (bool, error) { | ||
| if pendingOnlineDDL.MigrationContext == submittedMigration.MigrationContext { | ||
| // same migration context. this is obviously allowed | ||
| return false, nil | ||
| } | ||
| // Let's see if the pending migration is a revert: | ||
| revertedUUID, _ := pendingOnlineDDL.GetRevertUUID() | ||
| if revertedUUID == "" { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This feels like an opportunity for undefined behavior in the future. Any reason not to do this instead?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. changed to |
||
| // Not a revert. So the pending migration definitely conflicts with our migration. | ||
| return true, nil | ||
| } | ||
|
|
||
| // The pending migration is a revert | ||
| if !pendingOnlineDDL.StrategySetting().IsSingletonContext() { | ||
| // Aha! So, our "conflict" is with a REVERT migration, which does _not_ have a -singleton-context | ||
| // flag. Because we want to allow REVERT migrations to run as concurrently as possible, we allow this scenario. | ||
| return false, nil | ||
| } | ||
| return true, nil | ||
|
mattlord marked this conversation as resolved.
Outdated
|
||
| } | ||
|
|
||
| // SubmitMigration inserts a new migration request | ||
| func (e *Executor) SubmitMigration( | ||
| ctx context.Context, | ||
|
|
@@ -3667,9 +3690,14 @@ func (e *Executor) SubmitMigration( | |
| if err != nil { | ||
| return err | ||
| } | ||
| if pendingOnlineDDL.MigrationContext != onlineDDL.MigrationContext { | ||
| return vterrors.Errorf(vtrpcpb.Code_FAILED_PRECONDITION, "singleton migration rejected: found pending migration: %s in different context: %s", pendingUUID, pendingOnlineDDL.MigrationContext) | ||
| conflictFound, err := e.submittedMigrationConflictsWithPendingMigrationInSingletonContext(ctx, onlineDDL, pendingOnlineDDL) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| if conflictFound { | ||
| return vterrors.Errorf(vtrpcpb.Code_FAILED_PRECONDITION, "singleton-context migration rejected: found pending migration: %s in different context: %s", pendingUUID, pendingOnlineDDL.MigrationContext) | ||
| } | ||
| // no conflict? continue looking for other pending migrations | ||
| } | ||
| } | ||
| // OK to go! We can submit the migration: | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.