Loading
Remove the ml_candidate_metric_order_lateral feature flag
What does this MR do and why?
Removes the ml_candidate_metric_order_lateral feature flag. Candidate lists ordered by a metric (the MLflow runs/search API and the experiment page, HTML and CSV) look up the latest metric value of each candidate with a LATERAL join, instead of computing the latest value of the metric for every candidate in the table. Experiments with more than 50,000 candidates keep the DISTINCT ON query, as they did with the flag on.
The flag has been at 100% on GitLab.com since 2026-10-29.
Design notes
- Only the flag check goes away.
Projects::Ml::CandidateFinder#lateral_metric_order?keeps the candidate limit (LATERAL_METRIC_ORDER_MAX_CANDIDATES,Ml::Experiment#more_candidates_than?), so theDISTINCT ONbranch ofMl::Candidate.order_by_metricand itslateral:keyword stay: experiments above the limit still use them. No query changes for any experiment compared with the flag on. - The limit, the
DISTINCT ONbranch and the newml_candidate_metrics (candidate_id, name, id DESC)index are the follow-up #635116 (closed). That issue does not need the flag. The index must not exist while theDISTINCT ONquery still runs, so the index and the removal of the limit go together in that MR. - Spec changes:
spec/finders/projects/ml/candidate_finder_spec.rb: the keyset pagination examples for theDISTINCT ONquery now reach it through the candidate limit (stub_const) instead of the disabled flag. The second commit stubs that limit to 1, below the candidate count, and checks that the query has noLATERAL. Themetric ordering joinexamples already cover both sides of the limit, so the flag-disabled example is gone.spec/requests/api/ml/mlflow/runs_spec.rbandspec/requests/projects/ml/experiments_controller_spec.rb: the flag-disabled contexts are gone, and the shared examples that ran the same checks in both flag states are inline again.
- The
mlflow_search_order_by_listflag uses the same search code and stays.
References
- Related to https://gitlab.com/gitlab-org/gitlab/-/work_items/635115 (rollout issue)
- Flag introduced in !263900 (merged)
- Index follow-up: #635116 (closed)
- Sibling flag removal: !269565 (merged) removes
mlflow_enforce_request_limitsand also editsspec/requests/api/ml/mlflow/runs_spec.rb, in different examples. Either can merge first.
Rollback: revert this MR.
Screenshots or screen recordings
No UI change.
How to set up and validate locally
- Create an experiment with a few candidates that log a metric, for example with the MLflow client against
http://gdk.test:3000/api/v4/projects/<id>/ml/mlflow, loggingaucwith a different value on each run. - Visit
http://gdk.test:3000/<namespace>/<project>/-/ml/experiments/<iid>. - Sort the candidate list by the
aucmetric, descending and ascending, and page through it. - Expect: the candidates appear in metric order, candidates without the metric are not listed, and no candidate appears twice across pages.
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.
Edited by Eduardo Bonet