Skip to content

Add a single feature flag to disable all ddl across the database

What does this MR do and why?

Adds a single ops feature-flag that disables all DDL feature-flags being used across the GitLab database.

Adds disallow_database_ddl_feature_flags – disabled by default. When it's set to true, it will disable all other flags.

Feature flags were identified as

  • partition_manager_sync_partitions
  • execute_batched_migrations_on_schedule
  • execute_background_migrations
  • database_reindexing
  • database_async_index_operations
  • database_async_foreign_key_validation
  • database_async_index_creation

These flags are manually disabled during PostgreSQL upgrade: https://ops.gitlab.net/gitlab-com/gl-infra/db-migration/-/issues/58#note_170932

Screenshots or screen recordings

All the flags are enabled in production:

How to set up and validate locally

  1. Use this snippet

Note: Gitlab::Database::Reindexing.invoke('main') is quite tricky to test. You should check the queries triggered in the console.

  1. Test for db.rake
echo "Feature.enable(:disallow_database_ddl_feature_flags)" | bundle exec rails c

bundle exec rake gitlab:db:enqueue_reindexing_action\[public.projects_pkey\]
bundle exec rake gitlab:db:execute_async_index_operations:main
bundle exec rake gitlab:db:validate_async_constraints:main

You should see the following message for the three tasks:

Note: disallow_database_ddl_feature_flags feature is currently enabled. Disable it to proceed.

Disable with: Feature.disable(:disallow_database_ddl_feature_flags)

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #417161 (closed)

Edited by Leonardo da Rosa

Merge request reports

Loading