summaryrefslogtreecommitdiff
path: root/src/mongo/db/catalog/index_consistency.cpp
diff options
context:
space:
mode:
authorGregory Wlodarek <gregory.wlodarek@mongodb.com>2021-02-19 18:16:36 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-02-19 21:11:26 +0000
commita0b2871db72f0da975c61f50f87839d2ebd14c0a (patch)
treeffd45a46d4e31d85892b72516c87be476149f2fd /src/mongo/db/catalog/index_consistency.cpp
parent6d2adad86ca0ba48e5fa33d5ed43c0385a9e44f1 (diff)
downloadmongo-a0b2871db72f0da975c61f50f87839d2ebd14c0a.tar.gz
SERVER-54656 Validation reports missing and extra index entries for clustered collections
Diffstat (limited to 'src/mongo/db/catalog/index_consistency.cpp')
-rw-r--r--src/mongo/db/catalog/index_consistency.cpp19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/mongo/db/catalog/index_consistency.cpp b/src/mongo/db/catalog/index_consistency.cpp
index d388033cdf5..f476157782b 100644
--- a/src/mongo/db/catalog/index_consistency.cpp
+++ b/src/mongo/db/catalog/index_consistency.cpp
@@ -491,14 +491,21 @@ BSONObj IndexConsistency::_generateInfo(const std::string& indexName,
BSONObj rehydratedKey = b.done();
+ BSONObjBuilder infoBuilder;
+ infoBuilder.append("indexName", indexName);
+ infoBuilder.append(
+ "recordId",
+ recordId.withFormat([](RecordId::Null n) { return std::string("null"); },
+ [](int64_t rid) { return std::to_string(rid); },
+ [](const char* str, int size) { return OID::from(str).toString(); }));
+
if (!idKey.isEmpty()) {
- invariant(idKey.nFields() == 1);
- return BSON("indexName" << indexName << "recordId" << recordId.asLong() << "idKey" << idKey
- << "indexKey" << rehydratedKey);
- } else {
- return BSON("indexName" << indexName << "recordId" << recordId.asLong() << "indexKey"
- << rehydratedKey);
+ infoBuilder.append("idKey", idKey);
}
+
+ infoBuilder.append("indexKey", rehydratedKey);
+
+ return infoBuilder.obj();
}
uint32_t IndexConsistency::_hashKeyString(const KeyString::Value& ks,