summaryrefslogtreecommitdiff
path: root/src/mongo/db/catalog/index_consistency.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/catalog/index_consistency.cpp')
-rw-r--r--src/mongo/db/catalog/index_consistency.cpp31
1 files changed, 24 insertions, 7 deletions
diff --git a/src/mongo/db/catalog/index_consistency.cpp b/src/mongo/db/catalog/index_consistency.cpp
index 19258cbe3f2..c031905c1b0 100644
--- a/src/mongo/db/catalog/index_consistency.cpp
+++ b/src/mongo/db/catalog/index_consistency.cpp
@@ -127,7 +127,7 @@ KeyStringIndexConsistency::KeyStringIndexConsistency(
void KeyStringIndexConsistency::addMultikeyMetadataPath(const KeyString::Value& ks,
IndexInfo* indexInfo) {
auto hash = _hashKeyString(ks, indexInfo->indexNameHash);
- if (MONGO_unlikely(_validateState->extraLoggingForTest())) {
+ if (MONGO_unlikely(_validateState->logDiagnostics())) {
LOGV2(6208500,
"[validate](multikeyMetadataPath) Adding with the hash",
"hash"_attr = hash,
@@ -139,7 +139,7 @@ void KeyStringIndexConsistency::addMultikeyMetadataPath(const KeyString::Value&
void KeyStringIndexConsistency::removeMultikeyMetadataPath(const KeyString::Value& ks,
IndexInfo* indexInfo) {
auto hash = _hashKeyString(ks, indexInfo->indexNameHash);
- if (MONGO_unlikely(_validateState->extraLoggingForTest())) {
+ if (MONGO_unlikely(_validateState->logDiagnostics())) {
LOGV2(6208501,
"[validate](multikeyMetadataPath) Removing with the hash",
"hash"_attr = hash,
@@ -153,9 +153,26 @@ size_t KeyStringIndexConsistency::getMultikeyMetadataPathCount(IndexInfo* indexI
}
bool KeyStringIndexConsistency::haveEntryMismatch() const {
- return std::any_of(_indexKeyBuckets.begin(),
- _indexKeyBuckets.end(),
- [](const IndexKeyBucket& bucket) -> bool { return bucket.indexKeyCount; });
+ bool haveMismatch =
+ std::any_of(_indexKeyBuckets.begin(),
+ _indexKeyBuckets.end(),
+ [](const IndexKeyBucket& bucket) -> bool { return bucket.indexKeyCount; });
+
+ if (haveMismatch && _validateState->logDiagnostics()) {
+ for (size_t i = 0; i < _indexKeyBuckets.size(); i++) {
+ if (_indexKeyBuckets[i].indexKeyCount == 0) {
+ continue;
+ }
+
+ LOGV2(7404500,
+ "[validate](bucket entry mismatch)",
+ "hash"_attr = i,
+ "indexKeyCount"_attr = _indexKeyBuckets[i].indexKeyCount,
+ "bucketBytesSize"_attr = _indexKeyBuckets[i].bucketSizeBytes);
+ }
+ }
+
+ return haveMismatch;
}
void KeyStringIndexConsistency::repairIndexEntries(OperationContext* opCtx,
@@ -376,7 +393,7 @@ void KeyStringIndexConsistency::addDocKey(OperationContext* opCtx,
upper.bucketSizeBytes += ks.getSize();
indexInfo->numRecords++;
- if (MONGO_unlikely(_validateState->extraLoggingForTest())) {
+ if (MONGO_unlikely(_validateState->logDiagnostics())) {
LOGV2(4666602,
"[validate](record) Adding with hashes",
"hashUpper"_attr = hashUpper,
@@ -434,7 +451,7 @@ void KeyStringIndexConsistency::addIndexKey(OperationContext* opCtx,
upper.bucketSizeBytes += ks.getSize();
indexInfo->numKeys++;
- if (MONGO_unlikely(_validateState->extraLoggingForTest())) {
+ if (MONGO_unlikely(_validateState->logDiagnostics())) {
LOGV2(4666603,
"[validate](index) Adding with hashes",
"hashUpper"_attr = hashUpper,