diff options
author | Shaileja Jain <shaileja.jain@gmail.com> | 2019-07-29 14:33:31 -0400 |
---|---|---|
committer | Shaileja Jain <shaileja.jain@gmail.com> | 2019-08-05 15:53:20 -0400 |
commit | 41da4f253c73e93df42858db48ed593c5802a2f2 (patch) | |
tree | 088b6e34d253884a594791ddfe6411011a1ebca8 /src/mongo/db/curop.cpp | |
parent | 18bff834e331f8a6a13aeec4c9cf94a9e9239d75 (diff) | |
download | mongo-41da4f253c73e93df42858db48ed593c5802a2f2.tar.gz |
SERVER-42447 Add backtrace field to waitingforLatch
Diffstat (limited to 'src/mongo/db/curop.cpp')
-rw-r--r-- | src/mongo/db/curop.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/mongo/db/curop.cpp b/src/mongo/db/curop.cpp index 51cedc26dab..da117a244b4 100644 --- a/src/mongo/db/curop.cpp +++ b/src/mongo/db/curop.cpp @@ -323,14 +323,19 @@ void CurOp::reportCurrentOpForClient(OperationContext* opCtx, std::shared_ptr<DiagnosticInfo> diagnostic = DiagnosticInfo::Diagnostic::get(client); if (diagnostic && backtraceMode) { - // TODO: SERVER-42447 Add backtrace as bsonobj to waitingForLatch - BSONObjBuilder waitingForLatchBuilder; + BSONObjBuilder waitingForLatchBuilder(infoBuilder->subobjStart("waitingForLatch")); waitingForLatchBuilder.append("timestamp", diagnostic->getTimestamp()); waitingForLatchBuilder.append("captureName", diagnostic->getCaptureName()); - infoBuilder->append("waitingForLatch", waitingForLatchBuilder.obj()); + { + BSONArrayBuilder backtraceBuilder(waitingForLatchBuilder.subarrayStart("backtrace")); + for (const auto& frame : diagnostic->makeStackTrace().frames) { + BSONObjBuilder backtraceObj(backtraceBuilder.subobjStart()); + backtraceObj.append("addr", integerToHex(frame.instructionOffset)); + backtraceObj.append("path", frame.objectPath); + } + } } - if (MONGO_FAIL_POINT(keepDiagnosticCaptureOnFailedLock)) { gHangLock.lock.unlock(); } |