jenkinsci / lockable-resources-plugin

Lock resources against concurrent use
https://plugins.jenkins.io/lockable-resources
MIT License
87 stars 183 forks source link

Critical section in pipeline is entered without lock #83

Open karniemi opened 6 years ago

karniemi commented 6 years ago

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:

jimklimov commented 2 years ago

Would it be possible for you to try reproducing the issue with current plugin release (2.14 or newer), if the issue is still valid?