summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2021-11-03 12:26:18 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-11-03 17:16:11 +0000
commit9cdf162eaf214810eaa7bcd65d60c61401d368e5 (patch)
tree3e8e20f35dbbe151b407d72f2e04363b9f06a747
parenteca169a0b7009a783b0271f81677aadcdfd1a78b (diff)
downloadmongo-9cdf162eaf214810eaa7bcd65d60c61401d368e5.tar.gz
SERVER-61177 Create GDB command to dump storage engine info
This also adds the new command to the hang analyzer script.
-rw-r--r--buildscripts/gdb/mongo.py35
-rw-r--r--buildscripts/resmokelib/hang_analyzer/dumper.py2
2 files changed, 37 insertions, 0 deletions
diff --git a/buildscripts/gdb/mongo.py b/buildscripts/gdb/mongo.py
index fb55ce8ee14..b39d08a77c1 100644
--- a/buildscripts/gdb/mongo.py
+++ b/buildscripts/gdb/mongo.py
@@ -574,6 +574,41 @@ class MongoDBDumpRecoveryUnits(gdb.Command):
MongoDBDumpRecoveryUnits()
+class MongoDBDumpStorageEngineInfo(gdb.Command):
+ """Dump storage engine info in mongod process."""
+
+ def __init__(self):
+ """Initialize MongoDBDumpStorageEngineInfo."""
+ RegisterMongoCommand.register(self, "mongodb-dump-storage-engine-info", gdb.COMMAND_DATA)
+
+ def invoke(self, arg, _from_tty): # pylint: disable=unused-argument
+ """Invoke MongoDBDumpStorageEngineInfo."""
+ print("Running Hang Analyzer Supplement - MongoDBDumpStorageEngineInfo")
+
+ main_binary_name = get_process_name()
+ if main_binary_name == 'mongod':
+ self.dump_mongod_storage_engine_info()
+ else:
+ print("Not invoking mongod storage engine info dump for: %s" % (main_binary_name))
+
+ @staticmethod
+ def dump_mongod_storage_engine_info():
+ """GDB in-process python supplement."""
+
+ try:
+ # Call into mongod, and dump the state of storage engine
+ # Note that output will go to mongod's standard output, not the debugger output window
+ gdb.execute(
+ "call mongo::getGlobalServiceContext()->_storageEngine._ptr._value._M_b._M_p->dump()",
+ from_tty=False, to_string=False)
+ except gdb.error as gdberr:
+ print("Ignoring error '%s' in dump_mongod_storage_engine_info" % str(gdberr))
+
+
+# Register command
+MongoDBDumpStorageEngineInfo()
+
+
class BtIfActive(gdb.Command):
"""Print stack trace or a short message if the current thread is idle."""
diff --git a/buildscripts/resmokelib/hang_analyzer/dumper.py b/buildscripts/resmokelib/hang_analyzer/dumper.py
index 0c07fab0ff3..95a32c148f2 100644
--- a/buildscripts/resmokelib/hang_analyzer/dumper.py
+++ b/buildscripts/resmokelib/hang_analyzer/dumper.py
@@ -384,6 +384,7 @@ class GDBDumper(Dumper):
mongod_dump_sessions = "mongod-dump-sessions"
mongodb_dump_mutexes = "mongodb-dump-mutexes"
mongodb_dump_recovery_units = "mongodb-dump-recovery-units"
+ mongodb_dump_storage_engine_info = "mongodb-dump-storage-engine-info"
for pid in pinfo.pidv:
if not logger.mongo_process_filename:
@@ -427,6 +428,7 @@ class GDBDumper(Dumper):
mongod_dump_sessions,
mongodb_dump_mutexes,
mongodb_dump_recovery_units,
+ mongodb_dump_storage_engine_info,
"detach",
] + set_logging_off_commands