summaryrefslogtreecommitdiff
path: root/src/mongo/db/index
diff options
context:
space:
mode:
authorLucas de Castro Borges <lucas@gnuabordo.com.br>2025-02-18 17:02:53 -0300
committerLucas de Castro Borges <lucas@gnuabordo.com.br>2025-02-18 17:02:53 -0300
commit959575a5ca598bf5f37fb5cebe7ed1d80d3d71f7 (patch)
treeacc8d60aedb12b70048e676e8a7349deb0010db8 /src/mongo/db/index
parent76588293975fc059cf076779e4283e6ffaf8afff (diff)
New upstream version 6.0.20upstream
Diffstat (limited to 'src/mongo/db/index')
-rw-r--r--src/mongo/db/index/SConscript2
-rw-r--r--src/mongo/db/index/index_access_method.cpp10
-rw-r--r--src/mongo/db/index/index_descriptor.cpp14
3 files changed, 20 insertions, 6 deletions
diff --git a/src/mongo/db/index/SConscript b/src/mongo/db/index/SConscript
index 7b191838e2f..9207e32aa49 100644
--- a/src/mongo/db/index/SConscript
+++ b/src/mongo/db/index/SConscript
@@ -63,7 +63,6 @@ serveronlyEnv.Library(
'$BUILD_DIR/mongo/db/catalog/index_catalog',
'$BUILD_DIR/mongo/db/catalog/index_catalog_entry',
'$BUILD_DIR/mongo/db/concurrency/exception_util',
- '$BUILD_DIR/mongo/db/curop',
'$BUILD_DIR/mongo/db/exec/projection_executor',
'$BUILD_DIR/mongo/db/exec/working_set',
'$BUILD_DIR/mongo/db/fts/base_fts',
@@ -74,6 +73,7 @@ serveronlyEnv.Library(
'$BUILD_DIR/mongo/db/query/collation/collator_factory_interface',
'$BUILD_DIR/mongo/db/query/collation/collator_interface',
'$BUILD_DIR/mongo/db/query/projection_ast',
+ '$BUILD_DIR/mongo/db/query/query_stats/query_stats',
'$BUILD_DIR/mongo/db/query/sort_pattern',
'$BUILD_DIR/mongo/db/record_id_helpers',
'$BUILD_DIR/mongo/db/repl/repl_coordinator_interface',
diff --git a/src/mongo/db/index/index_access_method.cpp b/src/mongo/db/index/index_access_method.cpp
index 5727bfea1df..4d454f2b5a3 100644
--- a/src/mongo/db/index/index_access_method.cpp
+++ b/src/mongo/db/index/index_access_method.cpp
@@ -412,6 +412,13 @@ void SortedDataIndexAccessMethod::removeOneKey(OperationContext* opCtx,
try {
_newInterface->unindex(opCtx, keyString, dupsAllowed);
} catch (AssertionException& e) {
+ if (e.code() == ErrorCodes::DataCorruptionDetected) {
+ // DataCorruptionDetected errors are expected to have logged an error and added an entry
+ // to the health log with the stack trace at the location where the error was initially
+ // thrown. No need to do so again.
+ throw;
+ }
+
NamespaceString ns = _indexCatalogEntry->getNSSFromCatalog(opCtx);
LOGV2(20683,
"Assertion failure: _unindex failed on: {namespace} for index: {indexName}. "
@@ -631,7 +638,8 @@ Status SortedDataIndexAccessMethod::doUpdate(OperationContext* opCtx,
// Add all new data keys into the index.
for (const auto& keyString : ticket.added) {
- bool dupsAllowed = !_descriptor->prepareUnique() && ticket.dupsAllowed;
+ bool dupsAllowed = (!_descriptor->prepareUnique() || !opCtx->isEnforcingConstraints()) &&
+ ticket.dupsAllowed;
auto status = _newInterface->insert(opCtx, keyString, dupsAllowed);
if (!status.isOK())
return status;
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();
}