diff options
Diffstat (limited to 'src/mongo/db/pipeline/sharded_agg_helpers.cpp')
-rw-r--r-- | src/mongo/db/pipeline/sharded_agg_helpers.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/mongo/db/pipeline/sharded_agg_helpers.cpp b/src/mongo/db/pipeline/sharded_agg_helpers.cpp index 13ddc42253d..c836400728b 100644 --- a/src/mongo/db/pipeline/sharded_agg_helpers.cpp +++ b/src/mongo/db/pipeline/sharded_agg_helpers.cpp @@ -206,14 +206,17 @@ std::vector<RemoteCursor> establishShardCursors(OperationContext* opCtx, // The collection is sharded. Use the routing table to decide which shards to target // based on the query and collation, and build versioned requests for them. for (const auto& shardId : shardIds) { - auto versionedCmdObj = appendShardVersion(cmdObj, cm->getVersion(shardId)); + ChunkVersion placementVersion = cm->getVersion(shardId); + auto versionedCmdObj = appendShardVersion( + cmdObj, + ShardVersion(placementVersion, CollectionIndexes(placementVersion, boost::none))); requests.emplace_back(shardId, std::move(versionedCmdObj)); } } else { // The collection is unsharded. Target only the primary shard for the database. // Don't append shard version info when contacting the config servers. const auto cmdObjWithShardVersion = cm->dbPrimary() != ShardId::kConfigServerId - ? appendShardVersion(cmdObj, ChunkVersion::UNSHARDED()) + ? appendShardVersion(cmdObj, ShardVersion::UNSHARDED()) : cmdObj; requests.emplace_back(cm->dbPrimary(), appendDbVersionIfPresent(cmdObjWithShardVersion, cm->dbVersion())); @@ -809,14 +812,16 @@ std::unique_ptr<Pipeline, PipelineDeleter> runPipelineDirectlyOnSingleShard( auto versionedCmdObj = [&] { if (cm.isSharded()) { - return appendShardVersion(aggregation_request_helper::serializeToCommandObj(request), - cm.getVersion(shardId)); + ChunkVersion placementVersion = cm.getVersion(shardId); + return appendShardVersion( + aggregation_request_helper::serializeToCommandObj(request), + ShardVersion(placementVersion, CollectionIndexes(placementVersion, boost::none))); } else { // The collection is unsharded. Don't append shard version info when contacting the // config servers. const auto cmdObjWithShardVersion = (shardId != ShardId::kConfigServerId) ? appendShardVersion(aggregation_request_helper::serializeToCommandObj(request), - ChunkVersion::UNSHARDED()) + ShardVersion::UNSHARDED()) : aggregation_request_helper::serializeToCommandObj(request); return appendDbVersionIfPresent(std::move(cmdObjWithShardVersion), cm.dbVersion()); } |