Skip to content

Update MigrateRecordsToGhostUserInBatchesService retry logic to prevent from being blocked at one user

As an additional update from the issue, we can update the retry logic for MigrateRecordsToGhostUserInBatchesService by story a retry attribute for each row/user to avoid getting blocked if that deletion fails for a reasons. @ahegyi recommended:

We can use the same pattern that we have for loose foreign keys.

  1. Add the consume_after column to the ghost_user_migrations table.
  2. Set the consume_after value to created_at by default (could be NOW() as well) when the ghost_user_migrations record is created.
  3. When a user deletion fails, catch the timeout error and update the consume_after with Time.current + 30 minutes.

Additionally, we should retrieve a batch by ordering the rows by consume_after ASC