Loading
Backfill inventory filters table with traversal_ids
What does this MR do and why?
Adds a background migration which repairs security_inventory_filters.traversal_ids rows left stale by group transfers.
A previous MR fixed the underlying bug where group transfers never rewrote this column. This migration reads each project's current traversal_ids from the main db and updates only the rows that actually drifted, matching on the observed stale value so a group transfer landing mid job is not reverted.
Changelog: fixed
EE: true
Related issue
Query plans
BackfillTraversalIdsInSecurityInventoryFilters#perform
Raw SQL
UPDATE
security_inventory_filters AS sif
SET
traversal_ids = v.traversal_ids
FROM (
VALUES (70472537, ARRAY[10, 11]::bigint[], ARRAY[93, 71]::bigint[]),
(65339032, ARRAY[11111111]::bigint[], ARRAY[95]::bigint[]),
(80141160, ARRAY[11111111]::bigint[], ARRAY[89]::bigint[])) AS v (project_id, stale_traversal_ids, traversal_ids)
WHERE
sif.project_id = v.project_id
AND sif.traversal_ids = v.stale_traversal_ids
Query plan
Full details here
Update on public.security_inventory_filters sif (cost=0.43..10.43 rows=0 width=0) (actual time=3.224..3.225 rows=0 loops=1)
Buffers: shared hit=16 read=2 dirtied=6
WAL: records=8 fpi=6 bytes=39730
I/O Timings: read=1.994 write=0.000
-> Nested Loop (cost=0.43..10.43 rows=1 width=130) (actual time=3.223..3.223 rows=0 loops=1)
Buffers: shared hit=16 read=2 dirtied=6
WAL: records=8 fpi=6 bytes=39730
I/O Timings: read=1.994 write=0.000
-> Values Scan on "*VALUES*" (cost=0.00..0.04 rows=3 width=160) (actual time=0.008..0.013 rows=3 loops=1)
I/O Timings: read=0.000 write=0.000
-> Index Scan using index_security_inventory_filters_on_project_id on public.security_inventory_filters sif (cost=0.43..3.46 rows=1 width=51) (actual time=1.068..1.068 rows=0 loops=3)
Index Cond: (sif.project_id = "*VALUES*".column1)
Index Searches: 3
Filter: ("*VALUES*".column2 = sif.traversal_ids)
Rows Removed by Filter: 1
Buffers: shared hit=16 read=2 dirtied=6
WAL: records=8 fpi=6 bytes=39730
I/O Timings: read=1.994 write=0.000
Settings: jit = 'off', work_mem = '100MB', random_page_cost = '1.5', seq_page_cost = '4', effective_cache_size = '338688MB'
Query ID: -8499324194924821135MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.