Event transition definition - BackgroundMigration::BatchedMigration
Currently, we don't have any transition rules. We can move a batched background migration from any state to any state. Also, we don't validate the batched background migration data before we move it to a new state. This could lead to unsuspected behavior.
Example: We found a migration in state 'finished' with failed jobs.
I suggest that we define the different transitions and we validate the data before we move to a new state.
(Please double-check the data below, I am not 100% sure)
flowchart LR
active <--> paused
active ----> finished
active --> finalizing
active <--> failed
finalizing --> failed
finalizing --> finished
States description:
- Active: Ready to be picked by the runner / Running background jobs
- Finalizing: Running background jobs
- Failed: Failed migration
- Finished: Completed migration
- Paused: Not visible to the runner
Transition rules:
- :active => [:paused, :finalizing, :finished, :failed]
- :paused => :active
- :finalizing => [:finished, :failed]
- :failed => :active
- :finished => nil
Validations:
- Failed: At least one background job failed
- Finished: All background jobs are completed
Edited by Diogo Frazão