Investigate race condition between MR diffs and MR head pipeline updates
The following discussion from !146251 (merged) should be addressed:
-
@hfyngvason started a discussion: (+1 comment) Here is an example of a possible race caused by a lagging merge request diff. When a branch pipeline is created, the associated
Ci::PipelineCreatedEvent
could get processed before the merge request'sdiff_head_sha
has been updated.This could lead to a branch pipeline not being found at the right time. I think this call ends up mostly ensuring the branch pipeline gets eventually found because this worker is only called after the diff is updated, and it would still find a branch pipeline if no MR pipeline ends up getting created. But it would be much better if the
MergeRequests::UpdateHeadPipelineWorker
just handled the event correctly to begin with. And then we could get rid of the redundantupdate_head_pipeline
call inMergeRequests::CreatePipelineWorker
(because any created pipeline should fire an event that calls the same method). -
@hfyngvason AND ANOTHER THING: This one is also suspicious. It assumes
diff_head_sha
is in sync with theref
being passed intoCi::CreatePipelineService
above, which I don't think is entirely guaranteed.