summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAllison Easton <allison.easton@mongodb.com>2022-07-05 13:15:23 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-07-05 13:55:51 +0000
commit72208cda612439acd942363ebea10cc9d4d79ca8 (patch)
tree2beb515664c3dff4503e8b054f2cb267d04b48a2
parent91a4179916a8627f8e492a2a6e26dc4679033842 (diff)
downloadmongo-72208cda612439acd942363ebea10cc9d4d79ca8.tar.gz
SERVER-67252 Track time spent waiting for refresh on the shards
-rw-r--r--src/mongo/db/curop.cpp8
-rw-r--r--src/mongo/db/curop.h8
-rw-r--r--src/mongo/db/s/shard_filtering_metadata_refresh.cpp10
3 files changed, 26 insertions, 0 deletions
diff --git a/src/mongo/db/curop.cpp b/src/mongo/db/curop.cpp
index bd15b40232c..251f0e7fcf0 100644
--- a/src/mongo/db/curop.cpp
+++ b/src/mongo/db/curop.cpp
@@ -810,6 +810,14 @@ void OpDebug::report(OperationContext* opCtx,
pAttrs->add("prepareConflictDuration", prepareConflictDurationMillis);
}
+ if (databaseVersionRefreshMillis > Milliseconds::zero()) {
+ pAttrs->add("databaseVersionRefreshDuration", databaseVersionRefreshMillis);
+ }
+
+ if (shardVersionRefreshMillis > Milliseconds::zero()) {
+ pAttrs->add("shardVersionRefreshDuration", shardVersionRefreshMillis);
+ }
+
if (dataThroughputLastSecond) {
pAttrs->add("dataThroughputLastSecondMBperSec", *dataThroughputLastSecond);
}
diff --git a/src/mongo/db/curop.h b/src/mongo/db/curop.h
index cdc5e4f20d7..b641ae3547f 100644
--- a/src/mongo/db/curop.h
+++ b/src/mongo/db/curop.h
@@ -284,6 +284,14 @@ public:
// Stores the duration of time spent blocked on prepare conflicts.
Milliseconds prepareConflictDurationMillis{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};
+
+ // Stores the duration of time spent waiting for the shard to refresh the collection and wait
+ // for the collection critical section.
+ Milliseconds shardVersionRefreshMillis{0};
+
// Stores the amount of the data processed by the throttle cursors in MB/sec.
boost::optional<float> dataThroughputLastSecond;
boost::optional<float> dataThroughputAverage;
diff --git a/src/mongo/db/s/shard_filtering_metadata_refresh.cpp b/src/mongo/db/s/shard_filtering_metadata_refresh.cpp
index 51bb630571f..60046674966 100644
--- a/src/mongo/db/s/shard_filtering_metadata_refresh.cpp
+++ b/src/mongo/db/s/shard_filtering_metadata_refresh.cpp
@@ -33,6 +33,7 @@
#include "mongo/db/catalog/database_holder.h"
#include "mongo/db/catalog_raii.h"
#include "mongo/db/commands/feature_compatibility_version.h"
+#include "mongo/db/curop.h"
#include "mongo/db/operation_context.h"
#include "mongo/db/s/collection_sharding_runtime.h"
#include "mongo/db/s/database_sharding_state.h"
@@ -64,6 +65,11 @@ void onDbVersionMismatch(OperationContext* opCtx,
invariant(!opCtx->getClient()->isInDirectClient());
invariant(ShardingState::get(opCtx)->canAcceptShardedCommands());
+ Timer t{};
+ ScopeGuard finishTiming([&] {
+ CurOp::get(opCtx)->debug().databaseVersionRefreshMillis += Milliseconds(t.millis());
+ });
+
{
// Take the DBLock directly rather than using AutoGetDb, to prevent a recursive call into
// checkDbVersion().
@@ -243,6 +249,10 @@ void onShardVersionMismatch(OperationContext* opCtx,
invariant(!opCtx->getClient()->isInDirectClient());
invariant(ShardingState::get(opCtx)->canAcceptShardedCommands());
+ Timer t{};
+ ScopeGuard finishTiming(
+ [&] { CurOp::get(opCtx)->debug().shardVersionRefreshMillis += Milliseconds(t.millis()); });
+
if (nss.isNamespaceAlwaysUnsharded()) {
return;
}