jenkinsci / jenkinsci/lockable-resources-plugin

[JENKINS-52638] Lockable Resource Plugin returns null resource after saving system configuration

Open
#910 4 comments 0 reactions 0 assignees View on GitHub
component:lockable-resources-plugin imported-jira-issue priority:major resolution:unresolved Triage
Dominant language
Java
Stars
99
Forks
205
Avg merge
2d 13h
Merged PRs (30d)
8

Description

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
```

---
Originally reported by scott_zhong, imported from: Lockable Resource Plugin returns null resource after saving system configuration


  • status: Open
  • priority: Major
  • component(s): lockable-resources-plugin
  • resolution: Unresolved
  • votes: 9
  • watchers: 11
  • imported: 20251217-081411

Raw content of original issue

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

environment

```
CentOS 7.4 host

java-8-openjdk-amd64

jenkins/jenkins:lts docker image

JENKINS_VERSION 2.121.2

lockable-resources 2.3

full plugin list:

ace-editor 1.1 true

ant 1.8 true

antisamy-markup-formatter 1.5 true

apache-httpcomponents-client-4-api 4.5.5-3.0 true

authentication-tokens 1.3 true

bouncycastle-api 2.16.3 true

branch-api 2.0.20 true

build-timeout 1.19 true

cloudbees-folder 6.5.1 true

command-launcher 1.2 true

credentials 2.1.17 true

credentials-binding 1.16 true

display-url-api 2.2.0 true

docker-commons 1.13 true

docker-workflow 1.17 true

durable-task 1.22 true

email-ext 2.62 true

git 3.9.1 true

git-client 2.7.2 true

git-server 1.7 true

github 1.29.2 true

github-api 1.92 true

github-branch-source 2.3.6 true

gradle 1.29 true

handlebars 1.1.1 true

jackson2-api 2.8.11.3 true

jdk-tool 1.1 true

jquery-detached 1.2.1 true

jsch 0.1.54.2 true

junit 1.24 true

ldap 1.20 true

lockable-resources 2.3 true

mailer 1.21 true

mapdb-api 1.0.9.0 true

matrix-auth 2.3 true

matrix-project 1.13 true

momentjs 1.1.1 true

pam-auth 1.3 true

pipeline-build-step 2.7 true

pipeline-github-lib 1.0 true

pipeline-graph-analysis 1.7 true

pipeline-input-step 2.8 true

pipeline-milestone-step 1.3.1 true

pipeline-model-api 1.3.1 true

pipeline-model-declarative-agent 1.1.1 true

pipeline-model-definition 1.3.1 true

pipeline-model-extensions 1.3.1 true

pipeline-rest-api 2.10 true

pipeline-stage-step 2.3 true

pipeline-stage-tags-metadata 1.3.1 true

pipeline-stage-view 2.10 true

plain-credentials 1.4 true

resource-disposer 0.11 true

scm-api 2.2.7 true

script-security 1.44 true

ssh-credentials 1.14 true

ssh-slaves 1.26 true

structs 1.14 true

subversion 2.11.1 true

throttle-concurrents 2.0.1 true

timestamper 1.8.10 true

token-macro 2.5 true

workflow-aggregator 2.5 true

workflow-api 2.28 true

workflow-basic-steps 2.9 true

workflow-cps 2.54 true

workflow-cps-global-lib 2.9 true

workflow-durable-task-step 2.19 true

workflow-job 2.23 true

workflow-multibranch 2.20 true

workflow-scm-step 2.6 true

workflow-step-api 2.16 true

workflow-support 2.19 true

ws-cleanup 0.34 true

```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.