Time limit database lock when rebasing a merge request
MergeRequest#rebase_async
can lock indefinitely with a SELECT FOR
UPDATE call. If an update is idle in transaction or another rebase
attempts to run, MergeRequest#rebase_async
could queue indefinitely or
until statement timeouts are triggered.
To limit the impact of this operation, we now just bail out after 5 s if we can't get the lock. The user will see an error message if this happens.
To test this in the UI, I locked this merge request and clicked the Rebase
button:
merge_request = MergeRequest.find_by(project_id: 1, iid: 2)
merge_request.with_lock do
sleep 6000
end
Part of #30528 (closed)
Edited by Stan Hu