Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix locking for freestyle jobs
Freestyle jobs did not hold the resource locks properly,
as they did not record the queueProjectName to the queue.
Any blocked jobs would give up waiting after QUEUE_TIMEOUT
seconds in the queue, even if there was a job blocking.

Fixes: JENKINS-47754
  • Loading branch information
Aga303 committed Oct 31, 2017
1 parent 3a9e649 commit c20d996
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Expand Up @@ -158,12 +158,13 @@ public LockableResource fromName(String resourceName) {
}

public synchronized boolean queue(List<LockableResource> resources,
long queueItemId) {
long queueItemId, String queueProjectName) {
for (LockableResource r : resources)
if (r.isReserved() || r.isQueued(queueItemId) || r.isLocked())
return false;
for (LockableResource r : resources)
r.setQueued(queueItemId);
for (LockableResource r : resources) {
r.setQueued(queueItemId, queueProjectName);
}
return true;
}

Expand Down
Expand Up @@ -140,7 +140,7 @@ public CauseOfBlockage canRun(Queue.Item item) {
}

} else {
if (LockableResourcesManager.get().queue(resources.required, item.getId())) {
if (LockableResourcesManager.get().queue(resources.required, item.getId(), project.getFullDisplayName())) {
LOGGER.finest(project.getName() + " reserved resources " + resources.required);
return null;
} else {
Expand Down

0 comments on commit c20d996

Please sign in to comment.