From b4bab9ebc15f2b982e38fdd39f6920384fffa290 Mon Sep 17 00:00:00 2001 From: mike o'brien Date: Wed, 29 Apr 2015 08:38:43 -0400 Subject: [PATCH] SERVER-18251 multiversion setup script should dump stacks on SIGUSR1 signal Signed-off-by: Ernie Hershey --- buildscripts/setup_multiversion_mongodb.py | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/buildscripts/setup_multiversion_mongodb.py b/buildscripts/setup_multiversion_mongodb.py index dcf65f77a76..9ba9fbf4983 100644 --- a/buildscripts/setup_multiversion_mongodb.py +++ b/buildscripts/setup_multiversion_mongodb.py @@ -7,6 +7,9 @@ import tempfile import urllib2 import subprocess import tarfile +import signal +import threading +import traceback import shutil import errno # To ensure it exists on the system @@ -17,6 +20,20 @@ import gzip # Only really tested/works on Linux. # +def dump_stacks(signal, frame): + print "======================================" + print "DUMPING STACKS due to SIGUSR1 signal" + print "======================================" + threads = threading.enumerate(); + + print "Total Threads: " + str(len(threads)) + + for id, stack in sys._current_frames().items(): + print "Thread %d" % (id) + print "".join(traceback.format_stack(stack)) + print "======================================" + + def version_tuple(version): """Returns a version tuple that can be used for numeric sorting of version strings such as '2.6.0-rc1' and '2.4.0'""" @@ -215,6 +232,12 @@ def parse_cl_args(args): def main(): + # Listen for SIGUSR1 and dump stack if received. + try: + signal.signal(signal.SIGUSR1, dump_stacks) + except AttributeError: + print "Cannot catch signals on Windows" + downloader, versions = parse_cl_args(sys.argv[1:]) for version in versions: