diff --git a/src/mongo/db/curop.cpp b/src/mongo/db/curop.cpp index aef663364b..47c239942b 100644 --- a/src/mongo/db/curop.cpp +++ b/src/mongo/db/curop.cpp @@ -158,6 +158,13 @@ public: return _top; } + /** + * Returns the bottom of the CurOp stack. + */ + CurOp* base() { + return &_base; + } + /** * Adds "curOp" to the top of the CurOp stack for a client. Called by CurOp's constructor. */ @@ -211,7 +218,7 @@ private: CurOp* _top = nullptr; // The bottom-most CurOp for a client. - const CurOp _base; + CurOp _base; }; const OperationContext::Decoration CurOp::_curopStack = @@ -468,7 +475,9 @@ void appendAsObjOrString(StringData name, const BSONObj& obj, const boost::optional maxSize, BSONObjBuilder* builder) { - if (!maxSize || static_cast(obj.objsize()) <= *maxSize) { + if (obj.isEmpty()) { + return; + } else if (!maxSize || static_cast(obj.objsize()) <= *maxSize) { builder->append(name, obj); } else { // Generate an abbreviated serialization for the object, by passing false as the @@ -533,6 +542,12 @@ BSONObj CurOp::truncateAndSerializeGenericCursor(GenericCursor* cursor, } void CurOp::reportState(BSONObjBuilder* builder, bool truncateOps) { + boost::optional childBuilder; + if (_parent) { + _stack->base()->reportState(builder, truncateOps); + childBuilder.emplace(builder->subobjStart("childOp"_sd)); + builder = childBuilder.get_ptr(); + } if (_start) { builder->append("secs_running", durationCount(elapsedTimeTotal())); builder->append("microsecs_running", durationCount(elapsedTimeTotal())); diff --git a/src/mongo/db/pipeline/process_interface_standalone.cpp b/src/mongo/db/pipeline/process_interface_standalone.cpp index d7a5102850..136c603e3a 100644 --- a/src/mongo/db/pipeline/process_interface_standalone.cpp +++ b/src/mongo/db/pipeline/process_interface_standalone.cpp @@ -213,6 +213,7 @@ Status MongoInterfaceStandalone::insert(const boost::intrusive_ptr&& objs, const WriteConcernOptions& wc, boost::optional targetEpoch) { + CurOp curOp(expCtx->opCtx); auto writeResults = performInserts( expCtx->opCtx, buildInsertOp(ns, std::move(objs), expCtx->bypassDocumentValidation));