jenkinsci / jenkinsci/lockable-resources-plugin

[JENKINS-70304] Locking a resource while holding it locked in the same job is not possible

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

Description

Locking a resource while holding it locked in the same job like this:

lock(resource: 'res1'){

sleep(time: 2, unit: 'SECONDS')
lock(resource: 'res1'){
sleep(time: 2, unit: 'SECONDS')
 }
}

results in indefinite wait:

Trying to acquire lock on [res1]

Resource [res1] did not exist. Created.
Lock acquired on [res1]
[Pipeline] {
[Pipeline] sleep
Sleeping for 2 sec
[Pipeline] lock
Trying to acquire lock on [res1]
Found 0 available resource(s). Waiting for correct amount: 1.
[res1] is locked by job-name #NN waiting...

I would expect the inner lock to be granted immediately since the job has already acquired exclusive access to the resource.

---
Originally reported by epliskin, imported from: Locking a resource while holding it locked in the same job is not possible


  • status: Open
  • priority: Minor
  • component(s): lockable-resources-plugin
  • resolution: Unresolved
  • votes: 1
  • watchers: 2
  • imported: 20251217-081411

Raw content of original issue

Locking a resource while holding it locked in the same job like this:



lock(resource: 'res1'){

sleep(time: 2, unit: 'SECONDS')
lock(resource: 'res1'){
sleep(time: 2, unit: 'SECONDS')
 }
}


results in indefinite wait:



Trying to acquire lock on [res1]

Resource [res1] did not exist. Created.
Lock acquired on [res1]
[Pipeline] {
[Pipeline] sleep
Sleeping for 2 sec
[Pipeline] lock
Trying to acquire lock on [res1]
Found 0 available resource(s). Waiting for correct amount: 1.
[res1] is locked by job-name #NN waiting...


I would expect the inner lock to be granted immediately since the job has already acquired exclusive access to the resource.

  • environment: Jenkins version 2.363, Lockable Resources plugin version 2.15. Windows 10.

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.