jenkinsci / jenkinsci/lockable-resources-plugin
[JENKINS-45131] Locking Resources is slow
- Dominant language
- Java
- Stars
- 99
- Forks
- 205
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 8
Description
Locking and Unlocking takes very long for no apparent reason.
Take this example pipeline:
node {
// change workspace to shared directory
exws(extWorkspace) {
timeout(time: 30, unit: 'MINUTES') {
stage('build') {
checkout scm
nodeEnv {
sh 'ant build'
}
milestone 1
} // stage build
} // timeout
} // exws
} // node
lock(resource: 'deploy', inversePrecedence: true) {
// do not deploy older versions of the artifacts (NON-UNIQUE-SNAPSHOTS)
milestone 2
node {
exws(extWorkspace) {
stage('deploy') {
sh 'ant deploy'
} // stage deploy
} // extws
} // node
} // lock
This is how the Build-Log looks (sometimes):
```
12:04:42 BUILD SUCCESSFUL
12:04:42 Total time: 3 minutes 37 seconds
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] milestone
12:04:42 Trying to pass milestone 1
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // timeout
[Pipeline] }
[Pipeline] // exws
[Pipeline] }
[Pipeline] // node
```
here is the first problem. I see the job leaving the node, but not that it tries to lock a resource, that message will be printed after the lock is acquired (even though the timestamp implies something else)!
```
[Pipeline] lock
12:04:42 Trying to acquire lock on [deploy]
12:13:36 Lock acquired on [deploy]
[Pipeline] {
[Pipeline] milestone
12:13:36 Trying to pass milestone 2
[Pipeline] node
```
and the second problem is that it took nearly 10 minutes to get the lock while there was only one other non related job running. So the lock should be obtainable super fast and the overall workload of the system was low.
Not only the jobs seem to have these performance drops, but also when going to /lockable-resources/ there are times when it takes minutes to see the currently locked resources.
---
Originally reported by dageissl, imported from: Locking Resources is slow
Raw content of original issue
Locking and Unlocking takes very long for no apparent reason.
Take this example pipeline:
node {
// change workspace to shared directory
exws(extWorkspace) {
timeout(time: 30, unit: 'MINUTES') {
stage('build') {
checkout scm
nodeEnv {
sh 'ant build'
}
milestone 1
} // stage build
} // timeout
} // exws
} // node
lock(resource: 'deploy', inversePrecedence: true) {
// do not deploy older versions of the artifacts (NON-UNIQUE-SNAPSHOTS)
milestone 2
node {
exws(extWorkspace) {
stage('deploy') {
sh 'ant deploy'
} // stage deploy
} // extws
} // node
} // lockThis is how the Build-Log looks (sometimes):
12:04:42 BUILD SUCCESSFUL
12:04:42 Total time: 3 minutes 37 seconds
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] milestone
12:04:42 Trying to pass milestone 1
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // timeout
[Pipeline] }
[Pipeline] // exws
[Pipeline] }
[Pipeline] // nodehere is the first problem. I see the job leaving the node, but not that it tries to lock a resource, that message will be printed after the lock is acquired (even though the timestamp implies something else)!
[Pipeline] lock
12:04:42 Trying to acquire lock on [deploy]
12:13:36 Lock acquired on [deploy]
[Pipeline] {
[Pipeline] milestone
12:13:36 Trying to pass milestone 2
[Pipeline] node
and the second problem is that it took nearly 10 minutes to get the lock while there was only one other non related job running. So the lock should be obtainable super fast and the overall workload of the system was low.
Not only the jobs seem to have these performance drops, but also when going to <yourjenkins.url>/lockable-resources/ there are times when it takes minutes to see the currently locked resources.
environment
```
Jenkins ver. 2.46.2
Lockable Resource 2.0
```
Contributor guide
Assessment
This issue has not been assessed yet.