Race condition when enqueuing builds to run
Summary
In Ci::PlayBuildService#play
, we run two commands: build.enqueue
, followed by build.update(current_user: ..., job_variables_attributes: ...)
I think it's theoretically possible for us to enqueue a build, which is then picked up and run without the correct user or job variables set.
Steps to reproduce
Easiest is probably to add a sleep(120)
between the enqueue and update, to aggravate the problem.
What is the current bug behavior?
Job runs without correct variables set
What is the expected correct behavior?
Job should not be enqueued until the system is ready to service it fully
Possible fixes
https://gitlab.com/gitlab-org/gitlab-ce/blob/master/app/services/ci/play_build_service.rb#L12
/cc @matteeyah