Update traversal ids on inventory filters on group transfer
What does this MR do and why?
This MR introduces InventoryFilters::UpdateTraversalIdsService to keep security_inventory_filters.traversal_ids in sync when a group is transferred.
Since the column backs the lexicographic within scope, a stale value files the project under the wrong subtree. Security::AnalyzersStatus::ProcessGroupTransferEventsWorker now enumerates the moved subtree with Gitlab::Database::NamespaceProjectIdsEachBatch and fans out in slices of 500 to a new InventoryFilters::UpdateTraversalIdsWorker.
No new event subscription and no migration.
Changelog: fixed
EE: true
Related issue
Query plans
Security::InventoryFilters::UpdateTraversalIdsService#execute
Raw SQL
UPDATE
"security_inventory_filters"
SET
"traversal_ids" = '{9970,96981785}'
WHERE
"security_inventory_filters"."project_id" IN (70472537, 80141160, 65311716, 66212496, 82231679)```
Query plan
Full details here
Update on public.security_inventory_filters (cost=0.43..14.83 rows=0 width=0) (actual time=29.569..29.570 rows=0 loops=1)
Buffers: shared hit=90 read=46 dirtied=22
WAL: records=36 fpi=21 bytes=124591
I/O Timings: read=28.496 write=0.000
-> Index Scan using index_security_inventory_filters_on_project_id on public.security_inventory_filters (cost=0.43..14.83 rows=5 width=38) (actual time=3.044..11.575 rows=5 loops=1)
Index Cond: (security_inventory_filters.project_id = ANY ('{70472537,80141160,65311716,66212496,82231679}'::bigint[]))
Index Searches: 5
Buffers: shared hit=4 read=16 dirtied=3
WAL: records=6 fpi=3 bytes=24613
I/O Timings: read=11.010 write=0.000
Settings: random_page_cost = '1.5', seq_page_cost = '4', effective_cache_size = '338688MB', jit = 'off', work_mem = '100MB'
Query ID: -6104461078791536037Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.