Skip to content

Remove user callouts that are related to attention request

What does this MR do and why?

It's a part of the effort to clean up attention request related data. I'm adding a temporary index as it takes more than a minute to remove these without the index as it was violating our query performance guideline. It'll be removed in a follow up MR.

Related to #371939 (closed) and &8650 (closed)

Datatebase

Query plan(without batch processing): https://console.postgres.ai/gitlab/gitlab-production-tunnel-pg12/sessions/11815/commands/42006

Up

# rake db:migrate

main: == 20220901071310 AddTmpIndexUserCalloutsOnAttentionRequestFeatureNames: migrating
main: -- transaction_open?()
main:    -> 0.0000s
main: -- index_exists?(:user_callouts, [:id], {:where=>"feature_name IN (47,48)", :name=>"tmp_index_user_callouts_on_attention_request_feature_names", :algorithm=>:concurrently})
main:    -> 0.0146s
main: -- execute("SET statement_timeout TO 0")
main:    -> 0.0005s
main: -- add_index(:user_callouts, [:id], {:where=>"feature_name IN (47,48)", :name=>"tmp_index_user_callouts_on_attention_request_feature_names", :algorithm=>:concurrently})
main:    -> 0.0084s
main: -- execute("RESET statement_timeout")
main:    -> 0.0009s
main: == 20220901071310 AddTmpIndexUserCalloutsOnAttentionRequestFeatureNames: migrated (0.0378s)

main: == 20220901071355 CleanupAttentionRequestUserCallouts: migrating ==============
main: == 20220901071355 CleanupAttentionRequestUserCallouts: migrated (0.0079s) =====

ci: == 20220901071310 AddTmpIndexUserCalloutsOnAttentionRequestFeatureNames: migrating
ci: -- transaction_open?()
ci:    -> 0.0000s
ci: -- index_exists?(:user_callouts, [:id], {:where=>"feature_name IN (47,48)", :name=>"tmp_index_user_callouts_on_attention_request_feature_names", :algorithm=>:concurrently})
ci:    -> 0.0060s
ci: -- execute("SET statement_timeout TO 0")
ci:    -> 0.0004s
ci: -- add_index(:user_callouts, [:id], {:where=>"feature_name IN (47,48)", :name=>"tmp_index_user_callouts_on_attention_request_feature_names", :algorithm=>:concurrently})
ci:    -> 0.0122s
ci: -- execute("RESET statement_timeout")
ci:    -> 0.0006s
ci: == 20220901071310 AddTmpIndexUserCalloutsOnAttentionRequestFeatureNames: migrated (0.0243s)

ci: == 20220901071355 CleanupAttentionRequestUserCallouts: migrating ==============
ci: -- The migration is skipped since it modifies the schemas: [:gitlab_main].
ci: -- This database can only apply migrations in one of the following schemas: [:gitlab_ci, :gitlab_shared, :gitlab_internal].
ci: == 20220901071355 CleanupAttentionRequestUserCallouts: migrated (0.0002s) =====

Down


# rake db:migrate:down:main VERSION=20220901071355

main: == 20220901071355 CleanupAttentionRequestUserCallouts: reverting ==============
main: == 20220901071355 CleanupAttentionRequestUserCallouts: reverted (0.0019s) =====

# rake db:migrate:down:main VERSION=20220901071310

main: == 20220901071310 AddTmpIndexUserCalloutsOnAttentionRequestFeatureNames: reverting
main: -- transaction_open?()
main:    -> 0.0000s
main: -- indexes(:user_callouts)
main:    -> 0.0374s
main: -- execute("SET statement_timeout TO 0")
main:    -> 0.0004s
main: -- remove_index(:user_callouts, {:algorithm=>:concurrently, :name=>"tmp_index_user_callouts_on_attention_request_feature_names"})
main:    -> 0.0190s
main: -- execute("RESET statement_timeout")
main:    -> 0.0011s
main: == 20220901071310 AddTmpIndexUserCalloutsOnAttentionRequestFeatureNames: reverted (0.0862s)

# rake db:migrate:down:ci VERSION=20220901071355

ci: == 20220901071355 CleanupAttentionRequestUserCallouts: reverting ==============
ci: -- The migration is skipped since it modifies the schemas: [:gitlab_main].
ci: -- This database can only apply migrations in one of the following schemas: [:gitlab_ci, :gitlab_shared, :gitlab_internal].
ci: == 20220901071355 CleanupAttentionRequestUserCallouts: reverted (0.0001s) =====

# rake db:migrate:down:ci VERSION=20220901071310

ci: == 20220901071310 AddTmpIndexUserCalloutsOnAttentionRequestFeatureNames: reverting
ci: -- transaction_open?()
ci:    -> 0.0000s
ci: -- indexes(:user_callouts)
ci:    -> 0.0182s
ci: -- execute("SET statement_timeout TO 0")
ci:    -> 0.0009s
ci: -- remove_index(:user_callouts, {:algorithm=>:concurrently, :name=>"tmp_index_user_callouts_on_attention_request_feature_names"})
ci:    -> 0.0047s
ci: -- execute("RESET statement_timeout")
ci:    -> 0.0004s
ci: == 20220901071310 AddTmpIndexUserCalloutsOnAttentionRequestFeatureNames: reverted (0.0500s)

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 Sincheol (David) Kim

Merge request reports

Loading