Race condition may lead to an incorrect count in MigrationHelpers#update_column_in_batches
This occurred in gitlab-com/operations#355 today. What can happen:
- SELECT COUNT(*) AS count FROM projects is run
-
total
is set to N - A new project is created
- The update happens for all the other projects
The new project isn't marked with the default value. If change_column_null
attempts to run, it will fail, leading to a failed migration.
/cc: @pcarranza, @rspeicher, @twk3, @tmaczukin