-
Bug
-
Resolution: Fixed
-
Critical
-
None
-
windows
[test case] -> this test case is similar as test case from JENKINS-12077
// settings
1. create matrix project
2. create axis1 [a b], axis2 [c d]
3. create LOCK-$EXPORTED_AXIS1
4. Inject environment variables to the build process EXPORTED_AXIS1=$axis1
5. add critical-block-start
6. add windows batch command e.g. dir d:\ /s /b | find "lock"
7. add critical-block-end
// running
8. run build -> #1
9. run build and stop it -> #2
10. run build it -> it causes 'deadlock' there is unreleased resource from build #2
I write (locally) simple patch in IdAllocationManager.java which can works. It release resource from completed build whom downstream projects are also completed.
new method:
private void releaseDeadlockedResource(String id, BuildListener buildListener) throws InterruptedException, IOException {
PrintStream logger = buildListener.getLogger();
// check if 'lockable resource' exists
AbstractBuild resourceOwner = ids.get(id);
if (resourceOwner != null && !resourceOwner.isBuilding()) { // build was completed
List<AbstractProject> downstreamProjects = resourceOwner.getProject().getDownstreamProjects();
boolean canRelease = true;
for (Iterator<AbstractProject> it = downstreamProjects.iterator(); it.hasNext() {
AbstractProject proj = it.next();
if (proj.isBuilding())
}
if (canRelease)
}
}
and changes in allocate() method:
public synchronized String allocate(AbstractBuild owner, String id, BuildListener buildListener) throws InterruptedException, IOException {
PrintStream logger = buildListener.getLogger();
boolean printed = false;
while (ids.get(id) != null) {
if (printed == false)
wait(1000);
// periodically detect if any locked resource belongs to the completed build
releaseDeadlockedResource(id, buildListener);
}
ids.put(id, owner);
return id;
}