Disable `Vulnerabilities::Finding` joins in `Ci::Pipeline`
What does this MR do and why?
- adds
disabled_joins
attributes behind a feature flag forVulnerabilities::Finding
associations withci_pipelines
- adds new feature flags enabled by default to enable us to turn the functionality off if necessary
This has_many
join between non ci_*
tables and ci_*
tables which will not be allowed when ci_*
tables are moved to a separate database. This MR is using the disable_joins
feature that was backported in !66400 (merged).
Related to #338665 (closed)
Queries
ee/app/models/vulnerabilities/finding.rb
Before
Ci::Pipeline Load (0.5ms) SELECT "ci_pipelines".* FROM "ci_pipelines" INNER JOIN "vulnerability_occurrence_pipelines" ON "ci_pipelines"."id" = "vulnerability_occurrence_pipelines"."pipeline_id" WHERE "vulnerability_occurrence_pipelines"."occurrence_id" = 1 /*application:console,line:/lib/gem_extensions/active_record/associations/has_many_through_association.rb:13:in `find_target'*/
After
SELECT "vulnerability_occurrence_pipelines"."pipeline_id" FROM "vulnerability_occurrence_pipelines" WHERE "vulnerability_occurrence_pipelines"."occurrence_id" = 1 /*application:console,line:/lib/gem_extensions/active_record/disable_joins/associations/association_scope.rb:32:in `block in last_scope_chain'*/
Ci::Pipeline Load (3.9ms) SELECT "ci_pipelines".* FROM "ci_pipelines" WHERE "ci_pipelines"."id" IN (8, 16) /*application:console,line:/lib/gem_extensions/active_record/associations/has_many_through_association.rb:11:in `find_target'*/
Edited by Subashis Chakraborty