From e87edace22b258809b6f209a3cdc6c123149a16b Mon Sep 17 00:00:00 2001 From: Nicholas Zolnierz Date: Thu, 13 Feb 2020 15:09:48 +0000 Subject: SERVER-46087 Propagate allowDiskUse to shards for sharded $unionWith --- src/mongo/db/pipeline/sharded_agg_helpers.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/mongo') diff --git a/src/mongo/db/pipeline/sharded_agg_helpers.cpp b/src/mongo/db/pipeline/sharded_agg_helpers.cpp index fabc49ceb4e..d6d3569e5a8 100644 --- a/src/mongo/db/pipeline/sharded_agg_helpers.cpp +++ b/src/mongo/db/pipeline/sharded_agg_helpers.cpp @@ -128,7 +128,7 @@ BSONObj genericTransformForShards(MutableDocument&& cmdForShards, cmdForShards[AggregationRequest::kRuntimeConstants] = Value(constants.get().toBSON()); } - cmdForShards[AggregationRequest::kFromMongosName] = Value(true); + cmdForShards[AggregationRequest::kFromMongosName] = Value(expCtx->inMongos); // If this is a request for an aggregation explain, then we must wrap the aggregate inside an // explain command. if (explainVerbosity) { @@ -955,6 +955,11 @@ std::unique_ptr targetShardsAndAddMergeCursors( }(); AggregationRequest aggRequest(expCtx->ns, rawStages); + + // The default value for 'allowDiskUse' in the AggregationRequest may not match what was set + // on the originating command, so copy it from the ExpressionContext. + aggRequest.setAllowDiskUse(expCtx->allowDiskUse); + LiteParsedPipeline liteParsedPipeline(aggRequest); auto hasChangeStream = liteParsedPipeline.hasChangeStream(); auto shardDispatchResults = dispatchShardPipeline( -- cgit v1.2.1