Batched Background Migrations

Version history

There can be risks when disabling released features. Refer to this feature’s version history for more details.

To update database tables in batches, GitLab can use batched background migrations. These migrations are created by GitLab developers and run automatically on upgrade. However, such migrations are limited in scope to help with migrating some integer database columns to bigint. This is needed to prevent integer overflow for some tables.

All migrations must be finished before upgrading GitLab. To check the status of the existing migrations, execute this command:

Gitlab::Database::BackgroundMigration::BatchedMigration.pluck(:id, :table_name, :status)

Enable or disable Batched Background Migrations

Batched Background Migrations is under development but ready for production use. It is deployed behind a feature flag that is enabled by default. GitLab administrators with access to the GitLab Rails console can opt to disable it.

To enable it:

Feature.enable(:execute_batched_migrations_on_schedule)

To disable it:

Feature.disable(:execute_batched_migrations_on_schedule)

Automatic batch size optimization

Version history

There can be risks when disabling released features. Refer to this feature’s version history for more details.

To maximize throughput of batched background migrations (in terms of the number of tuples updated per time unit), batch sizes are automatically adjusted based on how long the previous batches took to complete.

Enable or disable automatic batch size optimization

Automatic batch size optimization for Batched Background Migrations is under development but ready for production use. It is deployed behind a feature flag that is enabled by default. GitLab administrators with access to the GitLab Rails console can opt to disable it.

To enable it:

Feature.enable(:optimize_batched_migrations)

To disable it:

Feature.disable(:optimize_batched_migrations)