diff options
author | Louis Williams <louis.williams@mongodb.com> | 2021-01-28 15:36:38 -0500 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-01-29 00:01:41 +0000 |
commit | 0d6199bb52dcae5978551816c6ac4ad98bda165b (patch) | |
tree | 0f1a707ead6ea117e4937414695fe4593d748dc6 /src/mongo/db/catalog/collection_validation.cpp | |
parent | 603f25ced3e7917ce94cf95265e7ffa0893b7fa6 (diff) | |
download | mongo-0d6199bb52dcae5978551816c6ac4ad98bda165b.tar.gz |
SERVER-53675 Allow validate to fix up multikey metadata
This allows foreground validation to fix up the following multikey
metadata inconsistencies:
* An index is multikey but there are no multikey fields
* An index has multikeyPaths covering fields that are not multikey
* An index does not have multikeyPaths but there are multikey documents (for pre-3.4 indexes)
If any changes were made, a warning is included to the validate output
and the 'repaired' flag is set to true.
Diffstat (limited to 'src/mongo/db/catalog/collection_validation.cpp')
-rw-r--r-- | src/mongo/db/catalog/collection_validation.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/mongo/db/catalog/collection_validation.cpp b/src/mongo/db/catalog/collection_validation.cpp index f47813abef7..241f9fe4f05 100644 --- a/src/mongo/db/catalog/collection_validation.cpp +++ b/src/mongo/db/catalog/collection_validation.cpp @@ -220,7 +220,7 @@ void _gatherIndexEntryErrors(OperationContext* opCtx, << " extra index entries."); } - if (validateState->shouldRunRepair()) { + if (validateState->fixErrors()) { indexConsistency->repairMissingIndexEntries(opCtx, result); } @@ -460,15 +460,17 @@ Status validate(OperationContext* opCtx, opCtx->recoveryUnit()->abandonSnapshot(); opCtx->recoveryUnit()->setPrepareConflictBehavior(oldPrepareConflictBehavior); }); - if (validateState.shouldRunRepair()) { + 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 // due to an already active WriteUnitOfWork. The prepare conflict behavior for validate // command with repair is set in the command code prior to this point. invariant(!validateState.isBackground()); } else if (!validateState.isBackground()) { + // Foreground validation may perform writes to fix up inconsistencies that are not + // correctness errors. opCtx->recoveryUnit()->setPrepareConflictBehavior( - PrepareConflictBehavior::kIgnoreConflicts); + PrepareConflictBehavior::kIgnoreConflictsAllowWrites); } else { // isBackground(). invariant(oldPrepareConflictBehavior == PrepareConflictBehavior::kEnforce); |