Skip to content

Synchronize temporary index for vulnerability findings with potentially mismatched scanners

What does this MR do and why?

Synchronous counter-part to !91488 (merged).

Synchronizes a temporary index for the background migration !89127 (merged) that migrates erroneously associated vulnerability scanners.

CREATE INDEX tmp_index_vulnerability_occurrences_on_id_and_scanner_id ON vulnerability_occurrences USING btree (id, scanner_id) WHERE (report_type = ANY (ARRAY[7, 99]));

Migration output

Up

main: == 20220607082910 AddSyncTmpIndexForPotentiallyMisassociatedVulnerabilityOccurrences: migrating
main: -- transaction_open?()
main:    -> 0.0000s
main: -- index_exists?(:vulnerability_occurrences, [:id, :scanner_id], {:where=>"report_type IN (7,99)", :name=>"tmp_index_vulnerability_occurrences_on_id_and_scanner_id", :algorithm=>:concurrently})
main:    -> 0.0211s
main: -- execute("SET statement_timeout TO 0")
main:    -> 0.0006s
main: -- add_index(:vulnerability_occurrences, [:id, :scanner_id], {:where=>"report_type IN (7,99)", :name=>"tmp_index_vulnerability_occurrences_on_id_and_scanner_id", :algorithm=>:concurrently})
main:    -> 0.0472s
main: -- execute("RESET statement_timeout")
main:    -> 0.0007s
main: == 20220607082910 AddSyncTmpIndexForPotentiallyMisassociatedVulnerabilityOccurrences: migrated (0.0866s)

Down

main: == 20220607082910 AddSyncTmpIndexForPotentiallyMisassociatedVulnerabilityOccurrences: reverting
main: -- transaction_open?()
main:    -> 0.0000s
main: -- indexes(:vulnerability_occurrences)
main:    -> 0.0160s
main: -- execute("SET statement_timeout TO 0")
main:    -> 0.0005s
main: -- remove_index(:vulnerability_occurrences, {:algorithm=>:concurrently, :name=>"tmp_index_vulnerability_occurrences_on_id_and_scanner_id"})
main:    -> 0.0094s
main: -- execute("RESET statement_timeout")
main:    -> 0.0006s
main: == 20220607082910 AddSyncTmpIndexForPotentiallyMisassociatedVulnerabilityOccurrences: reverted (0.0455s)

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

Edited by João Alexandre Cunha

Merge request reports