summaryrefslogtreecommitdiff
path: root/src/mongo/db/index/index_descriptor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/index/index_descriptor.cpp')
-rw-r--r--src/mongo/db/index/index_descriptor.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/mongo/db/index/index_descriptor.cpp b/src/mongo/db/index/index_descriptor.cpp
index 0fd676a8353..9c3c8a91c67 100644
--- a/src/mongo/db/index/index_descriptor.cpp
+++ b/src/mongo/db/index/index_descriptor.cpp
@@ -144,10 +144,16 @@ IndexDescriptor::IndexDescriptor(const std::string& accessMethodName, BSONObj in
}
if (BSONElement prepareUniqueElement = _infoObj[kPrepareUniqueFieldName]) {
- uassert(
- ErrorCodes::InvalidOptions,
- "Index does not support the 'prepareUnique' field",
- feature_flags::gCollModIndexUnique.isEnabled(serverGlobalParams.featureCompatibility));
+ // If FCV is initialized, check if prepareUnique is supported.
+ // Otherwise, we are in startup recovery and reading the option from disk, and can skip
+ // the check because this option could only be gnerated by 6.0+, and we already prevent
+ // FCV downgrades from 6.0 if any indexes contain prepareUnique.
+ if (serverGlobalParams.featureCompatibility.isVersionInitialized()) {
+ uassert(ErrorCodes::InvalidOptions,
+ "Index does not support the 'prepareUnique' field",
+ feature_flags::gCollModIndexUnique.isEnabled(
+ serverGlobalParams.featureCompatibility));
+ }
_prepareUnique = prepareUniqueElement.trueValue();
}