jenkinsci / jenkinsci/lockable-resources-plugin

[JENKINS-46494] Certain conditions might lock more resources than required quantity

Open
#890 6 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

In strained situations, more resources than you asked for might get locked. This creates a bottleneck problem related to resources but it cannot be solved by adding more resources.

In worst cases will always lock all resources with a certain label instead of the required amount.

You can recreate the issue by configuring a couple (say 4) of lockable resources with a tag. Trigger a bunch of these jobs with NUM_RESOURCES between 1 - 4 to build up a queue of jobs waiting for their resources to become available. Eventually the error will start appearing.

properties([

parameters ([
string(name: 'NUM_RESOURCES')
])
]);

node {
def askFor = params.NUM_RESOURCES as Integer
lock(label: "FOO", quantity: askFor) {
def clients = org.jenkins.plugins.lockableresources.LockableResourcesManager.class.get().getResourcesFromBuild(currentBuild.getRawBuild())
echo("Asked for ${askFor} resources, got ${clients.size()}: ${clients.toString()}")
sleep (60 * 10)
if (askFor != clients.size()) {
error ("Wrong amount of resources acquired")
}
}
}

---
Originally reported by mantonsson, imported from: Certain conditions might lock more resources than required quantity


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

Raw content of original issue

In strained situations, more resources than you asked for might get locked. This creates a bottleneck problem related to resources but it cannot be solved by adding more resources.

In worst cases will always lock all resources with a certain label instead of the required amount.

You can recreate the issue by configuring a couple (say 4) of lockable resources with a tag. Trigger a bunch of these jobs with NUM_RESOURCES between 1 - 4 to build up a queue of jobs waiting for their resources to become available. Eventually the error will start appearing.



properties([

parameters ([
string(name: 'NUM_RESOURCES')
])
]);

node {
def askFor = params.NUM_RESOURCES as Integer
lock(label: "FOO", quantity: askFor) {
def clients = org.jenkins.plugins.lockableresources.LockableResourcesManager.class.get().getResourcesFromBuild(currentBuild.getRawBuild())
echo("Asked for ${askFor} resources, got ${clients.size()}: ${clients.toString()}")
sleep (60 * 10)
if (askFor != clients.size()) {
error ("Wrong amount of resources acquired")
}
}
}


environment

```
CloudBees Jenkins Enterprise 2.32.2.1-rolling

lockable resources plugin version 1.x & 2.x
```

1 attachment

- [screenshot-1.png](https://issues.jenkins.io/secure/attachment/42185/screenshot-1.png)
> ![screenshot-1.png](https://issues.jenkins.io/secure/attachment/42185/screenshot-1.png)

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.