From 3dc0a444068601a61930af4c422ffefdd0928063 Mon Sep 17 00:00:00 2001 From: Jesse Glick Date: Mon, 14 Apr 2014 12:27:02 -0400 Subject: [PATCH] [JENKINS-21622] Trying to diagnose who is acquiring workspace leases when and why. --- .../main/java/hudson/slaves/WorkspaceList.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/core/src/main/java/hudson/slaves/WorkspaceList.java b/core/src/main/java/hudson/slaves/WorkspaceList.java index 78fdac9fc8b7..b6dd917da314 100644 --- a/core/src/main/java/hudson/slaves/WorkspaceList.java +++ b/core/src/main/java/hudson/slaves/WorkspaceList.java @@ -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); @@ -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); @@ -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)); @@ -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()); /**