mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-16 21:42:27 +00:00
[FIXED JENKINS-8929] Changed the definition of a building downstream project to one that is Building, Waiting, Pending or Buildable
but NOT blocked. This prevents the deadlock condition where upstream project A is blocked on downstream project B, which is blocked on upstream project A - now in this scenario B will remain blocked but A will build, eventually freeing up B.
This commit is contained in:
1 parent
114546f538
commit
b40e7b4228
2 files changed
+17
-3
No files matched your search
@@ -100,6 +100,7 @@ import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@@ -1082,9 +1083,10 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
|
||||
protected AbstractProject getBuildingDownstream() {
|
||||
DependencyGraph graph = Hudson.getInstance().getDependencyGraph();
|
||||
Set<AbstractProject> tups = graph.getTransitiveDownstream(this);
|
||||
tups.add(this);
|
||||
Queue queue = Hudson.getInstance().getQueue();
|
||||
|
||||
for (AbstractProject tup : tups) {
|
||||
if(tup!=this && (tup.isBuilding() || tup.isInQueue()))
|
||||
if(tup.isBuilding() || queue.getUnblockedItems().containsKey(tup))
|
||||
return tup;
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -77,6 +77,7 @@ import java.util.Collections;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.NoSuchElementException;
|
||||
@@ -633,6 +634,17 @@ public class Queue extends ResourceController implements Saveable {
|
||||
return new ArrayList<BuildableItem>(pendings.values());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all items that are in the queue but not blocked
|
||||
*/
|
||||
synchronized ItemList<Item> getUnblockedItems() {
|
||||
ItemList<Item> queuedNotBlocked = new ItemList<Item>();
|
||||
queuedNotBlocked.addAll(waitingList);
|
||||
queuedNotBlocked.addAll(pendings);
|
||||
queuedNotBlocked.addAll(buildables);
|
||||
return queuedNotBlocked;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the given task currently pending execution?
|
||||
*/
|
||||
@@ -1557,7 +1569,7 @@ public class Queue extends ResourceController implements Saveable {
|
||||
/**
|
||||
* {@link ArrayList} of {@link Item} with more convenience methods.
|
||||
*/
|
||||
private static class ItemList<T extends Item> extends ArrayList<T> {
|
||||
static class ItemList<T extends Item> extends ArrayList<T> {
|
||||
public T get(Task task) {
|
||||
for (T item: this) {
|
||||
if (item.task == task) {
|
||||
|
||||
Reference in new issue
Block a user