diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2017-11-10 18:49:36 +0300 |
---|---|---|
committer | Oswaldo Ferreira <oswaldo@gitlab.com> | 2017-11-10 22:34:55 +0300 |
commit | 29831be88942715d3c240bf965e887df7f93ba1d (patch) | |
tree | 98ee988df125a509a24dbd10cf7e3aa6e5497ade /app | |
parent | 4bab041750c328718265bf0459a151eff7e2965a (diff) |
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 0517b9e341a2960c54faa69717628225ed50c418)
ec73ecb0 Fix another timeout when searching for pipelines
Diffstat (limited to 'app')
-rw-r--r-- | app/models/merge_request.rb | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index efd8cca2947..dd4e67bc9da 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -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 |