summaryrefslogtreecommitdiff
path: root/src/mongo/db/pipeline/pipeline_d.cpp
diff options
context:
space:
mode:
authorMathias Stearn <mathias@10gen.com>2014-01-30 17:16:36 -0500
committerMathias Stearn <mathias@10gen.com>2014-02-12 11:38:38 -0500
commit20806b5757b5bf4dbf524df0f332170012086af7 (patch)
treec0f71847c38417ae835bd2dff99eef4d59f9d4ce /src/mongo/db/pipeline/pipeline_d.cpp
parent8c99c9ad5cd5ef14f808c1c135f807255330f025 (diff)
downloadmongo-20806b5757b5bf4dbf524df0f332170012086af7.tar.gz
SERVER-12530 clean up agg output cursor creation and locking
Diffstat (limited to 'src/mongo/db/pipeline/pipeline_d.cpp')
-rw-r--r--src/mongo/db/pipeline/pipeline_d.cpp20
1 files changed, 9 insertions, 11 deletions
diff --git a/src/mongo/db/pipeline/pipeline_d.cpp b/src/mongo/db/pipeline/pipeline_d.cpp
index 7bb6f0940d2..e85a5b3d3ee 100644
--- a/src/mongo/db/pipeline/pipeline_d.cpp
+++ b/src/mongo/db/pipeline/pipeline_d.cpp
@@ -63,9 +63,12 @@ namespace {
};
}
- void PipelineD::prepareCursorSource(
- const intrusive_ptr<Pipeline> &pPipeline,
- const intrusive_ptr<ExpressionContext> &pExpCtx) {
+ void PipelineD::prepareCursorSource(const intrusive_ptr<Pipeline>& pPipeline,
+ const intrusive_ptr<ExpressionContext>& pExpCtx,
+ Collection* collection) {
+ // get the full "namespace" name
+ const string& fullName = pExpCtx->ns.ns();
+ Lock::assertAtLeastReadLocked(fullName);
// We will be modifying the source vector as we go
Pipeline::SourceContainer& sources = pPipeline->sources;
@@ -125,9 +128,6 @@ namespace {
}
}
- // get the full "namespace" name
- const string& fullName = pExpCtx->ns.ns();
-
// for debugging purposes, show what the query and sort are
DEV {
(log() << "\n---- query BSON\n" <<
@@ -138,11 +138,9 @@ namespace {
fullName << "\n----\n");
}
- // Create the necessary context to use a Runner, including taking a namespace read lock.
- // Note: this may throw if the sharding version for this connection is out of date.
- Client::ReadContext context(fullName);
- Collection* collection = context.ctx().db()->getCollection(fullName);
- if ( !collection ) {
+ if (!collection) {
+ // Collection doesn't exist. Create a source that will return no results to simulate an
+ // empty collection.
intrusive_ptr<DocumentSource> source(DocumentSourceBsonArray::create(BSONObj(),
pExpCtx));
while (!sources.empty() && source->coalesce(sources.front())) {