[JIRA] (JENKINS-60702) Two calls to the build function can trigger the same run

3 views
Skip to first unread message

jenkins@mrozekma.com (JIRA)

unread,
Jan 8, 2020, 5:15:03 PM1/8/20
to jenkinsc...@googlegroups.com
Michael Mrozek created an issue
 
Jenkins / Bug JENKINS-60702
Two calls to the build function can trigger the same run
Issue Type: Bug Bug
Assignee: Unassigned
Components: pipeline-build-step-plugin
Created: 2020-01-08 22:14
Environment: Jenkins 2.211
Pipeline: API 2.38
Pipeline: Build Step 2.11
Priority: Minor Minor
Reporter: Michael Mrozek

I'm not certain which component is responsible for this, so I went with the Pipeline Build Step plugin. When using build to trigger another job, there seems to be a race condition where two calls to the function at approximately the same time with the same target job can both "start" the exact same run. For example, this code (the target job is irrelevant, I just happened to have an empty Freestyle job hanging around to test with):

parallel (
    First : { build job: "Test/Freestyle", wait: true },
    Second: { build job: "Test/Freestyle", wait: true },
)

causes the following:

Branch event
Obtained Jenkinsfile from 9c8963507d90d9cc4c8acb030efa07ca8a7d8d25
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] Start of Pipeline
[Pipeline] parallel
[Pipeline] { (Branch: First)
[Pipeline] { (Branch: Second)
[Pipeline] build
Scheduling project: Test » Freestyle
[Pipeline] build
Scheduling project: Test » Freestyle
Starting building: Test » Freestyle #1
Starting building: Test » Freestyle #1
[Pipeline] }
[Pipeline] }
[Pipeline] // parallel
[Pipeline] End of Pipeline
Finished: SUCCESS

Notice that instead of starting Test/Freestyle twice, both branches claim to have started run #1. Adding a sleep in one of the parallel branches fixes it, but I think this can happen any time two jobs happen to try and fork the same target job at the same time.

This might be the same as JENKINS-55210; I can't tell for sure.

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.13.6#713006-sha1:cc4451f)
Atlassian logo

jenkins@mrozekma.com (JIRA)

unread,
Jan 8, 2020, 6:46:02 PM1/8/20
to jenkinsc...@googlegroups.com
Michael Mrozek closed an issue as Not A Defect
 

Never mind! After pawing through the code I discovered this is intentional behavior. I thought it had to be a bug because in my real job (not the simple test I posted in the description) I'm passing in different build parameters for the two calls, but due to an unrelated problem the target job wasn't actually declaring those parameters, so they got filtered out.

This no longer affects me now that I've fixed the parameterization problem, but I will add that I'm not 100% sure this behavior makes sense. I assume there's a good reason for the build action folding mechanism, but if job A tells Jenkins to build downstream job B twice, I would expect Jenkins to build it twice.

Change By: Michael Mrozek
Status: Open Closed
Resolution: Not A Defect
Reply all
Reply to author
Forward
0 new messages