Skip to content

Synch index addition for `index_vulnerabilities_on_project_id_and_id`

What does this MR do and why?

The asynchronous index was introduced in !127180 (merged).

Screenshots or screen recordings

\d+ vulnerabilites
image

How to set up and validate locally

  1. follow this guide
  2. bundle exec rails db:migrate
  3. bundle exec rails db:rollback:main
  4. bundle exec rails db:rollback:ci
  5. bundle exec rails db:migrate

db:migrate output

`bundle exec rails db:migrate`
main: == [advisory_lock_connection] object_id: 227500, pg_backend_pid: 384282
main: == 20231014071832 CreateIndexVulnerabilityProjectIdAndOnIdSync: migrating =====
main: -- transaction_open?(nil)
main:    -> 0.0000s
main: -- view_exists?(:postgres_partitions)
main:    -> 0.0142s
main: -- index_exists?(:vulnerabilities, [:project_id, :id], {:name=>"index_vulnerabilities_on_project_id_and_id", :algorithm=>:concurrently})
main:    -> 0.0098s
main: -- execute("SET statement_timeout TO 0")
main:    -> 0.0004s
main: -- add_index(:vulnerabilities, [:project_id, :id], {:name=>"index_vulnerabilities_on_project_id_and_id", :algorithm=>:concurrently})
main:    -> 0.0039s
main: -- execute("RESET statement_timeout")
main:    -> 0.0002s
main: == 20231014071832 CreateIndexVulnerabilityProjectIdAndOnIdSync: migrated (0.0487s) 

main: == [advisory_lock_connection] object_id: 227500, pg_backend_pid: 384282
ci: == [advisory_lock_connection] object_id: 227760, pg_backend_pid: 384284
ci: == 20231014071832 CreateIndexVulnerabilityProjectIdAndOnIdSync: migrating =====
ci: -- transaction_open?(nil)
ci:    -> 0.0000s
ci: -- view_exists?(:postgres_partitions)
ci:    -> 0.0006s
ci: -- index_exists?(:vulnerabilities, [:project_id, :id], {:name=>"index_vulnerabilities_on_project_id_and_id", :algorithm=>:concurrently})
ci:    -> 0.0132s
ci: -- execute("SET statement_timeout TO 0")
ci:    -> 0.0002s
ci: -- add_index(:vulnerabilities, [:project_id, :id], {:name=>"index_vulnerabilities_on_project_id_and_id", :algorithm=>:concurrently})
ci:    -> 0.0020s
ci: -- execute("RESET statement_timeout")
ci:    -> 0.0005s
ci: == 20231014071832 CreateIndexVulnerabilityProjectIdAndOnIdSync: migrated (0.0331s) 

ci: == [advisory_lock_connection] object_id: 227760, pg_backend_pid: 384284

db:rollback output

`bundle exec rails db:rollback:main`
main: == [advisory_lock_connection] object_id: 227160, pg_backend_pid: 385670
main: == 20231014071832 CreateIndexVulnerabilityProjectIdAndOnIdSync: reverting =====
main: -- transaction_open?(nil)
main:    -> 0.0000s
main: -- view_exists?(:postgres_partitions)
main:    -> 0.0148s
main: -- indexes(:vulnerabilities)
main:    -> 0.0099s
main: -- execute("SET statement_timeout TO 0")
main:    -> 0.0005s
main: -- remove_index(:vulnerabilities, {:algorithm=>:concurrently, :name=>"index_vulnerabilities_on_project_id_and_id"})
main:    -> 0.0011s
main: -- execute("RESET statement_timeout")
main:    -> 0.0003s
main: == 20231014071832 CreateIndexVulnerabilityProjectIdAndOnIdSync: reverted (0.0391s) 

main: == [advisory_lock_connection] object_id: 227160, pg_backend_pid: 385670
`bundle exec rails db:rollback:ci`
ci: == [advisory_lock_connection] object_id: 226960, pg_backend_pid: 386179
ci: == 20231014071832 CreateIndexVulnerabilityProjectIdAndOnIdSync: reverting =====
ci: -- transaction_open?(nil)
ci:    -> 0.0000s
ci: -- view_exists?(:postgres_partitions)
ci:    -> 0.0142s
ci: -- indexes(:vulnerabilities)
ci:    -> 0.0121s
ci: -- execute("SET statement_timeout TO 0")
ci:    -> 0.0002s
ci: -- remove_index(:vulnerabilities, {:algorithm=>:concurrently, :name=>"index_vulnerabilities_on_project_id_and_id"})
ci:    -> 0.0009s
ci: -- execute("RESET statement_timeout")
ci:    -> 0.0002s
ci: == 20231014071832 CreateIndexVulnerabilityProjectIdAndOnIdSync: reverted (0.0455s) 

ci: == [advisory_lock_connection] object_id: 226960, pg_backend_pid: 386179

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

Edited by Michael Becker

Merge request reports

Loading