Skip mergeRequestMergeStatusUpdated trigger when not needed
What does this MR do and why?
In MergeRequests::RefreshService
, we mark all affected MRs as unchecked. In MergeRequest#merge_status
state machine, we have an after_transition
block that triggers a GraphQL subscription when MR is marked as unchecked.
There's a scenario wherein a single push can result to a lot of SQL queries in a single trigger. For example, if someone pushes to main
and there are 1K MRs targetting that branch, all those MRs will be marked as unchecked. That can result to a 1K SQL queries when GraphQL subscription is triggered.
To prevent that, a skip_merge_status_trigger
flag is added to MergeRequest
and it is set conditionally in MergeRequests::RefreshService
. We only need to trigger the subscription when the push is for the MR's source branch and project. This way we can still update the merge widget in real-time when a push occurs to the MR's branch.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #396255 (closed)