UserMergeBranch should emit an error when update ref fails
While attempting to merge gitlab!59539 (comment 558407230), I got:
This happens when Rails doesn't get a commit ID from Gitaly: https://gitlab.com/gitlab-org/gitlab/blob/4883fb192aad0abd3baa179965cb6ca672c2d10f/app/services/merge_requests/merge_service.rb#L78-85
The Gitaly logs didn't show anything of interest (https://log.gprd.gitlab.net/goto/f3a46effc08dc2f8dd33c64c8fdc13d7):
I think /internal/allowed and /internal/pre-receive succeeded, but it's hard to tell.
Retrying the merge succeeded, though.
Looking at https://gitlab.com/gitlab-org/gitaly/blob/53ea4846e77086bf6766a1dca6c8949b39048f3b/internal/gitaly/service/operations/merge.go#L114-118, I suspect there was an update ref issue that caused this quiet failure. Look at the timestamps between UpdateHeadPipelineForMergeRequestWorker and the MergeService ERROR:
Some suggestions for improvements here:
- Send more details about the error in RPC. Have Rails handle it and render a more useful message: "Error merging due to an update ref lock. Try again"
- Add these details in the JSON log
- Consider retrying the update ref if there's a lock conflict?
/cc: @pks-t, @proglottis


