Skip to content

Resolve "!15665 consistently 502s because it fetches every commit"

What does this MR do?

Speeds up MergeRequest#can_be_reverted? to only look for revert commits in the notes after the MR was merged:

*** PRODUCTION *** production> merge_request = MergeRequest.find(6442721)
=> #<MergeRequest id:6442721 gitlab-org/gitlab-ce!15665>
# Before
*** PRODUCTION *** production> Benchmark.realtime { merge_request.can_be_reverted?(nil) }
=> 128.915346572001
# After
*** PRODUCTION *** production> Benchmark.realtime { merge_request.can_be_reverted?(nil) }
=> 0.027516558999195695

Are there points in the code the reviewer needs to double check?

We could be optimistic and always assume the metrics are there, and then just return false if they aren't?

We could also use the merge commit's committed timestamp, but that could be wrong if someone merged locally.

Why was this MR needed?

This was timing out on GitLab.com for an MR that, at one point, added 16,000 commits. This was then loading each of those commits to check if it was a revert of the MR, even though all of the 16,000 in question were added before the MR was merged, and so couldn't be a revert of the merge commit.

Screenshots (if relevant)

Does this MR meet the acceptance criteria?

What are the relevant issue numbers?

Closes #41807 (closed).

Edited by Sean McGivern

Merge request reports