From ed601dd01169b8c1fad9fb8d388da0523a1b48f5 Mon Sep 17 00:00:00 2001 From: Tess Avitabile Date: Fri, 1 Sep 2017 14:06:58 -0400 Subject: SERVER-30899 Aggregations sent from a 3.4 mongos should serialize 3.4 metadata --- src/mongo/db/pipeline/aggregation_request.h | 30 +++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) (limited to 'src/mongo/db/pipeline/aggregation_request.h') diff --git a/src/mongo/db/pipeline/aggregation_request.h b/src/mongo/db/pipeline/aggregation_request.h index d8672b986d7..b34fc383d20 100644 --- a/src/mongo/db/pipeline/aggregation_request.h +++ b/src/mongo/db/pipeline/aggregation_request.h @@ -50,8 +50,9 @@ public: static constexpr StringData kCommandName = "aggregate"_sd; static constexpr StringData kCursorName = "cursor"_sd; static constexpr StringData kBatchSizeName = "batchSize"_sd; - static constexpr StringData kFromRouterName = "fromRouter"_sd; + static constexpr StringData kFromMongosName = "fromMongos"_sd; static constexpr StringData kNeedsMergeName = "needsMerge"_sd; + static constexpr StringData kNeedsMerge34Name = "fromRouter"_sd; static constexpr StringData kPipelineName = "pipeline"_sd; static constexpr StringData kCollationName = "collation"_sd; static constexpr StringData kExplainName = "explain"_sd; @@ -135,8 +136,15 @@ public: /** * Returns true if this request originated from a mongoS. */ - bool isFromRouter() const { - return _fromRouter; + bool isFromMongos() const { + return _fromMongos; + } + + /** + * Returns true if this request originated from a 3.4 mongos. + */ + bool isFrom34Mongos() const { + return _from34Mongos; } /** @@ -218,8 +226,12 @@ public: _allowDiskUse = allowDiskUse; } - void setFromRouter(bool isFromRouter) { - _fromRouter = isFromRouter; + void setFromMongos(bool isFromMongos) { + _fromMongos = isFromMongos; + } + + void setFrom34Mongos(bool isFrom34Mongos) { + _from34Mongos = isFrom34Mongos; } void setNeedsMerge(bool needsMerge) { @@ -276,10 +288,16 @@ private: boost::optional _explainMode; bool _allowDiskUse = false; - bool _fromRouter = false; + bool _fromMongos = false; bool _needsMerge = false; bool _bypassDocumentValidation = false; + // We track whether the aggregation request came from a 3.4 mongos. If so, the merge may occur + // on a 3.4 shard (which does not understand sort key metadata), and we should not serialize the + // sort key. + // TODO SERVER-30924: remove this. + bool _from34Mongos = false; + // A user-specified maxTimeMS limit, or a value of '0' if not specified. unsigned int _maxTimeMS = 0; }; -- cgit v1.2.1