From 2aec9637db63e4017e6dc2c95f15f41cd86ac2f5 Mon Sep 17 00:00:00 2001 From: Krasimir Angelov <kangelov@gitlab.com> Date: Mon, 17 May 2021 23:40:08 +0000 Subject: [PATCH] Enable by default scheduled execution of batched background migrations --- .../batched_background_migration_worker.rb | 2 +- ...execute-batched-migrations-on-schedule.yml | 5 ++ ...execute_batched_migrations_on_schedule.yml | 2 +- doc/update/index.md | 4 ++ .../monitoring/background_migrations.md | 48 +++++++++++++++++++ 5 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 changelogs/unreleased/329511-enable-by-default-execute-batched-migrations-on-schedule.yml create mode 100644 doc/user/admin_area/monitoring/background_migrations.md diff --git a/app/workers/database/batched_background_migration_worker.rb b/app/workers/database/batched_background_migration_worker.rb index ba5b8f4f947a..5a326a351e8b 100644 --- a/app/workers/database/batched_background_migration_worker.rb +++ b/app/workers/database/batched_background_migration_worker.rb @@ -16,7 +16,7 @@ class BatchedBackgroundMigrationWorker INTERVAL_VARIANCE = 5.seconds.freeze def perform - return unless Feature.enabled?(:execute_batched_migrations_on_schedule, type: :ops) && active_migration + return unless Feature.enabled?(:execute_batched_migrations_on_schedule, type: :ops, default_enabled: :yaml) && active_migration with_exclusive_lease(active_migration.interval) do # Now that we have the exclusive lease, reload migration in case another process has changed it. diff --git a/changelogs/unreleased/329511-enable-by-default-execute-batched-migrations-on-schedule.yml b/changelogs/unreleased/329511-enable-by-default-execute-batched-migrations-on-schedule.yml new file mode 100644 index 000000000000..3dd6051c6282 --- /dev/null +++ b/changelogs/unreleased/329511-enable-by-default-execute-batched-migrations-on-schedule.yml @@ -0,0 +1,5 @@ +--- +title: Enable by default scheduled execution of batched background migrations +merge_request: 61316 +author: +type: added diff --git a/config/feature_flags/ops/execute_batched_migrations_on_schedule.yml b/config/feature_flags/ops/execute_batched_migrations_on_schedule.yml index f518849b57fd..b739099fcd5d 100644 --- a/config/feature_flags/ops/execute_batched_migrations_on_schedule.yml +++ b/config/feature_flags/ops/execute_batched_migrations_on_schedule.yml @@ -5,4 +5,4 @@ rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/326241 milestone: '13.11' type: ops group: group::database -default_enabled: false +default_enabled: true diff --git a/doc/update/index.md b/doc/update/index.md index 4ae7a3b48546..3c2ea8e0d926 100644 --- a/doc/update/index.md +++ b/doc/update/index.md @@ -107,6 +107,10 @@ Sidekiq::Queue.new("background_migration").size Sidekiq::ScheduledSet.new.select { |r| r.klass == 'BackgroundMigrationWorker' }.size ``` +### Batched background migrations + +See the documentation on [batched background migrations](../user/admin_area/monitoring/background_migrations.md). + ### What do I do if my background migrations are stuck? WARNING: diff --git a/doc/user/admin_area/monitoring/background_migrations.md b/doc/user/admin_area/monitoring/background_migrations.md new file mode 100644 index 000000000000..a68d71094295 --- /dev/null +++ b/doc/user/admin_area/monitoring/background_migrations.md @@ -0,0 +1,48 @@ +--- +stage: Enablement +group: Database +info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments +--- + +# Batched Background Migrations **(FREE SELF)** + +> - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/51332) in GitLab 13.11. +> - [Deployed behind a feature flag](../../../user/feature_flags.md), disabled by default. +> - [Enabled by default](https://gitlab.com/gitlab-org/gitlab/-/issues/329511) in GitLab 13.12. +> - Enabled on GitLab.com. +> - Recommended for production use. +> - For GitLab self-managed instances, GitLab administrators can opt to [disable it](#enable-or-disable-batched-background-migrations). **(FREE SELF)** + +There can be [risks when disabling released features](../../../user/feature_flags.md#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: + +```ruby +Gitlab::Database::BackgroundMigration::BatchedMigration.pluck(:id, :table_name, :status) +``` + +## Enable or disable Batched Background Migrations **(FREE SELF)** + +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](../../../administration/feature_flags.md) +can opt to disable it. + +To enable it: + +```ruby +Feature.enable(:execute_batched_migrations_on_schedule) +``` + +To disable it: + +```ruby +Feature.disable(:execute_batched_migrations_on_schedule) +``` -- GitLab