jenkinsci / jenkinsci/lockable-resources-plugin
Critical section in pipeline is entered without lock
- Dominant language
- Java
- Stars
- 99
- Forks
- 205
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 8
Description
It seems that sometimes the critical section in pipeline is entered without lock. Please see the job configs below, which are "a bit" simplified from our real ones. The problem happens in the following scenario: JOB1 is running a build and has locked the resource:"lab1" via "CI_LAB"-label. I trigger JOB2, the build for JOB2 correctly starts waiting for the lock on "lab1". When JOB1 ends, JOB2 enters the critical section, and the lock tells that it got the lock for "lab1" - but when I look at the "Lockable Resources" UI in Jenkins, the resource has no lock, and other jobs can lock the resource even though JOB2 is still in the critical section!
lockable resources plugin: 1.11.2
jenkins: 1.644
pipeline:2.4
JOB1 does:
```
LAB_LABEL="CI_LAB"
SEQUENCER_LABEL="LONG_RUN_SEQUENCER"
lock ( label: "$SEQUENCER_LABEL") {
lock (label: "$LAB_LABEL", Quantity:1) {
// job1 critical section
}
}
```
JOB2 does:
```
LAB_RESOURCE=lab1
lock ( "$LAB_RESOURCE" ) {
// job2 critical section
}
```
We have the following lockable resources(simplified listing for the problem scenario):
```
Name:LONG_RUN_SEQUENCER, Labels:LONG_RUN_SEQUENCER //only one resource with this label
Name:lab1, Labels:LAB1 CI_LAB
Name:lab2, Labels:LAB2 CI_LAB
```
Ideas:
* could the nested lock in JOB1 cause this somehow?
* or could it be caused by JOB1 having locked the resource using label, while JOB2 locks the same resource using the resource name?
* or maybe just some other concurrency bug?
Contributor guide
Assessment
This issue has not been assessed yet.