summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuhong Zhang <yuhong.zhang@mongodb.com>2022-03-29 14:43:17 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-03-29 17:02:21 +0000
commit6d429374fbe31b67ec0303151ebc5ec01159eee5 (patch)
treec445a360099f61cd0ce32d0d7eb2ff2a8bcfc44a
parent5157deaa6adcce380f01f4736efbdf3c473e11bf (diff)
downloadmongo-6d429374fbe31b67ec0303151ebc5ec01159eee5.tar.gz
SERVER-63271 Skip appending the watchdog section to serverStatus if watchdog is not enabled
-rw-r--r--jstests/noPassthrough/serverStatus_does_not_block_on_RSTL.js3
-rw-r--r--src/mongo/watchdog/watchdog_mongod.cpp6
2 files changed, 6 insertions, 3 deletions
diff --git a/jstests/noPassthrough/serverStatus_does_not_block_on_RSTL.js b/jstests/noPassthrough/serverStatus_does_not_block_on_RSTL.js
index 72d6217467e..ee74b4ddf3a 100644
--- a/jstests/noPassthrough/serverStatus_does_not_block_on_RSTL.js
+++ b/jstests/noPassthrough/serverStatus_does_not_block_on_RSTL.js
@@ -57,8 +57,7 @@ try {
resourceConsumption: 1,
sharding: 1,
tenantMigrationAccessBlocker: 1,
- // TODO: uncomment this when SERVER-63271 gets fixed.
- // watchdog: 1,
+ watchdog: 1,
maxTimeMS: 20 * 1000
}));
jsTestLog("ServerStatus results: " + tojson(serverStatusResult));
diff --git a/src/mongo/watchdog/watchdog_mongod.cpp b/src/mongo/watchdog/watchdog_mongod.cpp
index 2c7d96075c0..07ad1c93f5e 100644
--- a/src/mongo/watchdog/watchdog_mongod.cpp
+++ b/src/mongo/watchdog/watchdog_mongod.cpp
@@ -116,9 +116,13 @@ public:
}
BSONObj generateSection(OperationContext* opCtx, const BSONElement& configElement) const {
- BSONObjBuilder result;
+ if (!watchdogEnabled) {
+ return BSONObj();
+ }
+ BSONObjBuilder result;
WatchdogMonitor* watchdog = getWatchdogMonitor(opCtx->getServiceContext()).get();
+ invariant(watchdog);
result.append("checkGeneration", watchdog->getCheckGeneration());
result.append("monitorGeneration", watchdog->getMonitorGeneration());