BigW Consortium Gitlab

Commit 29831be8 by Yorick Peterse Committed by Oswaldo Ferreira

Merge branch 'fix-502-mrs-with-lots-of-versions' into 'master'

Fix another timeout when searching for pipelines Closes #39054 See merge request gitlab-org/gitlab-ce!15322 (cherry picked from commit 0517b9e3) ec73ecb0 Fix another timeout when searching for pipelines
parent 4bab0417
......@@ -865,7 +865,19 @@ class MergeRequest < ActiveRecord::Base
#
def all_commit_shas
if persisted?
column_shas = MergeRequestDiffCommit.where(merge_request_diff: merge_request_diffs).limit(10_000).pluck('sha')
# MySQL doesn't support LIMIT in a subquery.
diffs_relation =
if Gitlab::Database.postgresql?
merge_request_diffs.order(id: :desc).limit(100)
else
merge_request_diffs
end
column_shas = MergeRequestDiffCommit
.where(merge_request_diff: diffs_relation)
.limit(10_000)
.pluck('sha')
serialised_shas = merge_request_diffs.where.not(st_commits: nil).flat_map(&:commit_shas)
(column_shas + serialised_shas).uniq
......
---
title: Ensure merge requests with lots of version don't time out when searching for
pipelines
merge_request:
author:
type: performance
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment