summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAllison Easton <allison.easton@mongodb.com>2022-07-26 06:39:52 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-07-26 07:17:47 +0000
commita09694e5cac45dd0150804e2f43a885e105d541b (patch)
treed0b9476fd3454d0e601066cd83319d7f91e9481d
parent581c2b78935b21bd240732f3a344b157b12bc7dc (diff)
downloadmongo-a09694e5cac45dd0150804e2f43a885e105d541b.tar.gz
SERVER-67253 Track time spent waiting for refresh on the router
-rw-r--r--src/mongo/db/curop.cpp8
-rw-r--r--src/mongo/db/curop.h8
-rw-r--r--src/mongo/s/catalog_cache.cpp12
3 files changed, 28 insertions, 0 deletions
diff --git a/src/mongo/db/curop.cpp b/src/mongo/db/curop.cpp
index 1b17d5080e1..af469dd95f3 100644
--- a/src/mongo/db/curop.cpp
+++ b/src/mongo/db/curop.cpp
@@ -808,6 +808,14 @@ void OpDebug::report(OperationContext* opCtx,
pAttrs->add("prepareConflictDuration", prepareConflictDurationMillis);
}
+ if (catalogCacheDatabaseLookupMillis > Milliseconds::zero()) {
+ pAttrs->add("catalogCacheDatabaseLookupDuration", catalogCacheDatabaseLookupMillis);
+ }
+
+ if (catalogCacheCollectionLookupMillis > Milliseconds::zero()) {
+ pAttrs->add("catalogCacheCollectionLookupDuration", catalogCacheCollectionLookupMillis);
+ }
+
if (databaseVersionRefreshMillis > Milliseconds::zero()) {
pAttrs->add("databaseVersionRefreshDuration", databaseVersionRefreshMillis);
}
diff --git a/src/mongo/db/curop.h b/src/mongo/db/curop.h
index a2877758fd0..15dcb2e0154 100644
--- a/src/mongo/db/curop.h
+++ b/src/mongo/db/curop.h
@@ -299,6 +299,14 @@ public:
// Stores the duration of time spent blocked on prepare conflicts.
Milliseconds prepareConflictDurationMillis{0};
+ // Total time spent looking up database entry in the local catalog cache, including eventual
+ // refreshes.
+ Milliseconds catalogCacheDatabaseLookupMillis{0};
+
+ // Total time spent looking up collection entry in the local catalog cache, including eventual
+ // refreshes.
+ Milliseconds catalogCacheCollectionLookupMillis{0};
+
// Stores the duration of time spent waiting for the shard to refresh the database and wait for
// the database critical section.
Milliseconds databaseVersionRefreshMillis{0};
diff --git a/src/mongo/s/catalog_cache.cpp b/src/mongo/s/catalog_cache.cpp
index 512dd4d2e0b..1600cdaede5 100644
--- a/src/mongo/s/catalog_cache.cpp
+++ b/src/mongo/s/catalog_cache.cpp
@@ -30,6 +30,7 @@
#include "mongo/s/catalog_cache.h"
#include "mongo/bson/bsonobjbuilder.h"
+#include "mongo/db/curop.h"
#include "mongo/db/query/collation/collator_factory_interface.h"
#include "mongo/db/repl/optime_with.h"
#include "mongo/logv2/log.h"
@@ -256,6 +257,11 @@ StatusWith<CachedDatabaseInfo> CatalogCache::getDatabase(OperationContext* opCtx
"SERVER-37398.");
}
+ Timer t{};
+ ScopeGuard finishTiming([&] {
+ CurOp::get(opCtx)->debug().catalogCacheDatabaseLookupMillis += Milliseconds(t.millis());
+ });
+
try {
auto dbEntry = _databaseCache.acquire(opCtx, dbName, CacheCausalConsistency::kLatestKnown);
uassert(ErrorCodes::NamespaceNotFound,
@@ -295,6 +301,12 @@ StatusWith<ChunkManager> CatalogCache::_getCollectionRoutingInfoAt(
return swDbInfo.getStatus();
}
+ Timer curOpTimer{};
+ ScopeGuard finishTiming([&] {
+ CurOp::get(opCtx)->debug().catalogCacheCollectionLookupMillis +=
+ Milliseconds(curOpTimer.millis());
+ });
+
const auto dbInfo = std::move(swDbInfo.getValue());
const auto cacheConsistency = gEnableFinerGrainedCatalogCacheRefresh &&