Add group transferred event handler workers
What does this MR do and why?
Add a group transferred event handler that schedules workers to clean up attributes from the previous root namespace. This handler iterates over the projects within the group and enqueues workers to delete attributes associated with the old root namespace. The cleanup is only triggered if the group transfer results in a change to the root namespace.
Changelog: added
EE: true
How to set up and validate locally
- Use this MR description to attach a project under a namespace with attributes.
- Verify that
Security::ProjectToSecurityAttributerecords are created. - Move the group to a different namespace.
- Verify that
Security::ProjectToSecurityAttributerecords are deleted. - Repeat, but this time move the group under the same root namespace.
- Verify that
Security::ProjectToSecurityAttributerecords are not deleted.
Query plans
delete_all
Raw SQL
DELETE FROM "project_to_security_attributes"
WHERE ("project_to_security_attributes"."id") IN (
SELECT
"project_to_security_attributes"."id"
FROM
"project_to_security_attributes"
WHERE
"project_to_security_attributes"."project_id" IN (1, 2)
AND (traversal_ids[1] != 2)
LIMIT 500)
Plan
See full plan here.
ModifyTable on public.project_to_security_attributes (cost=0.00..0.02 rows=0 width=0) (actual time=0.005..0.006 rows=0 loops=1)
I/O Timings: read=0.000 write=0.000
-> Nested Loop Semi Join (cost=0.00..0.02 rows=1 width=38) (actual time=0.004..0.005 rows=0 loops=1)
I/O Timings: read=0.000 write=0.000
-> Seq Scan on public.project_to_security_attributes (cost=0.00..0.00 rows=1 width=14) (actual time=0.004..0.004 rows=0 loops=1)
I/O Timings: read=0.000 write=0.000
-> Subquery Scan on ANY_subquery (cost=0.00..0.01 rows=1 width=40) (actual time=0.000..0.000 rows=0 loops=0)
I/O Timings: read=0.000 write=0.000
-> Limit (cost=0.00..0.00 rows=1 width=8) (actual time=0.000..0.000 rows=0 loops=0)
I/O Timings: read=0.000 write=0.000
-> Seq Scan on public.project_to_security_attributes project_to_security_attributes_1 (cost=0.00..0.00 rows=1 width=8) (actual time=0.000..0.000 rows=0 loops=0)
Filter: ((project_to_security_attributes_1.project_id = ANY ('{1,2}'::bigint[])) AND (project_to_security_attributes_1.traversal_ids[1] <> 2))
Rows Removed by Filter: 0
I/O Timings: read=0.000 write=0.000
Settings: random_page_cost = '1.5', effective_cache_size = '338688MB', jit = 'off', seq_page_cost = '4', work_mem = '100MB'
Note: The table is new and empty, so the indexes are not in use in the query plan. The existing table indexes:
index_project_to_security_attributes_on_security_attribute_id ON project_to_security_attributes USING btree (security_attribute_id);index_project_security_attributes_project_id_unique ON project_to_security_attributes USING btree (project_id, security_attribute_id);index_project_security_attributes_traversal_ids ON project_to_security_attributes USING btree (traversal_ids);
MR 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.
Related to Remove attributes when moving project or subgro... (#567568 - closed) • Gal Katz • 18.9