summaryrefslogtreecommitdiff
path: root/src/mongo
diff options
context:
space:
mode:
authorBernard Gorman <bernard.gorman@mongodb.com>2019-12-10 15:01:37 +0000
committerevergreen <evergreen@mongodb.com>2019-12-10 15:01:37 +0000
commit6297fc578b17c1782a6ed8e25948d82a98a40fa1 (patch)
tree6eecf9014939c307ca378e32632df3397dfdfea7 /src/mongo
parentb5a58d9c335857ab1d414f4f48574e514f640b59 (diff)
downloadmongo-6297fc578b17c1782a6ed8e25948d82a98a40fa1.tar.gz
SERVER-44977 Allow $changeStream with updateLookup to run directly against a shard mongoD
(cherry picked from commit fa76bfb04a062ce031e4d531b9e50a27e1bc2f76)
Diffstat (limited to 'src/mongo')
-rw-r--r--src/mongo/db/pipeline/process_interface_standalone.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/mongo/db/pipeline/process_interface_standalone.cpp b/src/mongo/db/pipeline/process_interface_standalone.cpp
index 7f2cf3e96f7..e6d0174aadc 100644
--- a/src/mongo/db/pipeline/process_interface_standalone.cpp
+++ b/src/mongo/db/pipeline/process_interface_standalone.cpp
@@ -426,7 +426,13 @@ boost::optional<Document> MongoInterfaceStandalone::lookupSingleDocument(
nss,
collectionUUID,
_getCollectionDefaultCollator(expCtx->opCtx, nss.db(), collectionUUID));
- pipeline = makePipeline({BSON("$match" << documentKey)}, foreignExpCtx);
+ // When looking up on a mongoD, we only ever want to read from the local collection. By
+ // default, makePipeline will attach a cursor source which may read from remote if the
+ // collection is sharded, so we manually attach a local-only cursor source here.
+ MakePipelineOptions opts;
+ opts.attachCursorSource = false;
+ pipeline = makePipeline({BSON("$match" << documentKey)}, foreignExpCtx, opts);
+ pipeline = attachCursorSourceToPipelineForLocalRead(foreignExpCtx, pipeline.release());
} catch (const ExceptionFor<ErrorCodes::NamespaceNotFound>&) {
return boost::none;
}