Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-52638

Lockable Resource Plugin returns null resource after saving system configuration

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • None

      The lock step can obtain a null resource after saving a global system configuration by clicking on "Manage Jenkins" -> "Configure System" -> "Save".  The bug occurs irregardless of any actual changes has been made.

      steps to reproduce

      setup

      • 4 jobs with the following configuration:
        node {
            boolean retry = true;
            while (retry) {
                lock(label: 'res1', quantity: 1, variable: 'RES_NAME') {
                    println env.RES_NAME
                    if ("${env.RES_NAME}" != "null") {
                        retry = false;
                        sleep(100)
                    }
                }
            }
        }
      • 2 resources configured "r1" and "r2", both with label "res1"
      • 4 executors.

      Steps

      1. Activate a build for each of the jobs simultaneously. 2 of the builds will obtain a lock and then proceed to sleep.  2 of the builds will be blocked waiting for a resource.
      2. Update the system configuration by clicking on "Manage Jenkins" -> "Configure System" -> "Save"
      3. One of the blocked build will obtain a "null" resource and re-trying a lock will obtain a resource that is already being used by one of the sleeping build. Demonstrated by the following snippet of the console output:
       Running on Jenkins in /var/jenkins_home/workspace/test4@2
      [Pipeline] {
      [Pipeline] lock
      Trying to acquire lock on [Label: res1, Quantity: 1]
      Found 0 available resource(s). Waiting for correct amount: 1.
      [Label: res1, Quantity: 1] is locked, waiting...
      Lock acquired on [Label: res1, Quantity: 1]
      [Pipeline] {
      [Pipeline] echo
      null
      [Pipeline] }
      Lock released on resource [Label: res1, Quantity: 1]
      [Pipeline] // lock
      [Pipeline] lock
      Trying to acquire lock on [Label: res1, Quantity: 1]
      Lock acquired on [Label: res1, Quantity: 1]
      [Pipeline] {
      [Pipeline] echo
      r1
      [Pipeline] sleep
      Sleeping for 1 min 40 sec[Pipeline] }
      Lock released on resource [Label: res1, Quantity: 1]
      [Pipeline] // lock
      [Pipeline] }
      [Pipeline] // node
      [Pipeline] End of Pipeline

            Unassigned Unassigned
            scott_zhong Scott Zhong
            Votes:
            9 Vote for this issue
            Watchers:
            11 Start watching this issue

              Created:
              Updated: