Skip to content
Permalink
Browse files
[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.
  • Loading branch information
Robert Elliot authored and kohsuke committed Apr 7, 2011
1 parent 31fb8b0 commit bddc4f2c1ae569dbf7af4bc73f8dcf667bf407bb
Showing with 17 additions and 3 deletions.
  1. +4 −2 core/src/main/java/hudson/model/AbstractProject.java
  2. +13 −1 core/src/main/java/hudson/model/Queue.java
@@ -98,6 +98,7 @@
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;
@@ -1071,9 +1072,10 @@ public CauseOfBlockage getCauseOfBlockage() {
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.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 @@ private void _getBuildableItems(Computer c, ItemList<BuildableItem> col, List<Bu
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 @@ protected void doRun() {
/**
* {@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) {

0 comments on commit bddc4f2

Please sign in to comment.