Remove merge_request_refresh_skip_diff_commit_preload feature flag
Removes the merge_request_refresh_skip_diff_commit_preload feature flag, default enabled since 19.3. The skip of the unused diff commit preload in MergeRequests::RefreshService becomes permanent, and the now-unused MergeRequest.preload_latest_diff_commit scope is deleted. No behaviour change beyond what is already live on GitLab.com.
Detailed context for AI agents
What does this MR do and why?
MergeRequests::RefreshService#post_merge_candidates (called from post_merge_manually_merged) used to eagerly preload, for every open MR targeting the pushed branch, the latest diff's commits, each commit's metadata row, and each row's commit author and committer. Nothing on that path reads this data. The cost was CPU and allocations, not extra queries: MergeRequestDiffCommit belongs_to :merge_request_commits_metadata has an instance-dependent scope that gets evaluated once per diff commit. On gitlab-org/gitlab that meant roughly 2,784 open MRs preloaded per push to master, adding about 300s of CPU per UpdateMergeRequestsWorker job.
With the flag removed, post_merge_candidates only preloads project and latest diff plus merge data. The MergeRequest.preload_latest_diff_commit scope is deleted along with its specs in spec/models/merge_request_spec.rb, since it has no remaining callers.
In spec/services/merge_requests/refresh_service_spec.rb, the flag on/off contexts are removed. The remaining test covers a diff whose head_commit_sha column is NULL (pre-GitLab 8.4 diffs), which is the only real consumer of the commit graph, and confirms the MR is still detected as manually merged via the fallback that reads commit rows with an indexed LIMIT 1 query.
Rollback risk is limited to what is already live: the flag has been enabled on GitLab.com, so reverting this MR would only re-add the flag, not change current production behaviour.
Changelog: other (a default-on flag is removed, behaviour is unchanged).
References
- Rollout issue: #618580 (closed)
- Flag introduced by: !251113 (merged)
How to set up and validate locally
- Push a commit to a branch that is the target of an open merge request, or merge an MR's source branch into its target manually and push. The MR should be closed as merged, and no
merge_request_diff_commitspreload query should appear in the log. - Rubocop is clean on the 4 changed files.
bundle exec rspec spec/services/merge_requests/refresh_service_spec.rb:569passes.spec/models/merge_request_spec.rbloads correctly and the neighbouring example passes.- After this MR merges, delete the flag with:
/chatops run feature delete merge_request_refresh_skip_diff_commit_preload --dev --pre --staging --staging-ref --production
MR acceptance checklist
Evaluated against the MR acceptance checklist; no user-facing, database, or security-sensitive change.
Screenshots
Not applicable, backend-only.