Remove merge_trains_batch_car_lookups feature flag

What does this MR do and why?

This removes the merge_trains_batch_car_lookups feature flag and keeps the preloading it gated permanently on.

MergeTrains::RefreshService refreshes every car on a merge train in one pass under an exclusive lease. MergeTrains::Train#refreshable_cars now always preloads the project, user, merge request, pipeline and diff that the refresh reads off each car, handing the train's already-loaded project to the preloader as an available record. Without the preload each car resolves those associations on its own, so the query count for a refresh scales with the length of the train. Measured on a train of cars waiting on their pipelines, the preload takes a refresh from 14 queries per car to 2, so a 20-car train goes from roughly 285 main-database queries to roughly 53.

This MR deletes the disabled path only. The preload: keyword on refreshable_cars and the batch_car_lookups? predicate in RefreshService are gone. Nothing under the flag changed during the rollout, so the enabled path is untouched.

What becomes permanent

Two effects of the preload lose their off switch. Both already apply wherever the flag is enabled.

  • validate_merge_request! gates a merge on open?, broken?, draft? and auto_merge_enabled?. Those are read once at the start of a refresh rather than when each car is reached, so a merge request that becomes a draft or is closed mid-pass may not be caught until the next refresh.
  • All cars share the train's project instance, so merge_trains_enabled? is read once per refresh rather than once per car.

References

How to set up and validate locally

bundle exec rspec ee/spec/models/merge_trains/train_spec.rb ee/spec/services/merge_trains/refresh_service_spec.rb

train_spec.rb folds the with preload context into the top-level #refreshable_cars examples, since there is no longer an unpreloaded path. refresh_service_spec.rb drops the flag-disabled context and tightens hash_including(limit: N) back to limit: N now that preload: is no longer passed.

After merge

/chatops gitlab run feature delete merge_trains_batch_car_lookups --dev --pre --staging --staging-ref --production
Edited by Hordur Freyr Yngvason

Merge request reports

Loading
Loading