Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Prevent migration operations running before previous finalization completes #14832
Normally finalization is scheduled when either
But in a small window of time, a
In this case, if completed migrations include a previous migration which
To fix that,
…pletes Normally finalization is scheduled when either `PublishCompletedMigrationsOperation` or a migration operation is executed. But in a small window of time, a `MigrationOperation` can come and start just after `PublishCompletedMigrationsOperation` starts executing. In this case, if completed migrations include a previous migration which belongs to the same partition with `MigrationOperation` and local member was source of that migration and if `MigrationOperation` starts its execution before the `FinalizeMigrationOperation` is put into the partition operation threads queue, then `FinalizeMigrationOperation` can run after the `MigrationOperation` and remove data replicated by it. To fix that, `MigrationOperation` is retried if it cannot set `migrating` flag of a partition. `migrating` flag is set by migration operations and cleared by `FinalizeMigrationOperation`. So, if `migrating` flag is set while `MigrationOperation` is executed, that means former `FinalizeMigrationOperation` is not executed yet.