diff options
author | Bernard Gorman <bernard.gorman@gmail.com> | 2020-03-11 18:17:30 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-03-12 18:10:40 +0000 |
commit | 482ec2ed36d6677f54f112a0a046c8b9f3ce9a1b (patch) | |
tree | 001a734c5660fef4ddf57a18b2fdd8a1d6e59f1d /src/mongo/db/pipeline | |
parent | 729b70ce06625ed73b023a6a41a1e4d1a7e58363 (diff) | |
download | mongo-482ec2ed36d6677f54f112a0a046c8b9f3ce9a1b.tar.gz |
SERVER-44884 Remove the 'useNewUpsert' flag after branching for 4.5
Diffstat (limited to 'src/mongo/db/pipeline')
-rw-r--r-- | src/mongo/db/pipeline/aggregation_request.cpp | 16 | ||||
-rw-r--r-- | src/mongo/db/pipeline/aggregation_request.h | 13 | ||||
-rw-r--r-- | src/mongo/db/pipeline/expression_context.cpp | 12 | ||||
-rw-r--r-- | src/mongo/db/pipeline/expression_context.h | 5 | ||||
-rw-r--r-- | src/mongo/db/pipeline/process_interface/common_mongod_process_interface.cpp | 5 | ||||
-rw-r--r-- | src/mongo/db/pipeline/sharded_agg_helpers.cpp | 4 |
6 files changed, 7 insertions, 48 deletions
diff --git a/src/mongo/db/pipeline/aggregation_request.cpp b/src/mongo/db/pipeline/aggregation_request.cpp index f5c417e30e9..34128ff6b0e 100644 --- a/src/mongo/db/pipeline/aggregation_request.cpp +++ b/src/mongo/db/pipeline/aggregation_request.cpp @@ -212,16 +212,11 @@ StatusWith<AggregationRequest> AggregationRequest::parseFromBSON( } request.setUse44SortKeys(elem.boolean()); - } else if (fieldName == kUseNewUpsert) { - // TODO SERVER-44884: After branching for 4.5, we will continue to accept this option - // for upgrade purposes but will ignore it, as any supported version will be capable of - // using the new upsert mechanism. In 4.7 we will completely remove this parameter. - if (elem.type() != BSONType::Bool) { - return {ErrorCodes::TypeMismatch, - str::stream() << kUseNewUpsert << " must be a boolean, not a " - << typeName(elem.type())}; - } - request.setUseNewUpsert(elem.boolean()); + } else if (fieldName == "useNewUpsert"_sd) { + // TODO SERVER-46751: we must retain the ability to ingest the 'useNewUpsert' field for + // 4.6 upgrade purposes, since a 4.4 mongoS will always send {useNewUpsert:true} to the + // shards. We do nothing with it because useNewUpsert will be automatically used in 4.6 + // when appropriate. Remove this final vestige of useNewUpsert during the 4.7 dev cycle. } else if (fieldName == kIsMapReduceCommand) { if (elem.type() != BSONType::Bool) { return {ErrorCodes::TypeMismatch, @@ -328,7 +323,6 @@ Document AggregationRequest::serializeToCommandObj() const { // Only serialize runtime constants if any were specified. {kRuntimeConstants, _runtimeConstants ? Value(_runtimeConstants->toBSON()) : Value()}, {kUse44SortKeys, _use44SortKeys ? Value(true) : Value()}, - {kUseNewUpsert, _useNewUpsert ? Value(true) : Value()}, {kIsMapReduceCommand, _isMapReduceCommand ? Value(true) : Value()}, }; } diff --git a/src/mongo/db/pipeline/aggregation_request.h b/src/mongo/db/pipeline/aggregation_request.h index eb2594e7765..c6f2b2aee40 100644 --- a/src/mongo/db/pipeline/aggregation_request.h +++ b/src/mongo/db/pipeline/aggregation_request.h @@ -64,7 +64,6 @@ public: static constexpr StringData kExchangeName = "exchange"_sd; static constexpr StringData kRuntimeConstants = "runtimeConstants"_sd; static constexpr StringData kUse44SortKeys = "use44SortKeys"_sd; - static constexpr StringData kUseNewUpsert = "useNewUpsert"_sd; static constexpr StringData kIsMapReduceCommand = "isMapReduceCommand"_sd; static constexpr long long kDefaultBatchSize = 101; @@ -223,10 +222,6 @@ public: return _use44SortKeys; } - bool getUseNewUpsert() const { - return _useNewUpsert; - } - bool getIsMapReduceCommand() const { return _isMapReduceCommand; } @@ -299,10 +294,6 @@ public: _use44SortKeys = use44SortKeys; } - void setUseNewUpsert(bool useNewUpsert) { - _useNewUpsert = useNewUpsert; - } - void setIsMapReduceCommand(bool isMapReduce) { _isMapReduceCommand = isMapReduce; } @@ -361,10 +352,6 @@ private: // use the updated sort key format when returning change stream results. bool _use44SortKeys = false; - // Indicates whether the aggregation may use the new 'upsertSupplied' mechanism when running - // $merge stages. All 4.4 mongoS and some versions of 4.2 set this flag. - bool _useNewUpsert = false; - // True when an aggregation was invoked by the MapReduce command. bool _isMapReduceCommand = false; }; diff --git a/src/mongo/db/pipeline/expression_context.cpp b/src/mongo/db/pipeline/expression_context.cpp index 4e203f16d38..0c6f80e8b82 100644 --- a/src/mongo/db/pipeline/expression_context.cpp +++ b/src/mongo/db/pipeline/expression_context.cpp @@ -64,11 +64,6 @@ ExpressionContext::ExpressionContext(OperationContext* opCtx, std::move(processInterface), std::move(resolvedNamespaces), std::move(collUUID)) { - // Any request which did not originate from a mongoS, or which did originate from a mongoS but - // has the 'useNewUpsert' flag set, can use the new upsertSupplied mechanism for $merge. - // TODO SERVER-44884: Remove this flag after we branch for 4.5. - useNewUpsert = request.getUseNewUpsert() || !request.isFromMongos(); - if (request.getIsMapReduceCommand()) { // mapReduce command JavaScript invocation is only subject to the server global // 'jsHeapLimitMB' limit. @@ -117,12 +112,6 @@ ExpressionContext::ExpressionContext( if (!isMapReduce) { jsHeapLimitMB = internalQueryJavaScriptHeapSizeLimitMB.load(); } - - // Any request which did not originate from a mongoS can use the new upsertSupplied mechanism. - // This is used to set 'useNewUpsert' when constructing a MR context on mongoS or mongoD. The MR - // on mongoS will be issued as an aggregation to the shards and will use the other constructor. - // TODO SERVER-44884: Remove this flag after we branch for 4.5. - useNewUpsert = !fromMongos; } ExpressionContext::ExpressionContext(OperationContext* opCtx, @@ -199,7 +188,6 @@ intrusive_ptr<ExpressionContext> ExpressionContext::copyWith( expCtx->maxFeatureCompatibilityVersion = maxFeatureCompatibilityVersion; expCtx->subPipelineDepth = subPipelineDepth; expCtx->tempDir = tempDir; - expCtx->useNewUpsert = useNewUpsert; expCtx->jsHeapLimitMB = jsHeapLimitMB; expCtx->variables = variables; diff --git a/src/mongo/db/pipeline/expression_context.h b/src/mongo/db/pipeline/expression_context.h index 35be79e3b1a..de9442dd6b3 100644 --- a/src/mongo/db/pipeline/expression_context.h +++ b/src/mongo/db/pipeline/expression_context.h @@ -352,11 +352,6 @@ public: // other than the "k44SortKey" format, so this will be removed. SortKeyFormat sortKeyFormat = SortKeyFormat::k44SortKey; - // True if this context is associated with a pipeline which is permitted to use the new - // upsertSupplied mechanism for applicable $merge modes. - // TODO SERVER-44884: remove this when we branch for 4.5. - bool useNewUpsert = false; - // True if this ExpressionContext is used to parse a view definition pipeline. bool isParsingViewDefinition = false; diff --git a/src/mongo/db/pipeline/process_interface/common_mongod_process_interface.cpp b/src/mongo/db/pipeline/process_interface/common_mongod_process_interface.cpp index e8004eede08..197bc5fcfd2 100644 --- a/src/mongo/db/pipeline/process_interface/common_mongod_process_interface.cpp +++ b/src/mongo/db/pipeline/process_interface/common_mongod_process_interface.cpp @@ -598,9 +598,8 @@ Update CommonMongodProcessInterface::buildUpdateOp( entry.setU(std::move(u)); entry.setC(std::move(c)); entry.setUpsert(upsert != UpsertType::kNone); - // TODO SERVER-44884: after branching for 4.5, remove the 'useNewUpsert' flag. - entry.setUpsertSupplied({{entry.getUpsert() && expCtx->useNewUpsert, - upsert == UpsertType::kInsertSuppliedDoc}}); + entry.setUpsertSupplied( + {{entry.getUpsert(), upsert == UpsertType::kInsertSuppliedDoc}}); entry.setMulti(multi); return entry; }()); diff --git a/src/mongo/db/pipeline/sharded_agg_helpers.cpp b/src/mongo/db/pipeline/sharded_agg_helpers.cpp index eeb614813ef..695a94f7409 100644 --- a/src/mongo/db/pipeline/sharded_agg_helpers.cpp +++ b/src/mongo/db/pipeline/sharded_agg_helpers.cpp @@ -157,10 +157,6 @@ BSONObj genericTransformForShards(MutableDocument&& cmdForShards, // there will only be one sort key format for changes streams, so there will be no need to // set this flag anymore. This flag has no effect on pipelines without a change stream. cmdForShards[AggregationRequest::kUse44SortKeys] = Value(true); - // TODO SERVER-44884: We set this flag to indicate that the shards should always use the new - // upsert mechanism when executing relevant $merge modes. After branching for 4.5, supported - // upgrade versions will all use the new mechanism, and we can remove this flag. - cmdForShards[AggregationRequest::kUseNewUpsert] = Value(true); } return cmdForShards.freeze().toBson(); |