-
Bug
-
Resolution: Fixed
-
Critical
-
Jenkins 2.7.1
Jenkins 2.49
Pipeline plugin 2.4
-
-
Jenkins 2.136
I have configured a Jenkins pipeline to disable concurrent builds:
properties([ disableConcurrentBuilds() ])
However, I have noticed on some occasions the next 2 builds are pulled from the pipeline's queue and executed concurrently. Why this occurs is not obvious at all.
- relates to
-
JENKINS-30231 Build creates second workspace@2 for non-concurrent build configuration
-
- Resolved
-
- links to
So Queue#maintain() is running twice, one immediately after the other, in some cases - probably race conditiony, not yet sure how the two are getting called. Anyway, the first run is making the first item in the queue buildable and calls makeBuildable on the item, removing said item from blockedProjects, and, via makeFlyweightTaskBuildable and createFlyWeightTaskRunnable, starting the flyweight task and adding the first item to pendings. All is well and good. But then the next run of maintain starts - and it can't find the task for the item we just started (theoretically) and put in pendings on any executor...so it removes the item from pendings. Then it gets to checking the queue again, and the new first item doesn't have anything blocking it (i.e., nothing in buildables or pending) and so...it goes through the same process as the previous item did in the previous maintain run. End result: two builds get started at the same time.
So - definitely a race condition.