Retry `@project.merge_requests.set_latest_merge_request_diff_ids!`

Problem to solve

It seems that in some circumstances (for big projects) this function @project.merge_requests.set_latest_merge_request_diff_ids can take a long time to execute.

Specifically, it seems that the first query can still work without the index in memory (likely due to Vacuum cleaning):

SELECT  \"merge_requests\".\"id\" FROM \"merge_requests\" WHERE \"merge_requests\".\"target_project_id\" = 15728921 ORDER BY \"merge_requests\".\"id\" ASC LIMIT 1

This is pretty much retryable operation, that it is likely to succeed after second time with very little impact for the application:

  • ActiveRecord::QueryCanceled: query/insert timeout

I would assume that we retry that 2-3 times to increase the chances of this succeeding.

Intended users

  • Sidney (Systems Administrator)
Assignee Loading
Time tracking Loading