jenkinsci / jenkinsci/lockable-resources-plugin

[JENKINS-57338] Lockable resource didn't work, if two jobs acquires lock at same time

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

Description

Lockable resource is used in the options block of the pipeline like this: 

options {

       timestamps()

       skipDefaultCheckout()

       lock resource: "Lock_Slave_${SlaveName.split(',').first()}"

       timeout(time: "$JobTimeout" as Integer, unit: "HOURS")

}

There are three jobs in the Jenkins System, which are using the same SlaveName (build with parameters parameter). All 3 jobs are started at the same time. After the first job is started, the other 2 jobs waits for the lock. After the job is done, the two other jobs acquires the lock at the same time. 

 

Console log job 1:

2019-05-02 10:23:55  Trying to acquire lock on [Lock_Slave_TIS_MainTargets]

2019-05-02 10:23:55  Found 0 available resource(s). Waiting for correct amount: 1.

2019-05-02 10:23:55  [Lock_Slave_TIS_MainTargets] is locked, waiting...

2019-05-02 11:05:58  Lock acquired on [Lock_Slave_TIS_MainTargets]

 

Console log job 2:

2019-05-02 10:24:52  Trying to acquire lock on [Lock_Slave_TIS_MainTargets]

2019-05-02 10:24:52  Found 0 available resource(s). Waiting for correct amount: 1.

2019-05-02 10:24:52  [Lock_Slave_TIS_MainTargets] is locked, waiting...

2019-05-02 11:05:58  Lock acquired on [Lock_Slave_TIS_MainTargets]

 

As you can see, the two jobs acquires the lock "Lock_Slave_TIS_MainTargets" at the same time. 

 

Get in contact with me if you need more information. Thanks in advance! 

 

 

---
Originally reported by mibe, imported from: Lockable resource didn't work, if two jobs acquires lock at same time


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

Raw content of original issue

Lockable resource is used in the options block of the pipeline like this: 

options {
       timestamps()
       skipDefaultCheckout()
       lock resource: "Lock_Slave_${SlaveName.split(',').first()}"
       timeout(time: "$JobTimeout" as Integer, unit: "HOURS")
}

There are three jobs in the Jenkins System, which are using the same SlaveName (build with parameters parameter). All 3 jobs are started at the same time. After the first job is started, the other 2 jobs waits for the lock. After the job is done, the two other jobs acquires the lock at the same time. 

 

Console log job 1:

2019-05-02 10:23:55  Trying to acquire lock on [Lock_Slave_TIS_MainTargets]

2019-05-02 10:23:55  Found 0 available resource(s). Waiting for correct amount: 1.

2019-05-02 10:23:55  [Lock_Slave_TIS_MainTargets] is locked, waiting...

2019-05-02 11:05:58  Lock acquired on [Lock_Slave_TIS_MainTargets]

 

Console log job 2:

2019-05-02 10:24:52  Trying to acquire lock on [Lock_Slave_TIS_MainTargets]

2019-05-02 10:24:52  Found 0 available resource(s). Waiting for correct amount: 1.

2019-05-02 10:24:52  [Lock_Slave_TIS_MainTargets] is locked, waiting...

2019-05-02 11:05:58  Lock acquired on [Lock_Slave_TIS_MainTargets]

 

As you can see, the two jobs acquires the lock "Lock_Slave_TIS_MainTargets" at the same time. 

 

Get in contact with me if you need more information. Thanks in advance! 

 

 

environment

```
Jenkins ver. 2.164.2

Lockable Resources plugin version: 2.5
```

Contributor guide

Open the contributing guide

Research direction

No source file or test is named in the report. Start by reproducing the three-job scenario with Jenkins 2.164.2 and Lockable Resources 2.5, then trace the lock acquisition path; done means two waiting jobs cannot acquire the same resource simultaneously.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend, devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.