diff options
author | Jason Chan <jason.chan@mongodb.com> | 2020-02-21 22:41:38 +0000 |
---|---|---|
committer | evergreen <evergreen@mongodb.com> | 2020-02-21 22:41:38 +0000 |
commit | db649073af2b6dac30b5d207ffa484f7d8cdc2b2 (patch) | |
tree | f93ea76d161cf3732eeaefefecea5a9788c22063 /src/mongo/s/commands/cluster_is_master_cmd.cpp | |
parent | 1315b6fdd3ade546c37364bcd4b0ba224adb7f58 (diff) | |
download | mongo-db649073af2b6dac30b5d207ffa484f7d8cdc2b2.tar.gz |
SERVER-44522 serverStatus metrics for awaitable isMaster
Diffstat (limited to 'src/mongo/s/commands/cluster_is_master_cmd.cpp')
-rw-r--r-- | src/mongo/s/commands/cluster_is_master_cmd.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/mongo/s/commands/cluster_is_master_cmd.cpp b/src/mongo/s/commands/cluster_is_master_cmd.cpp index 203f5e2e3df..084e9ef7488 100644 --- a/src/mongo/s/commands/cluster_is_master_cmd.cpp +++ b/src/mongo/s/commands/cluster_is_master_cmd.cpp @@ -42,6 +42,7 @@ #include "mongo/rpc/metadata/client_metadata.h" #include "mongo/rpc/metadata/client_metadata_ismaster.h" #include "mongo/rpc/topology_version_gen.h" +#include "mongo/transport/ismaster_metrics.h" #include "mongo/transport/message_compressor_manager.h" #include "mongo/util/map_util.h" #include "mongo/util/net/socket_utils.h" @@ -49,7 +50,11 @@ namespace mongo { +// Hangs in the beginning of each isMaster command when set. MONGO_FAIL_POINT_DEFINE(waitInIsMaster); +// Awaitable isMaster requests with the proper topologyVersions are expected to sleep for +// maxAwaitTimeMS on mongos. This failpoint will hang right before doing this sleep when set. +MONGO_FAIL_POINT_DEFINE(hangWhileWaitingForIsMasterResponse); TopologyVersion mongosTopologyVersion; @@ -152,6 +157,13 @@ public: // The topologyVersion never changes on a running mongos process, so just sleep for // maxAwaitTimeMS. + IsMasterMetrics::get(opCtx)->incrementNumAwaitingTopologyChanges(); + ON_BLOCK_EXIT( + [&] { IsMasterMetrics::get(opCtx)->decrementNumAwaitingTopologyChanges(); }); + if (MONGO_unlikely(hangWhileWaitingForIsMasterResponse.shouldFail())) { + LOGV2(31463, "hangWhileWaitingForIsMasterResponse failpoint enabled."); + hangWhileWaitingForIsMasterResponse.pauseWhileSet(opCtx); + } opCtx->sleepFor(Milliseconds(maxAwaitTimeMS)); } } else { @@ -200,6 +212,9 @@ public: maxAwaitTimeMSField); invariant(clientTopologyVersion); + InExhaustIsMaster::get(opCtx->getClient()->session().get()) + ->setInExhaustIsMaster(true /* inExhaustIsMaster */); + if (clientTopologyVersion->getProcessId() == mongosTopologyVersion.getProcessId() && clientTopologyVersion->getCounter() == mongosTopologyVersion.getCounter()) { // Indicate that an exhaust message should be generated and the previous BSONObj |