diff options
author | Anton Korshunov <anton.korshunov@mongodb.com> | 2019-06-26 14:25:06 +0100 |
---|---|---|
committer | Anton Korshunov <anton.korshunov@mongodb.com> | 2019-06-27 10:49:53 +0100 |
commit | 40f401824c4fb8925f063239d7855fe742e33d55 (patch) | |
tree | 67f32071c0988fc808779cfe680d48285be7eee9 /src/mongo/db/commands/run_aggregate.cpp | |
parent | a0b282227f59d51424b94d3bc02667449ba2a56d (diff) | |
download | mongo-40f401824c4fb8925f063239d7855fe742e33d55.tar.gz |
SERVER-41756 source namespace is not reported correctly if $out is used
Diffstat (limited to 'src/mongo/db/commands/run_aggregate.cpp')
-rw-r--r-- | src/mongo/db/commands/run_aggregate.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/mongo/db/commands/run_aggregate.cpp b/src/mongo/db/commands/run_aggregate.cpp index 80b4ffb9444..a47511f2bb1 100644 --- a/src/mongo/db/commands/run_aggregate.cpp +++ b/src/mongo/db/commands/run_aggregate.cpp @@ -784,6 +784,15 @@ Status runAggregate(OperationContext* opCtx, } } + // The aggregation pipeline may change the namespace of the curop and we need to set it back to + // the original namespace to correctly report command stats. One example when the namespace can + // be changed is when the pipeline contains an $out stage, which executes an internal command to + // create a temp collection, changing the curop namespace to the name of this temp collection. + { + stdx::lock_guard<Client> lk(*opCtx->getClient()); + curOp->setNS_inlock(origNss.ns()); + } + // Any code that needs the cursor pinned must be inside the try block, above. return Status::OK(); } |