diff options
author | Medha Potluri <medha.potluri@mongodb.com> | 2019-07-08 14:59:41 -0400 |
---|---|---|
committer | Medha Potluri <medha.potluri@mongodb.com> | 2019-07-29 10:44:09 -0400 |
commit | 2ae4fd3e580c90ecfca524d02b9a484f671768f0 (patch) | |
tree | 6a64bf9c1aa9f7e0b470774ee5fde950bd130cd0 /src/mongo/db/repl/repl_set_commands.cpp | |
parent | 102c20ab166050ae7357732070bc8262aa61749c (diff) | |
download | mongo-2ae4fd3e580c90ecfca524d02b9a484f671768f0.tar.gz |
SERVER-41509 Track the number of attempted stepDowns in serverStatus
Diffstat (limited to 'src/mongo/db/repl/repl_set_commands.cpp')
-rw-r--r-- | src/mongo/db/repl/repl_set_commands.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/mongo/db/repl/repl_set_commands.cpp b/src/mongo/db/repl/repl_set_commands.cpp index d614be0d7a9..6eb9779881d 100644 --- a/src/mongo/db/repl/repl_set_commands.cpp +++ b/src/mongo/db/repl/repl_set_commands.cpp @@ -458,16 +458,23 @@ public: "primary.)\n" "http://dochub.mongodb.org/core/replicasetcommands"; } - CmdReplSetStepDown() : ReplSetCommand("replSetStepDown") {} + CmdReplSetStepDown() + : ReplSetCommand("replSetStepDown"), + _stepDownCmdsWithForceExecutedMetric("commands.replSetStepDownWithForce.total", + &_stepDownCmdsWithForceExecuted) {} virtual bool run(OperationContext* opCtx, const string&, const BSONObj& cmdObj, BSONObjBuilder& result) { + const bool force = cmdObj["force"].trueValue(); + + if (force) { + _stepDownCmdsWithForceExecuted.increment(); + } + Status status = ReplicationCoordinator::get(opCtx)->checkReplEnabledForCommand(&result); uassertStatusOK(status); - const bool force = cmdObj["force"].trueValue(); - long long stepDownForSecs = cmdObj.firstElement().numberLong(); if (stepDownForSecs == 0) { stepDownForSecs = 60; @@ -513,6 +520,9 @@ public: } private: + mutable Counter64 _stepDownCmdsWithForceExecuted; + ServerStatusMetricField<Counter64> _stepDownCmdsWithForceExecutedMetric; + ActionSet getAuthActionSet() const override { return ActionSet{ActionType::replSetStateChange}; } |