diff options
author | Dan Larkin-York <dan.larkin-york@mongodb.com> | 2023-04-07 19:12:12 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2023-04-12 17:54:28 +0000 |
commit | 27e8e3a50200098513fa25e05b6585170d1fa124 (patch) | |
tree | 7f8a14c586fb7cede59d514f816c6b8e7d14c67b | |
parent | 83454815aaa1a986aee7fb3155db9153d88777d3 (diff) | |
download | mongo-27e8e3a50200098513fa25e05b6585170d1fa124.tar.gz |
SERVER-75745 Only log record and index metadata associated with missing or extra index keys
(cherry picked from commit 1c424c1a4d68fe02cb6ac0327bccbace66e05d62)
-rw-r--r-- | src/mongo/db/catalog/collection_validation.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/catalog/index_consistency.cpp | 20 | ||||
-rw-r--r-- | src/mongo/db/catalog/index_consistency.h | 8 |
3 files changed, 22 insertions, 8 deletions
diff --git a/src/mongo/db/catalog/collection_validation.cpp b/src/mongo/db/catalog/collection_validation.cpp index 1bf11131960..235928c5b98 100644 --- a/src/mongo/db/catalog/collection_validation.cpp +++ b/src/mongo/db/catalog/collection_validation.cpp @@ -197,7 +197,7 @@ void _gatherIndexEntryErrors(OperationContext* opCtx, LOGV2_OPTIONS(20301, {LogComponent::kIndex}, "Finished traversing through all the indexes"); - indexConsistency->addIndexEntryErrors(result); + indexConsistency->addIndexEntryErrors(opCtx, result); } void _validateIndexKeyCount(OperationContext* opCtx, diff --git a/src/mongo/db/catalog/index_consistency.cpp b/src/mongo/db/catalog/index_consistency.cpp index e606717a331..568d8ed429e 100644 --- a/src/mongo/db/catalog/index_consistency.cpp +++ b/src/mongo/db/catalog/index_consistency.cpp @@ -227,7 +227,7 @@ void IndexConsistency::repairMissingIndexEntries(OperationContext* opCtx, } } -void IndexConsistency::addIndexEntryErrors(ValidateResults* results) { +void IndexConsistency::addIndexEntryErrors(OperationContext* opCtx, ValidateResults* results) { invariant(!_firstPhase); // We'll report up to 1MB for extra index entry errors and missing index entry errors. @@ -282,6 +282,8 @@ void IndexConsistency::addIndexEntryErrors(ValidateResults* results) { missingIndexEntrySizeLimitWarning = true; } + _printMetadata(opCtx, results, entryInfo); + std::string indexName = entry["indexName"].String(); if (!results->indexResultsMap.at(indexName).valid) { continue; @@ -425,11 +427,6 @@ void IndexConsistency::addDocKey(OperationContext* opCtx, invariant(_missingIndexEntries.count(key) == 0); _missingIndexEntries.insert( std::make_pair(key, IndexEntryInfo(*indexInfo, recordId, idKeyBuilder.obj(), ks))); - - // Prints the collection document's and index entry's metadata. - _validateState->getCollection()->getRecordStore()->printRecordMetadata( - opCtx, recordId, &(results->recordTimestamps)); - indexInfo->accessMethod->getSortedDataInterface()->printIndexEntryMetadata(opCtx, ks); } } @@ -630,4 +627,15 @@ uint32_t IndexConsistency::_hashKeyString(const KeyString::Value& ks, uint32_t indexNameHash) const { return ks.hash(indexNameHash); } + +void IndexConsistency::_printMetadata(OperationContext* opCtx, + ValidateResults* results, + const IndexEntryInfo& entryInfo) { + _validateState->getCollection()->getRecordStore()->printRecordMetadata( + opCtx, entryInfo.recordId, &(results->recordTimestamps)); + getIndexInfo(entryInfo.indexName) + .accessMethod->getSortedDataInterface() + ->printIndexEntryMetadata(opCtx, entryInfo.keyString); +} + } // namespace mongo diff --git a/src/mongo/db/catalog/index_consistency.h b/src/mongo/db/catalog/index_consistency.h index 43268972db7..f4eab27660b 100644 --- a/src/mongo/db/catalog/index_consistency.h +++ b/src/mongo/db/catalog/index_consistency.h @@ -169,7 +169,7 @@ public: * Records the errors gathered from the second phase of index validation into the provided * ValidateResultsMap and ValidateResults. */ - void addIndexEntryErrors(ValidateResults* results); + void addIndexEntryErrors(OperationContext* opCtx, ValidateResults* results); /** * Sets up this IndexConsistency object to limit memory usage in the second phase of index @@ -242,5 +242,11 @@ private: */ uint32_t _hashKeyString(const KeyString::Value& ks, uint32_t indexNameHash) const; + /** + * Prints the collection document's and index entry's metadata. + */ + void _printMetadata(OperationContext* opCtx, + ValidateResults* results, + const IndexEntryInfo& info); }; // IndexConsistency } // namespace mongo |