summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mongo/db/s/query_analysis_coordinator.cpp3
-rw-r--r--src/mongo/db/s/query_analysis_coordinator.h1
-rw-r--r--src/mongo/db/s/query_analysis_op_observer.cpp113
-rw-r--r--src/mongo/s/SConscript18
-rw-r--r--src/mongo/s/analyze_shard_key_cmd.idl13
-rw-r--r--src/mongo/s/analyze_shard_key_common.idl25
-rw-r--r--src/mongo/s/analyze_shard_key_documents.idl33
-rw-r--r--src/mongo/s/analyze_shard_key_util.cpp52
-rw-r--r--src/mongo/s/analyze_shard_key_util.h44
-rw-r--r--src/mongo/s/configure_query_analyzer_cmd.idl26
-rw-r--r--src/mongo/s/mongos_main.cpp7
-rw-r--r--src/mongo/s/query_analysis_sampler.cpp4
-rw-r--r--src/mongo/s/query_analysis_sampler.h1
13 files changed, 218 insertions, 122 deletions
diff --git a/src/mongo/db/s/query_analysis_coordinator.cpp b/src/mongo/db/s/query_analysis_coordinator.cpp
index 9faf8ce0ed4..4d71cb00aae 100644
--- a/src/mongo/db/s/query_analysis_coordinator.cpp
+++ b/src/mongo/db/s/query_analysis_coordinator.cpp
@@ -34,7 +34,6 @@
#include "mongo/db/dbdirectclient.h"
#include "mongo/logv2/log.h"
#include "mongo/s/analyze_shard_key_documents_gen.h"
-#include "mongo/s/analyze_shard_key_feature_flag_gen.h"
#include "mongo/s/analyze_shard_key_server_parameters_gen.h"
#include "mongo/s/catalog/type_mongos.h"
@@ -65,7 +64,7 @@ QueryAnalysisCoordinator* QueryAnalysisCoordinator::get(ServiceContext* serviceC
bool QueryAnalysisCoordinator::shouldRegisterReplicaSetAwareService() const {
// This is invoked when the Register above is constructed which is before FCV is set so we need
// to ignore FCV when checking if the feature flag is enabled.
- return analyze_shard_key::gFeatureFlagAnalyzeShardKey.isEnabledAndIgnoreFCV() &&
+ return analyze_shard_key::isFeatureFlagEnabledIgnoreFCV() &&
serverGlobalParams.clusterRole == ClusterRole::ConfigServer;
}
diff --git a/src/mongo/db/s/query_analysis_coordinator.h b/src/mongo/db/s/query_analysis_coordinator.h
index f5a20089534..d311a1239e6 100644
--- a/src/mongo/db/s/query_analysis_coordinator.h
+++ b/src/mongo/db/s/query_analysis_coordinator.h
@@ -33,6 +33,7 @@
#include "mongo/db/repl/replica_set_aware_service.h"
#include "mongo/db/service_context.h"
#include "mongo/s/analyze_shard_key_common_gen.h"
+#include "mongo/s/analyze_shard_key_util.h"
#include "mongo/util/periodic_runner.h"
namespace mongo {
diff --git a/src/mongo/db/s/query_analysis_op_observer.cpp b/src/mongo/db/s/query_analysis_op_observer.cpp
index 5a98c1e8e12..efdbb36a4ee 100644
--- a/src/mongo/db/s/query_analysis_op_observer.cpp
+++ b/src/mongo/db/s/query_analysis_op_observer.cpp
@@ -32,7 +32,7 @@
#include "mongo/db/s/query_analysis_coordinator.h"
#include "mongo/db/s/query_analysis_op_observer.h"
#include "mongo/logv2/log.h"
-#include "mongo/s/analyze_shard_key_feature_flag_gen.h"
+#include "mongo/s/analyze_shard_key_util.h"
#include "mongo/s/catalog/type_mongos.h"
#define MONGO_LOGV2_DEFAULT_COMPONENT ::mongo::logv2::LogComponent::kDefault
@@ -44,12 +44,6 @@ namespace {
const auto docToDeleteDecoration = OperationContext::declareDecoration<BSONObj>();
-bool isFeatureFlagEnabled() {
- return serverGlobalParams.featureCompatibility.isVersionInitialized() &&
- analyze_shard_key::gFeatureFlagAnalyzeShardKey.isEnabled(
- serverGlobalParams.featureCompatibility);
-}
-
} // namespace
void QueryAnalysisOpObserver::onInserts(OperationContext* opCtx,
@@ -57,45 +51,42 @@ void QueryAnalysisOpObserver::onInserts(OperationContext* opCtx,
std::vector<InsertStatement>::const_iterator begin,
std::vector<InsertStatement>::const_iterator end,
bool fromMigrate) {
- if (!isFeatureFlagEnabled()) {
- return;
- }
-
- if (coll->ns() == NamespaceString::kConfigQueryAnalyzersNamespace) {
- for (auto it = begin; it != end; ++it) {
- const auto& insertedDoc = it->doc;
- opCtx->recoveryUnit()->onCommit([opCtx, insertedDoc](boost::optional<Timestamp>) {
- analyze_shard_key::QueryAnalysisCoordinator::get(opCtx)->onConfigurationInsert(
- insertedDoc);
- });
- }
- } else if (coll->ns() == MongosType::ConfigNS) {
- for (auto it = begin; it != end; ++it) {
- const auto& insertedDoc = it->doc;
- opCtx->recoveryUnit()->onCommit([opCtx, insertedDoc](boost::optional<Timestamp>) {
- analyze_shard_key::QueryAnalysisCoordinator::get(opCtx)->onSamplerInsert(
- insertedDoc);
- });
+ if (analyze_shard_key::supportsCoordinatingQueryAnalysis()) {
+ if (coll->ns() == NamespaceString::kConfigQueryAnalyzersNamespace) {
+ for (auto it = begin; it != end; ++it) {
+ const auto& insertedDoc = it->doc;
+ opCtx->recoveryUnit()->onCommit([opCtx, insertedDoc](boost::optional<Timestamp>) {
+ analyze_shard_key::QueryAnalysisCoordinator::get(opCtx)->onConfigurationInsert(
+ insertedDoc);
+ });
+ }
+ } else if (coll->ns() == MongosType::ConfigNS) {
+ for (auto it = begin; it != end; ++it) {
+ const auto& insertedDoc = it->doc;
+ opCtx->recoveryUnit()->onCommit([opCtx, insertedDoc](boost::optional<Timestamp>) {
+ analyze_shard_key::QueryAnalysisCoordinator::get(opCtx)->onSamplerInsert(
+ insertedDoc);
+ });
+ }
}
}
}
void QueryAnalysisOpObserver::onUpdate(OperationContext* opCtx, const OplogUpdateEntryArgs& args) {
- if (!isFeatureFlagEnabled()) {
- return;
- }
-
- if (args.nss == NamespaceString::kConfigQueryAnalyzersNamespace) {
- const auto& updatedDoc = args.updateArgs->updatedDoc;
- opCtx->recoveryUnit()->onCommit([opCtx, updatedDoc](boost::optional<Timestamp>) {
- analyze_shard_key::QueryAnalysisCoordinator::get(opCtx)->onConfigurationUpdate(
- updatedDoc);
- });
- } else if (args.nss == MongosType::ConfigNS) {
- const auto& updatedDoc = args.updateArgs->updatedDoc;
- opCtx->recoveryUnit()->onCommit([opCtx, updatedDoc](boost::optional<Timestamp>) {
- analyze_shard_key::QueryAnalysisCoordinator::get(opCtx)->onSamplerUpdate(updatedDoc);
- });
+ if (analyze_shard_key::supportsCoordinatingQueryAnalysis()) {
+ if (args.nss == NamespaceString::kConfigQueryAnalyzersNamespace) {
+ const auto& updatedDoc = args.updateArgs->updatedDoc;
+ opCtx->recoveryUnit()->onCommit([opCtx, updatedDoc](boost::optional<Timestamp>) {
+ analyze_shard_key::QueryAnalysisCoordinator::get(opCtx)->onConfigurationUpdate(
+ updatedDoc);
+ });
+ } else if (args.nss == MongosType::ConfigNS) {
+ const auto& updatedDoc = args.updateArgs->updatedDoc;
+ opCtx->recoveryUnit()->onCommit([opCtx, updatedDoc](boost::optional<Timestamp>) {
+ analyze_shard_key::QueryAnalysisCoordinator::get(opCtx)->onSamplerUpdate(
+ updatedDoc);
+ });
+ }
}
}
@@ -103,12 +94,10 @@ void QueryAnalysisOpObserver::aboutToDelete(OperationContext* opCtx,
NamespaceString const& nss,
const UUID& uuid,
BSONObj const& doc) {
- if (!isFeatureFlagEnabled()) {
- return;
- }
-
- if (nss == NamespaceString::kConfigQueryAnalyzersNamespace || nss == MongosType::ConfigNS) {
- docToDeleteDecoration(opCtx) = doc;
+ if (analyze_shard_key::supportsCoordinatingQueryAnalysis()) {
+ if (nss == NamespaceString::kConfigQueryAnalyzersNamespace || nss == MongosType::ConfigNS) {
+ docToDeleteDecoration(opCtx) = doc;
+ }
}
}
@@ -117,22 +106,20 @@ void QueryAnalysisOpObserver::onDelete(OperationContext* opCtx,
const UUID& uuid,
StmtId stmtId,
const OplogDeleteEntryArgs& args) {
- if (!isFeatureFlagEnabled()) {
- return;
- }
-
- if (nss == NamespaceString::kConfigQueryAnalyzersNamespace) {
- auto& doc = docToDeleteDecoration(opCtx);
- invariant(!doc.isEmpty());
- opCtx->recoveryUnit()->onCommit([opCtx, doc](boost::optional<Timestamp>) {
- analyze_shard_key::QueryAnalysisCoordinator::get(opCtx)->onConfigurationDelete(doc);
- });
- } else if (nss == MongosType::ConfigNS) {
- auto& doc = docToDeleteDecoration(opCtx);
- invariant(!doc.isEmpty());
- opCtx->recoveryUnit()->onCommit([opCtx, doc](boost::optional<Timestamp>) {
- analyze_shard_key::QueryAnalysisCoordinator::get(opCtx)->onSamplerDelete(doc);
- });
+ if (analyze_shard_key::supportsCoordinatingQueryAnalysis()) {
+ if (nss == NamespaceString::kConfigQueryAnalyzersNamespace) {
+ auto& doc = docToDeleteDecoration(opCtx);
+ invariant(!doc.isEmpty());
+ opCtx->recoveryUnit()->onCommit([opCtx, doc](boost::optional<Timestamp>) {
+ analyze_shard_key::QueryAnalysisCoordinator::get(opCtx)->onConfigurationDelete(doc);
+ });
+ } else if (nss == MongosType::ConfigNS) {
+ auto& doc = docToDeleteDecoration(opCtx);
+ invariant(!doc.isEmpty());
+ opCtx->recoveryUnit()->onCommit([opCtx, doc](boost::optional<Timestamp>) {
+ analyze_shard_key::QueryAnalysisCoordinator::get(opCtx)->onSamplerDelete(doc);
+ });
+ }
}
}
diff --git a/src/mongo/s/SConscript b/src/mongo/s/SConscript
index 36edec571aa..82eb4d98ee6 100644
--- a/src/mongo/s/SConscript
+++ b/src/mongo/s/SConscript
@@ -132,15 +132,26 @@ env.Library(
],
)
-# Sharding code needed by both mongos and mongod.
env.Library(
- target='common_s',
+ target='analyze_shard_key_common',
source=[
- 'analyze_shard_key_cmd.idl',
'analyze_shard_key_common.idl',
'analyze_shard_key_documents.idl',
'analyze_shard_key_feature_flag.idl',
'analyze_shard_key_server_parameters.idl',
+ 'analyze_shard_key_util.cpp',
+ ],
+ LIBDEPS_PRIVATE=[
+ '$BUILD_DIR/mongo/db/server_base',
+ '$BUILD_DIR/mongo/util/namespace_string_util',
+ ],
+)
+
+# Sharding code needed by both mongos and mongod.
+env.Library(
+ target='common_s',
+ source=[
+ 'analyze_shard_key_cmd.idl',
'cannot_implicitly_create_collection_info.cpp',
'catalog/mongo_version_range.cpp',
'catalog/type_changelog.cpp',
@@ -219,6 +230,7 @@ env.Library(
'$BUILD_DIR/mongo/db/repl/optime',
'$BUILD_DIR/mongo/db/server_options',
'$BUILD_DIR/mongo/rpc/message',
+ 'analyze_shard_key_common',
],
LIBDEPS_PRIVATE=[
'$BUILD_DIR/mongo/db/server_base',
diff --git a/src/mongo/s/analyze_shard_key_cmd.idl b/src/mongo/s/analyze_shard_key_cmd.idl
index fa0998f609d..8105f23d5a0 100644
--- a/src/mongo/s/analyze_shard_key_cmd.idl
+++ b/src/mongo/s/analyze_shard_key_cmd.idl
@@ -43,9 +43,9 @@ enums:
kUnknown: "unknown"
structs:
- percentileMetrics:
+ PercentileMetrics:
description: "The percentile metrics for a set of non-negative integers."
- strict: true
+ strict: false
fields:
p99:
type: long
@@ -63,8 +63,9 @@ structs:
type: long
validator: { gte: 0 }
- keyCharacteristicsMetrics:
+ KeyCharacteristicsMetrics:
description: "The metrics about the characteristics of a shard key."
+ strict: false
fields:
numDocs:
type: long
@@ -81,7 +82,7 @@ structs:
validator: { gte: 0 }
optional: true
frequency:
- type: percentileMetrics
+ type: PercentileMetrics
description: "The percentile metrics for the number of documents for each distinct shard key
value."
optional: true
@@ -100,13 +101,13 @@ structs:
strict: false
inline_chained_structs: true
chained_structs:
- keyCharacteristicsMetrics: keyCharacteristics
+ KeyCharacteristicsMetrics: keyCharacteristics
commands:
analyzeShardKey:
description: "The command for calculating metrics for evaluating a shard key for a collection."
command_name: analyzeShardKey
- strict: true
+ strict: false
namespace: type
api_version: ""
type: namespacestring
diff --git a/src/mongo/s/analyze_shard_key_common.idl b/src/mongo/s/analyze_shard_key_common.idl
index 66fb6fbbdb3..ee6ba4470c1 100644
--- a/src/mongo/s/analyze_shard_key_common.idl
+++ b/src/mongo/s/analyze_shard_key_common.idl
@@ -32,9 +32,32 @@ global:
imports:
- "mongo/db/basic_types.idl"
+enums:
+ QueryAnalyzerMode:
+ description: "The query analysis mode for a collection."
+ type: string
+ values:
+ kFull: "full"
+ kOff: "off"
+
structs:
+ QueryAnalyzerConfiguration:
+ description: "The query analyzer configuration for a collection as configured via the
+ configureQueryAnalyzer command."
+ strict: false
+ fields:
+ mode:
+ type: QueryAnalyzerMode
+ description: "The query analyzer mode."
+ sampleRate:
+ type: double
+ description: "The maximum number of queries to sample per second, in total across the
+ cluster (not per mongos or mongod)."
+ optional: true
+
CollectionQueryAnalyzerConfiguration:
- description: "The query analyzer configuration for a collection."
+ description: "The query analyzer configuration for a collection as returned by the
+ _refreshQueryAnalyzerConfiguration command."
fields:
ns:
type: namespacestring
diff --git a/src/mongo/s/analyze_shard_key_documents.idl b/src/mongo/s/analyze_shard_key_documents.idl
index c7254322a9e..fc1437965b6 100644
--- a/src/mongo/s/analyze_shard_key_documents.idl
+++ b/src/mongo/s/analyze_shard_key_documents.idl
@@ -27,23 +27,24 @@
#
global:
- cpp_namespace: "mongo"
+ cpp_namespace: "mongo"
imports:
- - "mongo/db/basic_types.idl"
- - "mongo/s/configure_query_analyzer_cmd.idl"
+ - "mongo/db/basic_types.idl"
+ - "mongo/s/analyze_shard_key_common.idl"
structs:
- QueryAnalyzerDocument:
- description: "Represents settings for query sampling for one collection."
- fields:
- _id:
- type: uuid
- description: "The UUID of the collection being sampled."
- cpp_name: collectionUuid
- ns:
- type: namespacestring
- description: "The namespace of the collectiong being sampled."
- inline_chained_structs: true
- chained_structs:
- queryAnalyzerConfiguration: configuration
+ QueryAnalyzerDocument:
+ description: "Represents a document storing the query analyzer configuration for a collection
+ as configured via the configureQueryAnalyzer command."
+ fields:
+ _id:
+ type: uuid
+ description: "The UUID of the collection."
+ cpp_name: collectionUuid
+ ns:
+ type: namespacestring
+ description: "The namespace of the collection."
+ inline_chained_structs: true
+ chained_structs:
+ QueryAnalyzerConfiguration: configuration
diff --git a/src/mongo/s/analyze_shard_key_util.cpp b/src/mongo/s/analyze_shard_key_util.cpp
new file mode 100644
index 00000000000..36ad137dfa2
--- /dev/null
+++ b/src/mongo/s/analyze_shard_key_util.cpp
@@ -0,0 +1,52 @@
+/**
+ * Copyright (C) 2022-present MongoDB, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the Server Side Public License, version 1,
+ * as published by MongoDB, Inc.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * Server Side Public License for more details.
+ *
+ * You should have received a copy of the Server Side Public License
+ * along with this program. If not, see
+ * <http://www.mongodb.com/licensing/server-side-public-license>.
+ *
+ * As a special exception, the copyright holders give permission to link the
+ * code of portions of this program with the OpenSSL library under certain
+ * conditions as described in each individual source file and distribute
+ * linked combinations including the program with the OpenSSL library. You
+ * must comply with the Server Side Public License in all respects for
+ * all of the code used other than as permitted herein. If you modify file(s)
+ * with this exception, you may extend this exception to your version of the
+ * file(s), but you are not obligated to do so. If you do not wish to do so,
+ * delete this exception statement from your version. If you delete this
+ * exception statement from all source files in the program, then also delete
+ * it in the license file.
+ */
+
+#include "mongo/s/analyze_shard_key_util.h"
+
+#include "mongo/s/analyze_shard_key_feature_flag_gen.h"
+
+namespace mongo {
+namespace analyze_shard_key {
+
+bool isFeatureFlagEnabled() {
+ return serverGlobalParams.featureCompatibility.isVersionInitialized() &&
+ analyze_shard_key::gFeatureFlagAnalyzeShardKey.isEnabled(
+ serverGlobalParams.featureCompatibility);
+}
+
+bool isFeatureFlagEnabledIgnoreFCV() {
+ return analyze_shard_key::gFeatureFlagAnalyzeShardKey.isEnabledAndIgnoreFCV();
+}
+
+bool supportsCoordinatingQueryAnalysis() {
+ return isFeatureFlagEnabled() && serverGlobalParams.clusterRole == ClusterRole::ConfigServer;
+}
+
+} // namespace analyze_shard_key
+} // namespace mongo
diff --git a/src/mongo/s/analyze_shard_key_util.h b/src/mongo/s/analyze_shard_key_util.h
new file mode 100644
index 00000000000..266431a477b
--- /dev/null
+++ b/src/mongo/s/analyze_shard_key_util.h
@@ -0,0 +1,44 @@
+/**
+ * Copyright (C) 2022-present MongoDB, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the Server Side Public License, version 1,
+ * as published by MongoDB, Inc.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * Server Side Public License for more details.
+ *
+ * You should have received a copy of the Server Side Public License
+ * along with this program. If not, see
+ * <http://www.mongodb.com/licensing/server-side-public-license>.
+ *
+ * As a special exception, the copyright holders give permission to link the
+ * code of portions of this program with the OpenSSL library under certain
+ * conditions as described in each individual source file and distribute
+ * linked combinations including the program with the OpenSSL library. You
+ * must comply with the Server Side Public License in all respects for
+ * all of the code used other than as permitted herein. If you modify file(s)
+ * with this exception, you may extend this exception to your version of the
+ * file(s), but you are not obligated to do so. If you do not wish to do so,
+ * delete this exception statement from your version. If you delete this
+ * exception statement from all source files in the program, then also delete
+ * it in the license file.
+ */
+
+#pragma once
+
+#include "mongo/platform/basic.h"
+
+namespace mongo {
+namespace analyze_shard_key {
+
+bool isFeatureFlagEnabled();
+
+bool isFeatureFlagEnabledIgnoreFCV();
+
+bool supportsCoordinatingQueryAnalysis();
+
+} // namespace analyze_shard_key
+} // namespace mongo
diff --git a/src/mongo/s/configure_query_analyzer_cmd.idl b/src/mongo/s/configure_query_analyzer_cmd.idl
index 6dd0cc194f3..395c6b6e72a 100644
--- a/src/mongo/s/configure_query_analyzer_cmd.idl
+++ b/src/mongo/s/configure_query_analyzer_cmd.idl
@@ -31,35 +31,15 @@ global:
imports:
- "mongo/db/basic_types.idl"
-
-enums:
- QueryAnalyzerMode:
- description: "The query analysis mode for a collection."
- type: string
- values:
- kFull: "full"
- kOff: "off"
+ - "mongo/s/analyze_shard_key_common.idl"
structs:
- queryAnalyzerConfiguration:
- description: "The query analyzer configuration for a collection."
- strict: true
- fields:
- mode:
- type: QueryAnalyzerMode
- description: "The query analysis mode."
- sampleRate:
- type: double
- description: "The maximum number of queries to sample per second, in total across the
- cluster (not per mongos or mongod)."
- optional: true
-
configureQueryAnalyzerResponse:
description: "The response for the 'configureQueryAnalyzer' command."
strict: false
inline_chained_structs: true
chained_structs:
- queryAnalyzerConfiguration: newConfiguration
+ QueryAnalyzerConfiguration: newConfiguration
commands:
configureQueryAnalyzer:
@@ -71,4 +51,4 @@ commands:
type: namespacestring
inline_chained_structs: true
chained_structs:
- queryAnalyzerConfiguration: configuration
+ QueryAnalyzerConfiguration: configuration
diff --git a/src/mongo/s/mongos_main.cpp b/src/mongo/s/mongos_main.cpp
index 6a07b0a1ea0..115abcaba2c 100644
--- a/src/mongo/s/mongos_main.cpp
+++ b/src/mongo/s/mongos_main.cpp
@@ -73,7 +73,6 @@
#include "mongo/logv2/log.h"
#include "mongo/platform/process_id.h"
#include "mongo/rpc/metadata/egress_metadata_hook_list.h"
-#include "mongo/s/analyze_shard_key_feature_flag_gen.h"
#include "mongo/s/balancer_configuration.h"
#include "mongo/s/catalog_cache.h"
#include "mongo/s/client/shard_factory.h"
@@ -314,8 +313,7 @@ void cleanupTask(const ShutdownTaskArgs& shutdownArgs) {
lsc->joinOnShutDown();
}
- if (analyze_shard_key::gFeatureFlagAnalyzeShardKey.isEnabled(
- serverGlobalParams.featureCompatibility)) {
+ if (analyze_shard_key::isFeatureFlagEnabled()) {
LOGV2_OPTIONS(
6973901, {LogComponent::kDefault}, "Shutting down the QueryAnalysisSampler");
analyze_shard_key::QueryAnalysisSampler::get(serviceContext).onShutdown();
@@ -795,8 +793,7 @@ ExitCode runMongosServer(ServiceContext* serviceContext) {
return ExitCode::processHealthCheck;
}
- if (analyze_shard_key::gFeatureFlagAnalyzeShardKey.isEnabled(
- serverGlobalParams.featureCompatibility)) {
+ if (analyze_shard_key::isFeatureFlagEnabled()) {
LOGV2_OPTIONS(6973900, {LogComponent::kDefault}, "Starting the QueryAnalysisSampler");
analyze_shard_key::QueryAnalysisSampler::get(serviceContext).onStartup();
}
diff --git a/src/mongo/s/query_analysis_sampler.cpp b/src/mongo/s/query_analysis_sampler.cpp
index 5276a480ccf..0cad2a0cf64 100644
--- a/src/mongo/s/query_analysis_sampler.cpp
+++ b/src/mongo/s/query_analysis_sampler.cpp
@@ -33,7 +33,6 @@
#include "mongo/db/stats/counters.h"
#include "mongo/logv2/log.h"
-#include "mongo/s/analyze_shard_key_feature_flag_gen.h"
#include "mongo/s/grid.h"
#include "mongo/s/is_mongos.h"
#include "mongo/s/refresh_query_analyzer_configuration_cmd_gen.h"
@@ -61,8 +60,7 @@ QueryAnalysisSampler& QueryAnalysisSampler::get(OperationContext* opCtx) {
}
QueryAnalysisSampler& QueryAnalysisSampler::get(ServiceContext* serviceContext) {
- invariant(analyze_shard_key::gFeatureFlagAnalyzeShardKey.isEnabled(
- serverGlobalParams.featureCompatibility),
+ invariant(analyze_shard_key::isFeatureFlagEnabled(),
"Only support analyzing queries when the feature flag is enabled");
invariant(isMongos(), "Only support analyzing queries on a sharded cluster");
return getQueryAnalysisSampler(serviceContext);
diff --git a/src/mongo/s/query_analysis_sampler.h b/src/mongo/s/query_analysis_sampler.h
index 728267f256a..e1c120c498d 100644
--- a/src/mongo/s/query_analysis_sampler.h
+++ b/src/mongo/s/query_analysis_sampler.h
@@ -32,6 +32,7 @@
#include "mongo/db/operation_context.h"
#include "mongo/db/service_context.h"
#include "mongo/s/analyze_shard_key_server_parameters_gen.h"
+#include "mongo/s/analyze_shard_key_util.h"
#include "mongo/util/periodic_runner.h"
namespace mongo {