diff options
Diffstat (limited to 'src/mongo/db/catalog/collection_validation.cpp')
| -rw-r--r-- | src/mongo/db/catalog/collection_validation.cpp | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/mongo/db/catalog/collection_validation.cpp b/src/mongo/db/catalog/collection_validation.cpp index 015bf7e4b5a..9d0c487b41a 100644 --- a/src/mongo/db/catalog/collection_validation.cpp +++ b/src/mongo/db/catalog/collection_validation.cpp @@ -162,7 +162,8 @@ void _gatherIndexEntryErrors(OperationContext* opCtx, ValidateResults tempValidateResults; BSONObjBuilder tempBuilder; - indexValidator->traverseRecordStore(opCtx, &tempValidateResults, &tempBuilder); + indexValidator->traverseRecordStore( + opCtx, &tempValidateResults, &tempBuilder, validateState->validationVersion()); } LOGV2_OPTIONS( @@ -454,8 +455,7 @@ void _validateCatalogEntry(OperationContext* opCtx, index_key_validate::validateIndexSpec(opCtx, indexEntry->descriptor()->infoObj()) .getStatus(); if (!status.isOK()) { - results->valid = false; - results->errors.push_back( + results->warnings.push_back( fmt::format("The index specification for index '{}' contains invalid fields. {}. " "Run the 'collMod' command on the collection without any arguments " "to fix the invalid index options", @@ -621,6 +621,14 @@ Status validate(OperationContext* opCtx, opCtx->recoveryUnit()->abandonSnapshot(); opCtx->recoveryUnit()->setPrepareConflictBehavior(oldPrepareConflictBehavior); }); + + // Relax corruption detection so that we log and continue scanning instead of failing early. + auto oldDataCorruptionMode = opCtx->recoveryUnit()->getDataCorruptionDetectionMode(); + opCtx->recoveryUnit()->setDataCorruptionDetectionMode( + DataCorruptionDetectionMode::kLogAndContinue); + ON_BLOCK_EXIT( + [&] { opCtx->recoveryUnit()->setDataCorruptionDetectionMode(oldDataCorruptionMode); }); + if (validateState.fixErrors()) { // Note: cannot set PrepareConflictBehavior here, since the validate command with repair // needs kIngnoreConflictsAllowWrites, but validate repair at startup cannot set that here @@ -697,7 +705,8 @@ Status validate(OperationContext* opCtx, // the collection. For clustered collections, the validator also verifies that the // record key (RecordId) matches the cluster key field in the record value (document's // cluster key). - indexValidator.traverseRecordStore(opCtx, results, output); + indexValidator.traverseRecordStore( + opCtx, results, output, additionalOptions.validationVersion); // Pause collection validation while a lock is held and between collection and index data // validation. @@ -771,8 +780,7 @@ Status validate(OperationContext* opCtx, return e.toStatus(); } string err = str::stream() << "exception during collection validation: " << e.toString(); - results->errors.push_back(err); - results->valid = false; + results->warnings.push_back(err); LOGV2_OPTIONS(5160302, {LogComponent::kIndex}, "Validation failed due to exception", |
