summaryrefslogtreecommitdiffstats
path: root/node-repository
diff options
context:
space:
mode:
authorHåkon Hallingstad <hakon@verizonmedia.com>2020-09-24 17:25:11 +0200
committerHåkon Hallingstad <hakon@verizonmedia.com>2020-09-24 17:25:11 +0200
commit18cf8e6154be4d6d1fb0399ba9fec2d26408740d (patch)
treecb988a6042ecfe22fb2077f08f3d25ecf3d444f7 /node-repository
parent731ec8fb898164b066b64d26019a74aa13b08710 (diff)
Make stacktraces for active locks during request handling
Diffstat (limited to 'node-repository')
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/LocksResponse.java24
1 files changed, 16 insertions, 8 deletions
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/LocksResponse.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/LocksResponse.java
index 502bd6f3cd7..24321cd8a20 100644
--- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/LocksResponse.java
+++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/LocksResponse.java
@@ -49,15 +49,23 @@ public class LocksResponse extends HttpResponse {
List<ThreadLockInfo> threadLockInfos = ThreadLockInfo.getThreadLockInfos();
Cursor threadsCursor = root.setArray("threads");
- threadLockInfos.forEach(threadLockInfo -> {
- Cursor threadLockInfoCursor = threadsCursor.addObject();
- threadLockInfoCursor.setString("thread-name", threadLockInfo.getThreadName());
- threadLockInfoCursor.setString("lock-path", threadLockInfo.getLockPath());
-
+ int numberOfStackTraces = 0;
+ for (var threadLockInfo : threadLockInfos) {
List<LockInfo> lockInfos = threadLockInfo.getLockInfos();
- Cursor lockInfosCursor = threadLockInfoCursor.setArray("locks");
- lockInfos.forEach(lockInfo -> setLockInfo(lockInfosCursor.addObject(), lockInfo, false));
- });
+ if (!lockInfos.isEmpty()) {
+ Cursor threadLockInfoCursor = threadsCursor.addObject();
+ threadLockInfoCursor.setString("thread-name", threadLockInfo.getThreadName());
+ threadLockInfoCursor.setString("lock-path", threadLockInfo.getLockPath());
+
+ Cursor lockInfosCursor = threadLockInfoCursor.setArray("active-locks");
+ for (var lockInfo : lockInfos) {
+ if (numberOfStackTraces++ < 10) { // Expensive to generate stack traces?
+ lockInfo.fillStackTrace();
+ }
+ setLockInfo(lockInfosCursor.addObject(), lockInfo, false);
+ }
+ }
+ }
List<LockInfo> slowLockInfos = ThreadLockInfo.getSlowLockInfos();
Cursor slowLocksCursor = root.setArray("slow-locks");