diff options
author | Luxi Liu <luxi.liu@mongodb.com> | 2022-06-30 15:00:38 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-06-30 16:00:04 +0000 |
commit | 55ac53e928a22867e8ad1b544765695c4c6bcf9d (patch) | |
tree | dc5df2ff5e355d8712b26391939a79dd9b933c6e /src/mongo/db | |
parent | 94c23b6b7974dc9bb6515cb1c279c42b7f055da3 (diff) | |
download | mongo-55ac53e928a22867e8ad1b544765695c4c6bcf9d.tar.gz |
SERVER-66923 Removed kFullyDowngradedTo_5_0 constants in the codebase
Diffstat (limited to 'src/mongo/db')
-rw-r--r-- | src/mongo/db/commands/find_and_modify.cpp | 5 | ||||
-rw-r--r-- | src/mongo/db/exec/upsert_stage.cpp | 7 | ||||
-rw-r--r-- | src/mongo/db/matcher/expression_parser.cpp | 4 | ||||
-rw-r--r-- | src/mongo/db/ops/insert.cpp | 20 | ||||
-rw-r--r-- | src/mongo/db/pipeline/document_source_set_window_fields.cpp | 22 | ||||
-rw-r--r-- | src/mongo/db/pipeline/expression.cpp | 37 | ||||
-rw-r--r-- | src/mongo/db/pipeline/field_path.cpp | 7 | ||||
-rw-r--r-- | src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp | 18 | ||||
-rw-r--r-- | src/mongo/db/update/pipeline_executor.cpp | 11 | ||||
-rw-r--r-- | src/mongo/db/update/storage_validation.cpp | 27 |
10 files changed, 50 insertions, 108 deletions
diff --git a/src/mongo/db/commands/find_and_modify.cpp b/src/mongo/db/commands/find_and_modify.cpp index 2751fa9b8dd..0c4001fafe7 100644 --- a/src/mongo/db/commands/find_and_modify.cpp +++ b/src/mongo/db/commands/find_and_modify.cpp @@ -495,10 +495,7 @@ write_ops::FindAndModifyCommandReply CmdFindAndModify::Invocation::writeConflict write_ops_exec::recordUpdateResultInOpDebug(updateResult, opDebug); opDebug->setPlanSummaryMetrics(summaryStats); - if (updateResult.containsDotsAndDollarsField && - serverGlobalParams.featureCompatibility.isVersionInitialized() && - serverGlobalParams.featureCompatibility.isGreaterThanOrEqualTo( - multiversion::FeatureCompatibilityVersion::kFullyDowngradedTo_5_0)) { + if (updateResult.containsDotsAndDollarsField) { // If it's an upsert, increment 'inserts' metric, otherwise increment 'updates'. dotsAndDollarsFieldsCounters.incrementForUpsert(!updateResult.upsertedId.isEmpty()); } diff --git a/src/mongo/db/exec/upsert_stage.cpp b/src/mongo/db/exec/upsert_stage.cpp index 9d60495646c..06235a9ac52 100644 --- a/src/mongo/db/exec/upsert_stage.cpp +++ b/src/mongo/db/exec/upsert_stage.cpp @@ -294,12 +294,9 @@ void UpsertStage::_assertDocumentToBeInsertedIsValid(const mb::Document& documen // should always have an _id here, since we generated one earlier if not already present. invariant(document.root().ok() && document.root()[idFieldName].ok()); bool containsDotsAndDollarsField = false; - bool allowTopLevelDollarPrefixes = - serverGlobalParams.featureCompatibility.isVersionInitialized() && - serverGlobalParams.featureCompatibility.isGreaterThanOrEqualTo( - multiversion::FeatureCompatibilityVersion::kFullyDowngradedTo_5_0); + storage_validation::scanDocument(document, - allowTopLevelDollarPrefixes, + true, /* allowTopLevelDollarPrefixes */ true, /* Should validate for storage */ &containsDotsAndDollarsField); if (containsDotsAndDollarsField) diff --git a/src/mongo/db/matcher/expression_parser.cpp b/src/mongo/db/matcher/expression_parser.cpp index caef2981ef1..f3faa022c89 100644 --- a/src/mongo/db/matcher/expression_parser.cpp +++ b/src/mongo/db/matcher/expression_parser.cpp @@ -299,9 +299,7 @@ StatusWithMatchExpression parse(const BSONObj& obj, std::string hint = ""; if (name == "not") { hint = ". If you are trying to negate an entire expression, use $nor."; - } else if (serverGlobalParams.featureCompatibility.isVersionInitialized() && - serverGlobalParams.featureCompatibility.isGreaterThanOrEqualTo( - multiversion::FeatureCompatibilityVersion::kFullyDowngradedTo_5_0)) { + } else { hint = ". If you have a field name that starts with a '$' symbol, consider using " "$getField or $setField."; diff --git a/src/mongo/db/ops/insert.cpp b/src/mongo/db/ops/insert.cpp index 8db1935b4b8..b1c3626af3e 100644 --- a/src/mongo/db/ops/insert.cpp +++ b/src/mongo/db/ops/insert.cpp @@ -112,20 +112,12 @@ StatusWith<BSONObj> fixDocumentForInsert(OperationContext* opCtx, auto fieldName = e.fieldNameStringData(); - if (fieldName[0] == '$') { - if (!serverGlobalParams.featureCompatibility.isVersionInitialized() || - !serverGlobalParams.featureCompatibility.isGreaterThanOrEqualTo( - multiversion::FeatureCompatibilityVersion::kFullyDowngradedTo_5_0)) { - return StatusWith<BSONObj>(ErrorCodes::BadValue, - str::stream() - << "Document can't have $ prefixed field names: " - << fieldName); - } else if (containsDotsAndDollarsField) { - *containsDotsAndDollarsField = true; - // If the internal validation is disabled and we confirm this doc contains - // dots/dollars field name, we can skip other validations below. - if (validationDisabled) - return StatusWith<BSONObj>(BSONObj()); + if (fieldName[0] == '$' && containsDotsAndDollarsField) { + *containsDotsAndDollarsField = true; + // If the internal validation is disabled and we confirm this doc contains + // dots/dollars field name, we can skip other validations below. + if (validationDisabled) { + return StatusWith<BSONObj>(BSONObj()); } } diff --git a/src/mongo/db/pipeline/document_source_set_window_fields.cpp b/src/mongo/db/pipeline/document_source_set_window_fields.cpp index 45223bb1cf4..0920fdda988 100644 --- a/src/mongo/db/pipeline/document_source_set_window_fields.cpp +++ b/src/mongo/db/pipeline/document_source_set_window_fields.cpp @@ -75,19 +75,15 @@ bool modifiedSortPaths(const SortPattern& pat, const DocumentSource::GetModPaths } } // namespace -REGISTER_DOCUMENT_SOURCE_WITH_MIN_VERSION( - setWindowFields, - LiteParsedDocumentSourceDefault::parse, - document_source_set_window_fields::createFromBson, - AllowedWithApiStrict::kAlways, - multiversion::FeatureCompatibilityVersion::kFullyDowngradedTo_5_0); - -REGISTER_DOCUMENT_SOURCE_WITH_MIN_VERSION( - _internalSetWindowFields, - LiteParsedDocumentSourceDefault::parse, - DocumentSourceInternalSetWindowFields::createFromBson, - AllowedWithApiStrict::kAlways, - multiversion::FeatureCompatibilityVersion::kFullyDowngradedTo_5_0); +REGISTER_DOCUMENT_SOURCE(setWindowFields, + LiteParsedDocumentSourceDefault::parse, + document_source_set_window_fields::createFromBson, + AllowedWithApiStrict::kAlways); + +REGISTER_DOCUMENT_SOURCE(_internalSetWindowFields, + LiteParsedDocumentSourceDefault::parse, + DocumentSourceInternalSetWindowFields::createFromBson, + AllowedWithApiStrict::kAlways); list<intrusive_ptr<DocumentSource>> document_source_set_window_fields::createFromBson( BSONElement elem, const intrusive_ptr<ExpressionContext>& expCtx) { diff --git a/src/mongo/db/pipeline/expression.cpp b/src/mongo/db/pipeline/expression.cpp index 774a337f740..1524e7d0ee7 100644 --- a/src/mongo/db/pipeline/expression.cpp +++ b/src/mongo/db/pipeline/expression.cpp @@ -7759,12 +7759,8 @@ void ExpressionDateTrunc::_doAddDependencies(DepsTracker* deps) const { } /* -------------------------- ExpressionGetField ------------------------------ */ -REGISTER_EXPRESSION_WITH_MIN_VERSION( - getField, - ExpressionGetField::parse, - AllowedWithApiStrict::kAlways, - AllowedWithClientType::kAny, - multiversion::FeatureCompatibilityVersion::kFullyDowngradedTo_5_0); + +REGISTER_STABLE_EXPRESSION(getField, ExpressionGetField::parse); intrusive_ptr<Expression> ExpressionGetField::parse(ExpressionContext* const expCtx, BSONElement expr, @@ -7871,20 +7867,11 @@ Value ExpressionGetField::serialize(const bool explain) const { } /* -------------------------- ExpressionSetField ------------------------------ */ -REGISTER_EXPRESSION_WITH_MIN_VERSION( - setField, - ExpressionSetField::parse, - AllowedWithApiStrict::kAlways, - AllowedWithClientType::kAny, - multiversion::FeatureCompatibilityVersion::kFullyDowngradedTo_5_0); + +REGISTER_STABLE_EXPRESSION(setField, ExpressionSetField::parse); // $unsetField is syntactic sugar for $setField where value is set to $$REMOVE. -REGISTER_EXPRESSION_WITH_MIN_VERSION( - unsetField, - ExpressionSetField::parse, - AllowedWithApiStrict::kNeverInVersion1, - AllowedWithClientType::kAny, - multiversion::FeatureCompatibilityVersion::kFullyDowngradedTo_5_0); +REGISTER_STABLE_EXPRESSION(unsetField, ExpressionSetField::parse); intrusive_ptr<Expression> ExpressionSetField::parse(ExpressionContext* const expCtx, BSONElement expr, @@ -8015,12 +8002,7 @@ Value ExpressionTsSecond::evaluate(const Document& root, Variables* variables) c return Value(static_cast<long long>(operand.getTimestamp().getSecs())); } -REGISTER_EXPRESSION_WITH_MIN_VERSION( - tsSecond, - ExpressionTsSecond::parse, - AllowedWithApiStrict::kAlways, - AllowedWithClientType::kAny, - multiversion::FeatureCompatibilityVersion::kFullyDowngradedTo_5_0); +REGISTER_STABLE_EXPRESSION(tsSecond, ExpressionTsSecond::parse); /* ------------------------- ExpressionTsIncrement ----------------------------- */ @@ -8039,12 +8021,7 @@ Value ExpressionTsIncrement::evaluate(const Document& root, Variables* variables return Value(static_cast<long long>(operand.getTimestamp().getInc())); } -REGISTER_EXPRESSION_WITH_MIN_VERSION( - tsIncrement, - ExpressionTsIncrement::parse, - AllowedWithApiStrict::kAlways, - AllowedWithClientType::kAny, - multiversion::FeatureCompatibilityVersion::kFullyDowngradedTo_5_0); +REGISTER_STABLE_EXPRESSION(tsIncrement, ExpressionTsIncrement::parse); MONGO_INITIALIZER_GROUP(BeginExpressionRegistration, ("default"), ("EndExpressionRegistration")) MONGO_INITIALIZER_GROUP(EndExpressionRegistration, ("BeginExpressionRegistration"), ()) diff --git a/src/mongo/db/pipeline/field_path.cpp b/src/mongo/db/pipeline/field_path.cpp index ab00617bbd3..c860e863512 100644 --- a/src/mongo/db/pipeline/field_path.cpp +++ b/src/mongo/db/pipeline/field_path.cpp @@ -100,12 +100,7 @@ FieldPath::FieldPath(std::string inputPath) void FieldPath::uassertValidFieldName(StringData fieldName) { uassert(15998, "FieldPath field names may not be empty strings.", !fieldName.empty()); - const auto dotsAndDollarsHint = - serverGlobalParams.featureCompatibility.isVersionInitialized() && - serverGlobalParams.featureCompatibility.isGreaterThanOrEqualTo( - multiversion::FeatureCompatibilityVersion::kFullyDowngradedTo_5_0) - ? " Consider using $getField or $setField." - : ""; + const auto dotsAndDollarsHint = " Consider using $getField or $setField."; if (fieldName[0] == '$' && !kAllowedDollarPrefixedFields.count(fieldName)) { uasserted(16410, diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp index 7cfbe29f304..b290f2b3a62 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp @@ -207,16 +207,20 @@ std::string WiredTigerFileVersion::getDowngradeString() { // With the introduction of continuous releases, there are two downgrade paths from kLatest. // Either to kLastContinuous or kLastLTS. It's possible for the data format to differ between // kLastContinuous and kLastLTS and we'll need to handle that appropriately here. We only - // consider downgrading when FCV has been fully downgraded. This will have to be updated for new - // releases. + // consider downgrading when FCV has been fully downgraded. const auto currentVersion = serverGlobalParams.featureCompatibility.getVersion(); - if (currentVersion == multiversion::FeatureCompatibilityVersion::kVersion_5_1) { - // If the data format between kLatest (v5.2) and kLastContinuous (v5.1) differs, change the + // (Generic FCV reference): This FCV check should exist across LTS binary versions because the + // logic for keeping the WiredTiger release version compatible with the server FCV version will + // be the same across different LTS binary versions. + if (currentVersion == multiversion::GenericFCV::kLastContinuous) { + // If the data format between kLatest and kLastContinuous differs, change the // 'kLastContinuousWTRelease' version. return kLastContinuousWTRelease; - } else if (currentVersion == - multiversion::FeatureCompatibilityVersion::kFullyDowngradedTo_5_0) { - // If the data format between kLatest (v5.2) and kLastLTS (v5.0) differs, change the + // (Generic FCV reference): This FCV check should exist across LTS binary versions because + // the logic for keeping the WiredTiger release version compatible with the server FCV + // version will be the same across different LTS binary versions. + } else if (currentVersion == multiversion::GenericFCV::kLastLTS) { + // If the data format between kLatest and kLastLTS differs, change the // 'kLastLTSWTRelease' version. return kLastLTSWTRelease; } diff --git a/src/mongo/db/update/pipeline_executor.cpp b/src/mongo/db/update/pipeline_executor.cpp index 710803d6b04..acbe69b133f 100644 --- a/src/mongo/db/update/pipeline_executor.cpp +++ b/src/mongo/db/update/pipeline_executor.cpp @@ -103,12 +103,11 @@ UpdateExecutor::ApplyResult PipelineExecutor::applyUpdate(ApplyParams applyParam // Replace the pre-image document in applyParams with the post image we got from running the // post image. - bool allowTopLevelDollarPrefixedFields = - serverGlobalParams.featureCompatibility.isVersionInitialized() && - serverGlobalParams.featureCompatibility.isGreaterThanOrEqualTo( - multiversion::FeatureCompatibilityVersion::kFullyDowngradedTo_5_0); - auto ret = ObjectReplaceExecutor::applyReplacementUpdate( - applyParams, transformedDoc, transformedDocHasIdField, allowTopLevelDollarPrefixedFields); + auto ret = + ObjectReplaceExecutor::applyReplacementUpdate(applyParams, + transformedDoc, + transformedDocHasIdField, + true /* allowTopLevelDollarPrefixedFields */); // The oplog entry should not have been populated yet. invariant(ret.oplogEntry.isEmpty()); diff --git a/src/mongo/db/update/storage_validation.cpp b/src/mongo/db/update/storage_validation.cpp index d94c645a588..0feb5877ef5 100644 --- a/src/mongo/db/update/storage_validation.cpp +++ b/src/mongo/db/update/storage_validation.cpp @@ -112,17 +112,12 @@ void validateDollarPrefixElement(mutablebson::ConstElement elem) { curr.rightSibling().ok() && curr.rightSibling().getFieldName() == "$id"); } else { // Not an okay, $ prefixed field name. - const auto replaceWithHint = - serverGlobalParams.featureCompatibility.isVersionInitialized() && - serverGlobalParams.featureCompatibility.isGreaterThanOrEqualTo( - multiversion::FeatureCompatibilityVersion::kFullyDowngradedTo_5_0) - ? "' is not allowed in the context of an update's replacement document. Consider using " - "an aggregation pipeline with $replaceWith." - : "' is not valid for storage."; - uasserted(ErrorCodes::DollarPrefixedFieldName, str::stream() << "The dollar ($) prefixed field '" << elem.getFieldName() - << "' in '" << mutablebson::getFullName(elem) << replaceWithHint); + << "' in '" << mutablebson::getFullName(elem) + << "' is not allowed in the context of an update's replacement" + " document. Consider using an aggregation pipeline with" + " $replaceWith."); } } } // namespace @@ -137,10 +132,7 @@ Status storageValidIdField(const mongo::BSONElement& element) { << "The '_id' value cannot be of type " << typeName(element.type())); case BSONType::Object: { auto status = element.Obj().storageValidEmbedded(); - if (!status.isOK() && status.code() == ErrorCodes::DollarPrefixedFieldName && - serverGlobalParams.featureCompatibility.isVersionInitialized() && - serverGlobalParams.featureCompatibility.isGreaterThanOrEqualTo( - multiversion::FeatureCompatibilityVersion::kFullyDowngradedTo_5_0)) { + if (!status.isOK() && status.code() == ErrorCodes::DollarPrefixedFieldName) { return Status(status.code(), str::stream() << "_id fields may not contain '$'-prefixed fields: " << status.reason()); @@ -200,21 +192,16 @@ void scanDocument(mutablebson::ConstElement elem, // Only check top-level fields if 'allowTopLevelDollarPrefixes' is false, and don't validate any // fields for '$'-prefixes if 'allowTopLevelDollarPrefixes' is true. const bool checkTopLevelFields = !allowTopLevelDollarPrefixes && (recursionLevel == 1); - const bool dotsAndDollarsFeatureEnabled = - serverGlobalParams.featureCompatibility.isVersionInitialized() && - serverGlobalParams.featureCompatibility.isGreaterThanOrEqualTo( - multiversion::FeatureCompatibilityVersion::kFullyDowngradedTo_5_0); - const bool checkFields = !dotsAndDollarsFeatureEnabled || checkTopLevelFields; auto fieldName = elem.getFieldName(); if (fieldName[0] == '$') { - if (dotsAndDollarsFeatureEnabled && containsDotsAndDollarsField) { + if (containsDotsAndDollarsField) { *containsDotsAndDollarsField = true; // If we are not validating for storage, return once a $-prefixed field is found. if (!shouldValidate) return; } - if (!childOfArray && checkFields && shouldValidate) { + if (!childOfArray && checkTopLevelFields && shouldValidate) { // Cannot start with "$", unless dbref. validateDollarPrefixElement(elem); } |