Skip to content
Snippets Groups Projects
Commit 2a1c85ef authored by Heinrich Lee Yu's avatar Heinrich Lee Yu
Browse files

Merge branch 'morefice/drop-database-async-index-destruction-ff' into 'master'

Remove database_async_index_destruction feature flag

See merge request !95570
parents 8f77040f 00a8dc5a
No related branches found
No related tags found
2 merge requests!96059Draft: Add GraphQL query for deployment details,!95570Remove database_async_index_destruction feature flag
Pipeline #617768774 passed
---
name: database_async_index_destruction
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/92328
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/367964
milestone: '15.3'
type: ops
group: group::database
default_enabled: false
......@@ -328,8 +328,8 @@ asynchronously during weekend hours. Due to generally lower traffic and fewer de
index destruction can proceed at a lower level of risk.
1. [Schedule the index to be removed](#schedule-the-index-to-be-removed).
1. [Verify the MR was deployed and the index exists in production](#verify-the-mr-was-deployed-and-the-index-exists-in-production).
1. [Add a migration to create the index synchronously](#add-a-migration-to-create-the-index-synchronously).
1. [Verify the MR was deployed and the index exists in production](#verify-the-mr-was-deployed-and-the-index-no-longer-exists-in-production).
1. [Add a migration to destroy the index synchronously](#add-a-migration-to-destroy-the-index-synchronously).
### Schedule the index to be removed
......@@ -357,21 +357,21 @@ to remove them.
You must test the database index changes locally before creating a merge request.
### Verify the MR was deployed and the index exists in production
### Verify the MR was deployed and the index no longer exists in production
You can verify if the MR was deployed to GitLab.com with
`/chatops run auto_deploy status <merge_sha>`. To verify the existence of
the index, you can:
- Use a meta-command in `#database-lab`, for example: `\d <index_name>`.
- Make sure the index is not [`invalid`](https://www.postgresql.org/docs/12/sql-createindex.html#:~:text=The%20psql%20%5Cd%20command%20will%20report%20such%20an%20index%20as%20INVALID).
- Make sure the index no longer exists
- Ask someone in `#database` to check if the index exists.
- If you have access, you can verify directly on production or in a
production clone.
### Add a migration to destroy the index synchronously
After you verify the index exists in the production database, create a second
After you verify the index no longer exists in the production database, create a second
merge request that removes the index synchronously. The schema changes must be
updated and committed to `structure.sql` in this second merge request.
The synchronous migration results in a no-op on GitLab.com, but you should still add the
......@@ -379,7 +379,7 @@ migration as expected for other installations. For example, to
create the second migration for the previous asynchronous example:
**WARNING:**
Verify that the index no longer exist in production before merging a second migration with `remove_concurrent_index_by_name`.
Verify that the index no longer exists in production before merging a second migration with `remove_concurrent_index_by_name`.
If the second migration is deployed before the index has been destroyed,
the index is destroyed synchronously when the second migration executes.
......@@ -395,7 +395,7 @@ def up
end
def down
add_concurrent_index :ci_builds, :some_column, INDEX_NAME
add_concurrent_index :ci_builds, :some_column, name: INDEX_NAME
end
```
......@@ -403,7 +403,7 @@ end
To test changes for removing an index, use the asynchronous index helpers on your local environment:
1. Enable the feature flags by running `Feature.enable(:database_async_index_destruction)` and `Feature.enable(:database_reindexing)` in the Rails console.
1. Enable the feature flags by running `Feature.enable(:database_reindexing)` in the Rails console.
1. Run `bundle exec rails db:migrate` which should create an entry in the `postgres_async_indexes` table.
1. Run `bundle exec rails gitlab:db:reindex` destroy the index asynchronously.
1. To verify the index, open the PostgreSQL console by using the [GDK](https://gitlab.com/gitlab-org/gitlab-development-kit/-/blob/main/doc/howto/postgresql.md)
......
......@@ -27,7 +27,7 @@ def self.invoke(database = nil)
# Hack: Before we do actual reindexing work, create async indexes
Gitlab::Database::AsyncIndexes.create_pending_indexes! if Feature.enabled?(:database_async_index_creation, type: :ops)
Gitlab::Database::AsyncIndexes.drop_pending_indexes! if Feature.enabled?(:database_async_index_destruction, type: :ops)
Gitlab::Database::AsyncIndexes.drop_pending_indexes!
automatic_reindexing
end
......
......@@ -46,25 +46,11 @@
end
end
context 'when async index destruction is enabled' do
it 'executes async index destruction prior to any reindexing actions' do
stub_feature_flags(database_async_index_destruction: true)
it 'executes async index destruction prior to any reindexing actions' do
expect(Gitlab::Database::AsyncIndexes).to receive(:drop_pending_indexes!).ordered.exactly(databases_count).times
expect(described_class).to receive(:automatic_reindexing).ordered.exactly(databases_count).times
expect(Gitlab::Database::AsyncIndexes).to receive(:drop_pending_indexes!).ordered.exactly(databases_count).times
expect(described_class).to receive(:automatic_reindexing).ordered.exactly(databases_count).times
described_class.invoke
end
end
context 'when async index destruction is disabled' do
it 'does not execute async index destruction' do
stub_feature_flags(database_async_index_destruction: false)
expect(Gitlab::Database::AsyncIndexes).not_to receive(:drop_pending_indexes!)
described_class.invoke
end
described_class.invoke
end
context 'calls automatic reindexing' do
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment