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:

    1. The merge_request_pipeline_exists? gonna return false, for diff_head_sha=A,
    2. The diff_head_sha gonna be updated to B,
    3. The another call (concurrent) will make the merge_request_pipeline_exists? to return false,
    4. Two CreatePipelineServices gonna be executed.

    I think that we should:

    1. Extend the create_merge_request_pipeline with sha,
    2. We gonna pass merge_request.diff_head_sha to this method call,
    3. Run return if merge_request.merge_request_pipeline_exists?(sha),
    4. To Ci::CreatePipelineService pass ref: merge_request.source_branch, sha: sha.

    Feel free to resolve that as extra MR.