diff options
author | Yuhong Zhang <yuhong.zhang@mongodb.com> | 2023-03-13 20:32:26 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2023-03-16 21:46:12 +0000 |
commit | 4e4823e6df43a94c516047d0d17931cdf3a28326 (patch) | |
tree | 10e3de8f38eebe936e94cfccd616a2a290ec0da7 | |
parent | 0c6cc277345584054b3b50a507f629ba4b937e9d (diff) | |
download | mongo-4e4823e6df43a94c516047d0d17931cdf3a28326.tar.gz |
SERVER-72542 Avoid redundant index traversal during full validation
(cherry picked from commit 6e1dc6ebbacc2a05b2f1cd22f54bf240ba99ad0b)
5 files changed, 0 insertions, 40 deletions
diff --git a/src/mongo/db/catalog/collection_validation.cpp b/src/mongo/db/catalog/collection_validation.cpp index 673324df4f6..11465c8824c 100644 --- a/src/mongo/db/catalog/collection_validation.cpp +++ b/src/mongo/db/catalog/collection_validation.cpp @@ -133,33 +133,6 @@ void _validateIndexes(OperationContext* opCtx, auto& curIndexResults = (results->indexResultsMap)[descriptor->indexName()]; curIndexResults.keysTraversed = numTraversedKeys; - // If we are performing a full index validation, we have information on the number of index - // keys validated in _validateIndexesInternalStructure (when we validated the internal - // structure of the index). Check if this is consistent with 'numTraversedKeys' from - // traverseIndex above. - if (validateState->isFullIndexValidation()) { - invariant(opCtx->lockState()->isCollectionLockedForMode(validateState->nss(), MODE_X)); - - // The number of keys counted in _validateIndexesInternalStructure, when checking the - // internal structure of the index. - const int64_t numIndexKeys = curIndexResults.keysTraversedFromFullValidate; - - // Check if currIndexResults is valid to ensure that this index is not corrupted or - // comprised (which was set in _validateIndexesInternalStructure). If the index is - // corrupted, there is no use in checking if the traversal yielded the same key count. - if (curIndexResults.valid) { - if (numIndexKeys != numTraversedKeys) { - curIndexResults.valid = false; - string msg = str::stream() - << "number of traversed index entries (" << numTraversedKeys - << ") does not match the number of expected index entries (" << numIndexKeys - << ")"; - results->errors.push_back(msg); - results->valid = false; - } - } - } - if (!curIndexResults.valid) { results->valid = false; } diff --git a/src/mongo/db/catalog/validate_results.h b/src/mongo/db/catalog/validate_results.h index 1c3e274d6cc..c02235a68bc 100644 --- a/src/mongo/db/catalog/validate_results.h +++ b/src/mongo/db/catalog/validate_results.h @@ -45,7 +45,6 @@ struct IndexValidateResults { std::vector<std::string> errors; std::vector<std::string> warnings; int64_t keysTraversed = 0; - int64_t keysTraversedFromFullValidate = 0; int64_t keysRemovedFromRecordStore = 0; }; diff --git a/src/mongo/db/storage/sorted_data_interface_test_fullvalidate.cpp b/src/mongo/db/storage/sorted_data_interface_test_fullvalidate.cpp index 9b75ae21ba8..79b97a96add 100644 --- a/src/mongo/db/storage/sorted_data_interface_test_fullvalidate.cpp +++ b/src/mongo/db/storage/sorted_data_interface_test_fullvalidate.cpp @@ -66,12 +66,6 @@ TEST(SortedDataInterface, FullValidate) { const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); ASSERT_EQUALS(nToInsert, sorted->numEntries(opCtx.get())); } - - { - const ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext()); - // Full validate will set keysTraversedFromFullValidate to the number of keys. - ASSERT(sorted->validate(opCtx.get(), true).keysTraversedFromFullValidate == nToInsert); - } } } // namespace diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_column_store.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_column_store.cpp index 4c6eb90edc2..bb3f9452ab7 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_column_store.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_column_store.cpp @@ -232,9 +232,6 @@ IndexValidateResults WiredTigerColumnStore::validate(OperationContext* opCtx, bo } WiredTigerIndexUtil::validateStructure(opCtx, _uri, results); - if (results.valid) { - results.keysTraversedFromFullValidate = numEntries(opCtx); - } return results; } diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_index.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_index.cpp index 92fe361801b..974fccf3de9 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_index.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_index.cpp @@ -323,9 +323,6 @@ IndexValidateResults WiredTigerIndex::validate(OperationContext* opCtx, bool ful } WiredTigerIndexUtil::validateStructure(opCtx, _uri, results); - if (results.valid) { - results.keysTraversedFromFullValidate = numEntries(opCtx); - } return results; } |