summaryrefslogtreecommitdiff
path: root/src/mongo/db/mongod_main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/mongod_main.cpp')
-rw-r--r--src/mongo/db/mongod_main.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/mongo/db/mongod_main.cpp b/src/mongo/db/mongod_main.cpp
index 65b6d06f112..127f694b9d5 100644
--- a/src/mongo/db/mongod_main.cpp
+++ b/src/mongo/db/mongod_main.cpp
@@ -142,6 +142,7 @@
#include "mongo/db/s/op_observer_sharding_impl.h"
#include "mongo/db/s/periodic_sharded_index_consistency_checker.h"
#include "mongo/db/s/query_analysis_op_observer.h"
+#include "mongo/db/s/query_analysis_writer.h"
#include "mongo/db/s/rename_collection_participant_service.h"
#include "mongo/db/s/resharding/resharding_coordinator_service.h"
#include "mongo/db/s/resharding/resharding_donor_service.h"
@@ -856,6 +857,10 @@ ExitCode _initAndListen(ServiceContext* serviceContext, int listenPort) {
auto catalog = std::make_unique<StatsCatalog>(serviceContext, std::move(cacheLoader));
StatsCatalog::set(serviceContext, std::move(catalog));
+ if (analyze_shard_key::supportsPersistingSampledQueriesIgnoreFCV()) {
+ analyze_shard_key::QueryAnalysisWriter::get(serviceContext).onStartup();
+ }
+
// MessageServer::run will return when exit code closes its socket and we don't need the
// operation context anymore
startupOpCtx.reset();
@@ -1174,6 +1179,8 @@ void setUpObservers(ServiceContext* serviceContext) {
std::make_unique<OplogWriterTransactionProxy>(std::make_unique<OplogWriterImpl>())));
opObserverRegistry->addObserver(std::make_unique<ShardServerOpObserver>());
opObserverRegistry->addObserver(std::make_unique<ReshardingOpObserver>());
+ opObserverRegistry->addObserver(
+ std::make_unique<analyze_shard_key::QueryAnalysisOpObserver>());
opObserverRegistry->addObserver(std::make_unique<repl::TenantMigrationDonorOpObserver>());
opObserverRegistry->addObserver(
std::make_unique<repl::TenantMigrationRecipientOpObserver>());
@@ -1314,6 +1321,11 @@ void shutdownTask(const ShutdownTaskArgs& shutdownArgs) {
lsc->joinOnShutDown();
}
+ if (analyze_shard_key::supportsPersistingSampledQueriesIgnoreFCV()) {
+ LOGV2(7047303, "Shutting down the QueryAnalysisWriter");
+ analyze_shard_key::QueryAnalysisWriter::get(serviceContext).onShutdown();
+ }
+
// Shutdown the TransportLayer so that new connections aren't accepted
if (auto tl = serviceContext->getTransportLayer()) {
LOGV2_OPTIONS(