From 2ea7ee0dcb831eaa9e4a05c078011c455bb66148 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Sat, 26 Mar 2016 13:34:21 -0400 Subject: [PATCH] Add thread traces to USR1 handler When receiving a USR1 signal, it did usefully provide 'the' current stack, useful for diagnosing really hard hangs. However, it's frequently informative to see all the thread stack traces, so add that data to the diagnostic feature. --- confluent_server/confluent/main.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/confluent_server/confluent/main.py b/confluent_server/confluent/main.py index 9acc7cb2..2eaee4da 100644 --- a/confluent_server/confluent/main.py +++ b/confluent_server/confluent/main.py @@ -50,6 +50,8 @@ try: except ImportError: havefcntl = False #import multiprocessing +import gc +from greenlet import greenlet import sys import os import signal @@ -129,6 +131,13 @@ def dumptrace(signalname, frame): ht = open('/var/log/confluent/hangtraces', 'a') ht.write('Dumping active trace on ' + time.strftime('%X %x\n')) ht.write(''.join(traceback.format_stack(frame))) + for o in gc.get_objects(): + if not isinstance(o, greenlet): + continue + if not o: + continue + ht.write('Thread trace:\n') + ht.write(''.join(traceback.format_stack(o.gr_frame))) ht.close() def doexit():