Capture a thread dump when Redis commands time out.

This commit is contained in:
Jon Chambers
2020-11-03 12:05:06 -05:00
committed by Jon Chambers
parent 4d5fbec5a5
commit 6c78d7544f
3 changed files with 58 additions and 11 deletions

View File

@@ -0,0 +1,27 @@
package org.whispersystems.textsecuregcm.util;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.lang.management.ManagementFactory;
import java.lang.management.ThreadInfo;
public class ThreadDumpUtil {
private static final Logger log = LoggerFactory.getLogger(ThreadDumpUtil.class);
public static void writeThreadDump() {
try {
try (final PrintWriter out = new PrintWriter(File.createTempFile("thread_dump_", ".txt"))) {
for (ThreadInfo info : ManagementFactory.getThreadMXBean().dumpAllThreads(true, true)) {
out.print(info);
}
}
} catch (final IOException e) {
log.warn("Failed to write thread dump", e);
}
}
}