Skip to content

Add async indexes for VSA tables

What does this MR do and why?

This MR schedules async index creation for the value stream analytics aggregation tables. These tables are hash-partitioned so running the migration in post_migrate would take some time...

Database

There are many partitions so I truncated the log:

Up:

A lot's of: index_exists and add_index_options calls

main: == 20230524093249 AddAsyncIndexToVsaIssues: migrating =========================
main: -- index_exists?("gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_00", [:stage_event_hash_id, :group_id, :end_event_timestamp, :issue_id], {:name=>"index_c7ac8595d3", :algorithm=>:concurrently})
main:    -> 0.0085s
main: -- index_exists?("gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_01", [:stage_event_hash_id, :group_id, :end_event_timestamp, :issue_id], {:name=>"index_837cc295f1", :algorithm=>:concurrently})
main:    -> 0.0064s
main: -- index_exists?("gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_02", [:stage_event_hash_id, :group_id, :end_event_timestamp, :issue_id], {:name=>"index_c02f569fba", :algorithm=>:concurrently})
main:    -> 0.0055s
main: -- index_exists?("gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_03", [:stage_event_hash_id, :group_id, :end_event_timestamp, :issue_id], {:name=>"index_be0a028bcc", :algorithm=>:concurrently})


main: == 20230524093355 AddAsyncIndexToVsaMrs: migrating ============================
main: -- index_exists?("gitlab_partitions_static.analytics_cycle_analytics_merge_request_stage_events_00", [:stage_event_hash_id, :group_id, :end_event_timestamp, :merge_request_id], {:name=>"index_ce87cbaf2d", :algorithm=>:concurrently})
main:    -> 0.0032s
main: -- add_index_options("gitlab_partitions_static.analytics_cycle_analytics_merge_request_stage_events_00", [:stage_event_hash_id, :group_id, :end_event_timestamp, :merge_request_id], {:name=>"index_ce87cbaf2d", :algorithm=>:concurrently})
main:    -> 0.0003s
main: -- index_exists?("gitlab_partitions_static.analytics_cycle_analytics_merge_request_stage_events_01", [:stage_event_hash_id, :group_id, :end_event_timestamp, :merge_request_id], {:name=>"index_d17b82ddd9", :algorithm=>:concurrently})
main:    -> 0.0034s
main: -- add_index_options("gitlab_partitions_static.analytics_cycle_analytics_merge_request_stage_events_01", [:stage_event_hash_id, :group_id, :end_event_timestamp, :merge_request_id], {:name=>"index_d17b82ddd9", :algorithm=>:concurrently})
main:    -> 0.0000s

Down:

main: == [advisory_lock_connection] object_id: 275540, pg_backend_pid: 599234
main: == 20230524093355 AddAsyncIndexToVsaMrs: reverting ============================
main: == 20230524093355 AddAsyncIndexToVsaMrs: reverted (0.1503s) ===================


ci: == [advisory_lock_connection] object_id: 275420, pg_backend_pid: 599598
ci: == 20230524093355 AddAsyncIndexToVsaMrs: reverting ============================
ci: == 20230524093355 AddAsyncIndexToVsaMrs: reverted (0.1809s) ===================


main: == 20230524093249 AddAsyncIndexToVsaIssues: reverting =========================
main: == 20230524093249 AddAsyncIndexToVsaIssues: reverted (0.1077s) ================


ci: == 20230524093249 AddAsyncIndexToVsaIssues: reverting =========================
ci: == 20230524093249 AddAsyncIndexToVsaIssues: reverted (0.2501s) ================

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 #408320 (closed)

Edited by Adam Hegyi

Merge request reports

Loading