http://repo.jenkins-ci.org/snapshots/org/jenkins-ci/main/jenkins-war/1.609-SNAPSHOT/jenkins-war-1.609-20150411.073620-2.war is an alternative attempt. It would be good if you could confirm that it also resolves the issue.

diff --git a/core/src/main/java/hudson/model/Queue.java b/core/src/main/java/hudson/model/Queue.java
index d776a57..3c9367a 100644
--- a/core/src/main/java/hudson/model/Queue.java
+++ b/core/src/main/java/hudson/model/Queue.java
@@ -844,6 +844,17 @@ public class Queue extends ResourceController implements Saveable {
      * Gets all the {@link BuildableItem}s that are waiting for an executor in the given {@link Computer}.
      */
     public List<BuildableItem> getBuildableItems(Computer c) {
+        if (lock.tryLock()) {
+            // JENKINS-22708 and JENKINS-27871, if we can get the lock, return live
+            try {
+                List<BuildableItem> result = new ArrayList<BuildableItem>();
+                _getBuildableItems(c, buildables, result);
+                _getBuildableItems(c, pendings, result);
+                return result;
+            } finally {
+                lock.unlock();
+            }
+        }
         Snapshot snapshot = this.snapshot;
         List<BuildableItem> result = new ArrayList<BuildableItem>();
         _getBuildableItems(c, snapshot.buildables, result);
@@ -865,6 +876,16 @@ public class Queue extends ResourceController implements Saveable {
      * Gets the snapshot of all {@link BuildableItem}s.
      */
     public List<BuildableItem> getBuildableItems() {
+        if (lock.tryLock()) {
+            // JENKINS-22708 and JENKINS-27871, if we can get the lock, return live
+            try {
+                ArrayList<BuildableItem> r = new ArrayList<BuildableItem>(buildables);
+                r.addAll(pendings);
+                return r;
+            } finally {
+                lock.unlock();
+            }
+        }
         Snapshot snapshot = this.snapshot;
         ArrayList<BuildableItem> r = new ArrayList<BuildableItem>(snapshot.buildables);
         r.addAll(snapshot.pendings);
@@ -875,6 +896,14 @@ public class Queue extends ResourceController implements Saveable {
      * Gets the snapshot of all {@link BuildableItem}s.
      */
     public List<BuildableItem> getPendingItems() {
+        if (lock.tryLock()) {
+            // JENKINS-22708 and JENKINS-27871, if we can get the lock, return live
+            try {
+                return new ArrayList<BuildableItem>(pendings);
+            } finally {
+                lock.unlock();
+            }
+        }
         return new ArrayList<BuildableItem>(snapshot.pendings);
     }
 
@@ -902,6 +931,19 @@ public class Queue extends ResourceController implements Saveable {
      * @since 1.402
      */
     public List<Item> getUnblockedItems() {
+        if (lock.tryLock()) {
+            // JENKINS-22708 and JENKINS-27871, if we can get the lock, return live
+            try {
+                List<Item> queuedNotBlocked = new ArrayList<Item>();
+                queuedNotBlocked.addAll(waitingList);
+                queuedNotBlocked.addAll(buildables);
+                queuedNotBlocked.addAll(pendings);
+                // but not 'blockedProjects'
+                return queuedNotBlocked;
+            } finally {
+                lock.unlock();
+            }
+        }
         Snapshot snapshot = this.snapshot;
         List<Item> queuedNotBlocked = new ArrayList<Item>();
         queuedNotBlocked.addAll(snapshot.waitingList);
@@ -928,6 +970,16 @@ public class Queue extends ResourceController implements Saveable {
      * Is the given task currently pending execution?
      */
     public boolean isPending(Task t) {
+        if (lock.tryLock()) {
+            try {
+                for (BuildableItem i : pendings)
+                    if (i.task.equals(t))
+                        return true;
+                return false;
+            } finally {
+                lock.unlock();
+            }
+        }
         Snapshot snapshot = this.snapshot;
         for (BuildableItem i : snapshot.pendings)
             if (i.task.equals(t))

If both work then I will fire each up on my test bed environment and see which passes the concurrency and lock stress... then we commit the simpler fix.

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators.
For more information on JIRA, see: http://www.atlassian.com/software/jira

--
You received this message because you are subscribed to the Google Groups "Jenkins Issues" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-issues+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to