diff options
author | Xiangyu Yao <xiangyu.yao@mongodb.com> | 2018-08-01 10:25:26 -0400 |
---|---|---|
committer | Xiangyu Yao <xiangyu.yao@mongodb.com> | 2018-08-06 22:31:45 -0400 |
commit | 3f08a905c17b6d68201b5ddbdaf5b62e26c99b30 (patch) | |
tree | 203509acfa1031666c7f23fc871c0c9bee2ee433 /src | |
parent | e444d98f411566bcd983e7ca2eccfda1bc14fe5a (diff) | |
download | mongo-3f08a905c17b6d68201b5ddbdaf5b62e26c99b30.tar.gz |
SERVER-36329 Deprecate failIndexKeyTooLong server parameter
Diffstat (limited to 'src')
-rw-r--r-- | src/mongo/db/catalog/private/record_store_validate_adaptor.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/index/index_access_method.cpp | 14 | ||||
-rw-r--r-- | src/mongo/db/index/index_access_method.h | 4 |
3 files changed, 16 insertions, 4 deletions
diff --git a/src/mongo/db/catalog/private/record_store_validate_adaptor.cpp b/src/mongo/db/catalog/private/record_store_validate_adaptor.cpp index cc52362502a..d4619c81592 100644 --- a/src/mongo/db/catalog/private/record_store_validate_adaptor.cpp +++ b/src/mongo/db/catalog/private/record_store_validate_adaptor.cpp @@ -222,7 +222,7 @@ void RecordStoreValidateAdaptor::validateIndexKeyCount(IndexDescriptor* idx, auto totalKeys = numLongKeys + numIndexedKeys; bool hasTooFewKeys = false; - bool noErrorOnTooFewKeys = !failIndexKeyTooLong.load() && (_level != kValidateFull); + bool noErrorOnTooFewKeys = !failIndexKeyTooLongParam() && (_level != kValidateFull); if (idx->isIdIndex() && totalKeys != numRecs) { hasTooFewKeys = totalKeys < numRecs ? true : hasTooFewKeys; diff --git a/src/mongo/db/index/index_access_method.cpp b/src/mongo/db/index/index_access_method.cpp index 04ebed5b623..4dab655cfb7 100644 --- a/src/mongo/db/index/index_access_method.cpp +++ b/src/mongo/db/index/index_access_method.cpp @@ -78,8 +78,20 @@ bool isMultikeyFromPaths(const MultikeyPaths& multikeyPaths) { } } // namespace + +// TODO SERVER-36386: Remove the server parameter MONGO_EXPORT_SERVER_PARAMETER(failIndexKeyTooLong, bool, true); +// TODO SERVER-36386: Remove the server parameter +bool failIndexKeyTooLongParam() { + // Always return true in FCV 4.2 although FCV 4.2 actually never needs to + // check this value because there shouldn't be any KeyTooLong errors in FCV 4.2. + if (serverGlobalParams.featureCompatibility.getVersion() == + ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo42) + return true; + return failIndexKeyTooLong.load(); +} + class BtreeExternalSortComparison { public: BtreeExternalSortComparison(const BSONObj& ordering, IndexVersion version) @@ -110,7 +122,7 @@ bool IndexAccessMethod::ignoreKeyTooLong(OperationContext* opCtx) { const auto shouldRelaxConstraints = repl::ReplicationCoordinator::get(opCtx)->shouldRelaxIndexConstraints( opCtx, NamespaceString(_btreeState->ns())); - return shouldRelaxConstraints || !failIndexKeyTooLong.load(); + return shouldRelaxConstraints || !failIndexKeyTooLongParam(); } // Find the keys for obj, put them in the tree pointing to loc diff --git a/src/mongo/db/index/index_access_method.h b/src/mongo/db/index/index_access_method.h index feb51712f1a..9e1e3185247 100644 --- a/src/mongo/db/index/index_access_method.h +++ b/src/mongo/db/index/index_access_method.h @@ -42,13 +42,13 @@ namespace mongo { -extern AtomicBool failIndexKeyTooLong; - class BSONObjBuilder; class MatchExpression; class UpdateTicket; struct InsertDeleteOptions; +bool failIndexKeyTooLongParam(); + /** * An IndexAccessMethod is the interface through which all the mutation, lookup, and * traversal of index entries is done. The class is designed so that the underlying index |