Resolve "Batched background migration marked as finished, but there are failed jobs"
requested to merge 342352-batched-background-migration-marked-as-finished-but-there-are-failed-jobs into master
What does this MR do and why?
Since we could not find the root cause of the problem, we decided to add a new validation to the model. This will prevent having background migration in an inconsistent state.
When we move the background migration to the state finished
we validate if all jobs have succeeded.
Screenshots or screen recordings
These are strongly recommended to assist reviewers and reduce the time to merge your change.
How to set up and validate locally
- Create a new background migration (status=active)
Example
migration = Gitlab::Database::BackgroundMigration::BatchedMigration.create!(..., status: :active)
- Create a new background migration job (status=failed)
migration.batched_jobs.create!(..., status: :failed)
- Execute
migration.finished!
- You should see an error message
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #342352 (closed)
Edited by Diogo Frazão