Fix a small race condition on MR pipelines guard
The following discussion from !23217 (merged) should be addressed:
-
@ayufan started a discussion: This has slight race-condition:
- The
merge_request_pipeline_exists?
gonna return false, for diff_head_sha=A, - The diff_head_sha gonna be updated to B,
- The another call (concurrent) will make the
merge_request_pipeline_exists?
to return false, - Two
CreatePipelineServices
gonna be executed.
I think that we should:
- Extend the
create_merge_request_pipeline
withsha
, - We gonna pass
merge_request.diff_head_sha
to this method call, - Run
return if merge_request.merge_request_pipeline_exists?(sha)
, - To
Ci::CreatePipelineService
passref: merge_request.source_branch, sha: sha
.
Feel free to resolve that as extra MR.
- The