Skip to content

Commit

Permalink
[JENKINS-21622] Trying to diagnose who is acquiring workspace leases …
Browse files Browse the repository at this point in the history
…when and why.
  • Loading branch information
jglick committed Apr 14, 2014
1 parent 767ccc6 commit 3dc0a44
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions core/src/main/java/hudson/slaves/WorkspaceList.java
Expand Up @@ -176,7 +176,9 @@ public synchronized Lease allocate(FilePath base, Object context) throws Interru
* Just record that this workspace is being used, without paying any attention to the synchronization support.
*/
public synchronized Lease record(FilePath p) {
log("recorded "+p);
if (LOGGER.isLoggable(Level.FINE)) {
LOGGER.log(Level.FINE, "recorded " + p, new Throwable("from " + this));
}
Entry old = inUse.put(p, new Entry(p, false));
if (old!=null)
throw new AssertionError("Tried to record a workspace already owned: "+old);
Expand All @@ -190,6 +192,9 @@ private synchronized void _release(FilePath p) {
Entry old = inUse.get(p);
if (old==null)
throw new AssertionError("Releasing unallocated workspace "+p);
if (LOGGER.isLoggable(Level.FINE)) {
LOGGER.log(Level.FINE, "releasing " + p + " with lock count " + old.lockCount, new Throwable("from " + this));
}
old.lockCount--;
if (old.lockCount==0)
inUse.remove(p);
Expand Down Expand Up @@ -240,7 +245,9 @@ public synchronized Lease acquire(FilePath p, boolean quick, Object context) thr
} finally {
t.setName(oldName);
}
log("acquired "+p);
if (LOGGER.isLoggable(Level.FINE)) {
LOGGER.log(Level.FINE, "acquired " + p + (e == null ? "" : " with lock count " + e.lockCount), new Throwable("from " + this));
}

if (e!=null) e.lockCount++;
else inUse.put(p,new Entry(p,quick,context));
Expand All @@ -258,11 +265,6 @@ public void release() {
};
}

private void log(String msg) {
if (LOGGER.isLoggable(Level.FINE))
LOGGER.fine(Thread.currentThread().getName() + " " + msg);
}

private static final Logger LOGGER = Logger.getLogger(WorkspaceList.class.getName());

/**
Expand Down

0 comments on commit 3dc0a44

Please sign in to comment.