diff options
Diffstat (limited to 'src/mongo/db/repl/replication_info.cpp')
-rw-r--r-- | src/mongo/db/repl/replication_info.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/mongo/db/repl/replication_info.cpp b/src/mongo/db/repl/replication_info.cpp index d5c183c365f..fd8ce22e8d0 100644 --- a/src/mongo/db/repl/replication_info.cpp +++ b/src/mongo/db/repl/replication_info.cpp @@ -63,13 +63,18 @@ #include "mongo/logv2/log.h" #include "mongo/rpc/metadata/client_metadata.h" #include "mongo/rpc/metadata/client_metadata_ismaster.h" +#include "mongo/transport/ismaster_metrics.h" #include "mongo/util/decimal_counter.h" #include "mongo/util/fail_point.h" #include "mongo/util/map_util.h" namespace mongo { +// Hangs in the beginning of each isMaster command when set. MONGO_FAIL_POINT_DEFINE(waitInIsMaster); +// Awaitable isMaster requests with the proper topologyVersions will sleep for maxAwaitTimeMS on +// standalones. This failpoint will hang right before doing this sleep when set. +MONGO_FAIL_POINT_DEFINE(hangWaitingForIsMasterResponseOnStandalone); using std::list; using std::string; @@ -121,6 +126,15 @@ TopologyVersion appendReplicationInfo(OperationContext* opCtx, // The topologyVersion never changes on a running standalone process, so just sleep for // maxAwaitTimeMS. invariant(maxAwaitTimeMS); + + IsMasterMetrics::get(opCtx)->incrementNumAwaitingTopologyChanges(); + ON_BLOCK_EXIT([&] { IsMasterMetrics::get(opCtx)->decrementNumAwaitingTopologyChanges(); }); + if (MONGO_unlikely(hangWaitingForIsMasterResponseOnStandalone.shouldFail())) { + // Used in tests that wait for this failpoint to be entered to guarantee that the + // request is waiting and metrics have been updated. + LOGV2(31462, "Hanging due to hangWaitingForIsMasterResponseOnStandalone failpoint."); + hangWaitingForIsMasterResponseOnStandalone.pauseWhileSet(opCtx); + } opCtx->sleepFor(Milliseconds(*maxAwaitTimeMS)); } @@ -499,6 +513,9 @@ public: maxAwaitTimeMSField); invariant(clientTopologyVersion); + InExhaustIsMaster::get(opCtx->getClient()->session().get()) + ->setInExhaustIsMaster(true /* inExhaustIsMaster */); + if (clientTopologyVersion->getProcessId() == currentTopologyVersion.getProcessId() && clientTopologyVersion->getCounter() == currentTopologyVersion.getCounter()) { // Indicate that an exhaust message should be generated and the previous BSONObj |