Skip to content

Add confidential notes index

Jan Provaznik requested to merge jp-sync_confidential_idx into master

What does this MR do and why?

In a previous step (!89520 (merged)) this index was prepared on .com and verified that this index exists there:

https://console.postgres.ai/gitlab/gitlab-production-tunnel-pg12/sessions/10544/commands/37865

\d

Query:

index_notes_on_id_where_confidential

Response:

Index "public.index_notes_on_id_where_confidential"
 Column |  Type   | Key? | Definition 
--------+---------+------+------------
 id     | integer | yes  | id
btree, for table "public.notes", predicate (confidential = true)

Currently we create this index synchronously also for self-managed instances (as described in https://docs.gitlab.com/ee/development/adding_database_indexes.html#add-a-migration-to-create-the-index-synchronously)

Screenshots or screen recordings

Migration output

honza@pc ~/gitlab-development-kit/gitlab (jp-sync_confidential_idx)$ rake db:migrate
main: == 20220613095911 CreateConfidentialNotesIndexOnId: migrating =================
main: -- transaction_open?()
main:    -> 0.0000s
main: -- indexes(:notes)
main:    -> 0.0081s
main: -- execute("SET statement_timeout TO 0")
main:    -> 0.0003s
main: -- remove_index(:notes, {:algorithm=>:concurrently, :name=>"index_notes_on_confidential"})
main:    -> 0.0053s
main: -- execute("RESET statement_timeout")
main:    -> 0.0003s
main: -- transaction_open?()
main:    -> 0.0000s
main: -- index_exists?(:notes, :id, {:where=>"confidential = true", :name=>"index_notes_on_id_where_confidential", :algorithm=>:concurrently})
main:    -> 0.0056s
main: -- add_index(:notes, :id, {:where=>"confidential = true", :name=>"index_notes_on_id_where_confidential", :algorithm=>:concurrently})
main:    -> 0.0079s
main: == 20220613095911 CreateConfidentialNotesIndexOnId: migrated (0.0346s) ========

ci: == 20220613095911 CreateConfidentialNotesIndexOnId: migrating =================
ci: -- transaction_open?()
ci:    -> 0.0000s
ci: -- indexes(:notes)
ci:    -> 0.0075s
ci: -- execute("SET statement_timeout TO 0")
ci:    -> 0.0003s
ci: -- remove_index(:notes, {:algorithm=>:concurrently, :name=>"index_notes_on_confidential"})
ci:    -> 0.0044s
ci: -- execute("RESET statement_timeout")
ci:    -> 0.0003s
ci: -- transaction_open?()
ci:    -> 0.0000s
ci: -- index_exists?(:notes, :id, {:where=>"confidential = true", :name=>"index_notes_on_id_where_confidential", :algorithm=>:concurrently})
ci:    -> 0.0057s
ci: -- Index not created because it already exists (this may be due to an aborted migration or similar): table_name: notes, column_name: id
ci: == 20220613095911 CreateConfidentialNotesIndexOnId: migrated (0.0209s) ========

honza@pc ~/gitlab-development-kit/gitlab (jp-sync_confidential_idx)$ rake db:rollback:ci db:rollback:main
ci: == 20220613095911 CreateConfidentialNotesIndexOnId: reverting =================
ci: -- transaction_open?()
ci:    -> 0.0000s
ci: -- indexes(:notes)
ci:    -> 0.0081s
ci: -- execute("SET statement_timeout TO 0")
ci:    -> 0.0003s
ci: -- remove_index(:notes, {:algorithm=>:concurrently, :name=>"index_notes_on_id_where_confidential"})
ci:    -> 0.0198s
ci: -- execute("RESET statement_timeout")
ci:    -> 0.0003s
ci: == 20220613095911 CreateConfidentialNotesIndexOnId: reverted (0.0335s) ========

main: == 20220613095911 CreateConfidentialNotesIndexOnId: reverting =================
main: -- transaction_open?()
main:    -> 0.0000s
main: -- indexes(:notes)
main:    -> 0.0072s
main: -- execute("SET statement_timeout TO 0")
main:    -> 0.0003s
main: -- remove_index(:notes, {:algorithm=>:concurrently, :name=>"index_notes_on_id_where_confidential"})
main:    -> 0.0041s
main: -- execute("RESET statement_timeout")
main:    -> 0.0002s
main: == 20220613095911 CreateConfidentialNotesIndexOnId: reverted (0.0137s) ========

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

MR acceptance checklist

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

Edited by Jan Provaznik

Merge request reports