From c256da787a986f3adf2096306a68e782f62a3113 Mon Sep 17 00:00:00 2001 From: Mark Benvenuto Date: Thu, 11 Oct 2018 14:21:13 -0400 Subject: SERVER-34199 Remove serverStatus timing section from FTDC (cherry picked from commit a222ef5e647ac527f7d4f8636bcacd6cc0ae6b8e) --- src/mongo/db/commands/server_status.cpp | 17 ++++++++++++++++- src/mongo/db/ftdc/ftdc_server.cpp | 4 +++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/mongo/db/commands/server_status.cpp b/src/mongo/db/commands/server_status.cpp index 89eae376373..01fd9569fc4 100644 --- a/src/mongo/db/commands/server_status.cpp +++ b/src/mongo/db/commands/server_status.cpp @@ -50,6 +50,10 @@ using std::map; using std::string; using std::stringstream; +namespace { +constexpr auto kTimingSection = "timing"_sd; +} // namespace + class CmdServerStatus : public BasicCommand { public: CmdServerStatus() : BasicCommand("serverStatus"), _started(Date_t::now()), _runCalled(false) {} @@ -154,13 +158,24 @@ public: if (runElapsed > Milliseconds(1000)) { BSONObj t = timeBuilder.obj(); log() << "serverStatus was very slow: " << t; - result.append("timing", t); + + bool include_timing = true; + const auto& elem = cmdObj[kTimingSection]; + if (!elem.eoo()) { + include_timing = elem.trueValue(); + } + + if (include_timing) { + result.append(kTimingSection, t); + } } return true; } void addSection(ServerStatusSection* section) { + // Disallow adding a section named "timing" as it is reserved for the server status command. + dassert(section->getSectionName() != kTimingSection); verify(!_runCalled); _sections[section->getSectionName()] = section; } diff --git a/src/mongo/db/ftdc/ftdc_server.cpp b/src/mongo/db/ftdc/ftdc_server.cpp index 95eb2b21b83..a46a0106262 100644 --- a/src/mongo/db/ftdc/ftdc_server.cpp +++ b/src/mongo/db/ftdc/ftdc_server.cpp @@ -293,12 +293,14 @@ void startFTDC(boost::filesystem::path& path, // migration status. This section triggers too many schema changes in the serverStatus which // hurt ftdc compression efficiency, because its output varies depending on the list of active // migrations. + // "timing" is filtered out because it triggers frequent schema changes. // TODO: do we need to enable "sharding" on MongoS? controller->addPeriodicCollector(stdx::make_unique( "serverStatus", "serverStatus", "", - BSON("serverStatus" << 1 << "tcMalloc" << true << "sharding" << false))); + BSON("serverStatus" << 1 << "tcMalloc" << true << "sharding" << false << "timing" + << false))); registerCollectors(controller.get()); -- cgit v1.2.1