diff options
Diffstat (limited to 'src/mongo/db/curop.cpp')
-rw-r--r-- | src/mongo/db/curop.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/mongo/db/curop.cpp b/src/mongo/db/curop.cpp index 57e0d04b59f..34df70eccb9 100644 --- a/src/mongo/db/curop.cpp +++ b/src/mongo/db/curop.cpp @@ -487,15 +487,19 @@ void CurOp::reportState(BSONObjBuilder* builder, bool truncateOps) { appendAsObjOrString("command", _opDescription, maxQuerySize, builder); - if (!_originatingCommand.isEmpty()) { - appendAsObjOrString("originatingCommand", _originatingCommand, maxQuerySize, builder); - } - if (!_planSummary.empty()) { builder->append("planSummary", _planSummary); } if (_genericCursor) { + // This creates a new builder to truncate the object that will go into the curOp output. In + // order to make sure the object is not too large but not truncate the comment, we only + // truncate the originatingCommand and not the entire cursor. + BSONObjBuilder tempObj; + appendAsObjOrString( + "truncatedObj", _genericCursor->getOriginatingCommand().get(), maxQuerySize, &tempObj); + auto originatingCommand = tempObj.done().getObjectField("truncatedObj"); + _genericCursor->setOriginatingCommand(originatingCommand.getOwned()); builder->append("cursor", _genericCursor->toBSON()); } |