summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Timmons <ryan.timmons@mongodb.com>2019-10-22 21:59:21 +0000
committerevergreen <evergreen@mongodb.com>2019-10-22 21:59:21 +0000
commita2ab511f0191a8dabf0962c52fe41325700a3b6d (patch)
tree047b0d4410ab4b90a956102d43c5df83cf68e1fe
parent8d048a3bb2f0f2f81cf99ce76ff21112bf3963d6 (diff)
downloadmongo-a2ab511f0191a8dabf0962c52fe41325700a3b6d.tar.gz
SERVER-44017 hang_analyzer.py inflates debug-symbols
-rwxr-xr-xbuildscripts/hang_analyzer.py57
-rw-r--r--etc/evergreen.yml30
2 files changed, 61 insertions, 26 deletions
diff --git a/buildscripts/hang_analyzer.py b/buildscripts/hang_analyzer.py
index 67a4ef97e1c..ce92c7b1be5 100755
--- a/buildscripts/hang_analyzer.py
+++ b/buildscripts/hang_analyzer.py
@@ -487,6 +487,61 @@ class JstackWindowsDumper(object):
root_logger.warning("Debugger jstack not supported, skipping dumping of %d", pid)
+class DebugExtractor(object):
+ """Extracts `mongo-debugsymbols.tgz`."""
+
+ @staticmethod
+ def extract_debug_symbols(root_logger):
+ """
+ Extract debug symbols. Idempotent.
+
+ :param root_logger: logger to use
+ :return: None
+ """
+ path = os.path.join(os.getcwd(), 'mongo-debugsymbols.tgz')
+ root_logger.debug('Starting: Extract debug-symbols from %s.', path)
+ if not os.path.exists(path):
+ root_logger.info('Debug-symbols archive-file does not exist. '
+ 'Hang-Analyzer may not complete successfully, '
+ 'or debug-symbols may already be extracted.')
+ return
+ try:
+ DebugExtractor._exxtract_tar(path, root_logger)
+ root_logger.debug('Finished: Extract debug-symbols from %s.', path)
+ # We never want this to cause the whole task to fail.
+ # The rest of hang_analyzer.py will continue to work without the
+ # symbols it just won't be quite as helpful.
+ # pylint: disable=broad-except
+ except Exception as exception:
+ root_logger.warning('Error when extracting %s: %s', path, exception)
+
+ @staticmethod
+ def _exxtract_tar(path, root_logger):
+ import shutil
+ # The file name is always .tgz but it's "secretly" a zip file on Windows :(
+ compressed_format = 'zip' if _IS_WINDOWS else 'gztar'
+ shutil.unpack_archive(path, format=compressed_format)
+ for (src, dest) in DebugExtractor._extracted_files_to_copy():
+ if os.path.exists(dest):
+ root_logger.debug('Debug symbol %s already exists, not copying from %s.', dest, src)
+ continue
+ shutil.copy(src, dest)
+ root_logger.debug('Copied debug symbol %s.', dest)
+
+ @staticmethod
+ def _extracted_files_to_copy():
+ out = []
+ for ext in ['debug', 'dSYM', 'pdb']:
+ for file in ['mongo', 'mongod', 'mongos']:
+ # need to glob because it untar's to a directory that looks like
+ # mongodb-linux-x86_64-enterprise-rhel62-4.3.0-1823-gb9c13fa-patch-5daa05630ae60652f0890f76
+ haystack = os.path.join('mongodb*', 'bin', '{file}.{ext}'.format(
+ file=file, ext=ext))
+ for needle in glob.glob(haystack):
+ out.append((needle, os.path.join(os.getcwd(), os.path.basename(needle))))
+ return out
+
+
def get_hang_analyzers():
"""Return hang analyzers."""
@@ -609,6 +664,8 @@ def main(): # pylint: disable=too-many-branches,too-many-locals,too-many-statem
except AttributeError:
root_logger.warning("Cannot determine Unix Current Login, not supported on Windows")
+ DebugExtractor.extract_debug_symbols(root_logger)
+
interesting_processes = ["mongo", "mongod", "mongos", "_test", "dbtest", "python", "java"]
go_processes = []
process_ids = []
diff --git a/etc/evergreen.yml b/etc/evergreen.yml
index 2f2c96dca1d..9010fbb2a60 100644
--- a/etc/evergreen.yml
+++ b/etc/evergreen.yml
@@ -48,6 +48,8 @@ variables:
- name: compile
commands:
- func: "do setup"
+ - func: "set task expansion macros"
+ - func: "fetch debugsymbols archive"
- func: "run tests"
vars:
resmoke_args: --help
@@ -815,30 +817,6 @@ functions:
bucket: mciuploads
local_file: src/mongo-debugsymbols.tgz
- "extract debugsymbols": &extract_debugsymbols
- command: shell.exec
- params:
- working_dir: src
- script: |
- set -o errexit
- set -o verbose
- # Debug symbols are not created for every variant
- if [ ! -f mongo-debugsymbols.tgz ]; then
- exit
- fi
- ${decompress} mongo-debugsymbols.tgz
- files="mongo mongod mongos"
- file_exts="debug dSYM pdb"
- for file_ext in $file_exts
- do
- for file in $files
- do
- mv mongodb*/bin/$file.$file_ext . 2>/dev/null || true
- done
- rm -r mongodb*/bin/*.$file_ext 2>/dev/null || true
- done
- rm mongo-debugsymbols.tgz 2>/dev/null || true
-
"fetch and build OpenSSL":
command: shell.exec
params:
@@ -1488,7 +1466,6 @@ functions:
path_value="$path_value:${task_path_suffix}"
fi
-
# The "resmoke_wrapper" expansion is used by the 'burn_in_tests' task to wrap the resmoke.py
# invocation. It doesn't set any environment variables and should therefore come last in
# this list of expansions.
@@ -1657,6 +1634,8 @@ functions:
value: mongodata_aws
- key: aws_secret_remote
value: ${mongodatafiles_aws_secret}
+ - *set_task_expansion_macros
+ - *fetch_debugsymbols_archive
- *set_up_remote_credentials
- *determine_resmoke_jobs
- *update_resmoke_jobs_expansions
@@ -3647,7 +3626,6 @@ post:
# Timeout steps
timeout:
- func: "fetch debugsymbols archive"
- - func: "extract debugsymbols"
- func: "get EC2 address"
- func: "update EC2 address"
- func: "run hang analyzer"