summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Wlodarek <gregory.wlodarek@mongodb.com>2023-02-06 22:51:09 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2023-02-06 23:43:55 +0000
commit1b475ef190b29cb62d9a205a05bde1d2ddb6332b (patch)
tree059f12e22f51219e879e660e19890d775b4f3108
parent63c63511ab29416dc3658d6416ba35c7faf4a236 (diff)
downloadmongo-1b475ef190b29cb62d9a205a05bde1d2ddb6332b.tar.gz
SERVER-71353 Add diagnostics for when the durable catalog is scanned due to missing catalogId mapping
-rw-r--r--src/mongo/db/catalog/collection_catalog.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/mongo/db/catalog/collection_catalog.cpp b/src/mongo/db/catalog/collection_catalog.cpp
index 40b45b404d8..ed75b200986 100644
--- a/src/mongo/db/catalog/collection_catalog.cpp
+++ b/src/mongo/db/catalog/collection_catalog.cpp
@@ -33,6 +33,7 @@
#include "mongo/db/catalog/database.h"
#include "mongo/db/catalog/uncommitted_catalog_updates.h"
+#include "mongo/db/commands/server_status.h"
#include "mongo/db/concurrency/exception_util.h"
#include "mongo/db/concurrency/lock_manager_defs.h"
#include "mongo/db/concurrency/resource_catalog.h"
@@ -60,6 +61,8 @@ static RecordId kUnknownRangeMarkerId = RecordId::minLong();
// reached we will fall back to more durable catalog scans.
static constexpr int kMaxCatalogIdMappingLengthForMissingInsert = 1000;
+constexpr auto kNumDurableCatalogScansDueToMissingMapping = "numScansDueToMissingMapping"_sd;
+
struct LatestCollectionCatalog {
std::shared_ptr<CollectionCatalog> catalog = std::make_shared<CollectionCatalog>();
};
@@ -100,6 +103,27 @@ const auto minUuid = UUID::parse("00000000-0000-0000-0000-000000000000").getValu
} // namespace
+/**
+ * Defines a new serverStatus section "collectionCatalog".
+ */
+class CollectionCatalogSection final : public ServerStatusSection {
+public:
+ CollectionCatalogSection() : ServerStatusSection("collectionCatalog") {}
+
+ bool includeByDefault() const override {
+ return true;
+ }
+
+ BSONObj generateSection(OperationContext* opCtx, const BSONElement&) const override {
+ BSONObjBuilder section;
+ section.append(kNumDurableCatalogScansDueToMissingMapping,
+ numScansDueToMissingMapping.loadRelaxed());
+ return section.obj();
+ }
+
+ AtomicWord<long long> numScansDueToMissingMapping;
+} gCollectionCatalogSection;
+
class IgnoreExternalViewChangesForDatabase {
public:
IgnoreExternalViewChangesForDatabase(OperationContext* opCtx, const DatabaseName& dbName)
@@ -1036,6 +1060,7 @@ boost::optional<DurableCatalogEntry> CollectionCatalog::_fetchPITCatalogEntry(
invariant(readTimestamp);
// Scan durable catalog when we don't have accurate catalogId mapping for this timestamp.
+ gCollectionCatalogSection.numScansDueToMissingMapping.fetchAndAdd(1);
auto catalogEntry = DurableCatalog::get(opCtx)->scanForCatalogEntryByNss(opCtx, nss);
writeCatalogIdAfterScan(catalogEntry);
return catalogEntry;