From f3fa519bd0c83ed9558dedfa72dbee2c26453dcb Mon Sep 17 00:00:00 2001 From: "Joan Bruguera Micó (at MongoDB)" Date: Wed, 14 Aug 2024 13:17:35 +0000 Subject: SERVER-93033 Sharding cluster parameters cannot be accessed via MongoS (#26107) GitOrigin-RevId: 65ad2fff60e3f8d34a5dd47fb25bb36a0ee92f0a --- jstests/libs/cluster_server_parameter_utils.js | 48 +++++++-- .../cluster_server_parameter_refresher.js | 4 + src/mongo/db/SConscript | 1 - src/mongo/db/direct_connection_util.cpp | 2 +- .../db/replica_set_endpoint_sharding_state.cpp | 2 +- .../replica_set_endpoint_sharding_state_test.cpp | 2 +- src/mongo/db/replica_set_endpoint_test_fixture.cpp | 2 +- src/mongo/db/replica_set_endpoint_test_fixture.h | 2 +- src/mongo/db/s/SConscript | 11 -- .../sharding_catalog_manager_shard_operations.cpp | 2 +- .../s/resharding/resharding_coordinator_test.cpp | 2 +- src/mongo/db/s/sharding_cluster_parameters.idl | 112 --------------------- .../db/s/sharding_ddl_coordinator_service.cpp | 2 +- src/mongo/db/s/sharding_ddl_util.cpp | 2 +- .../db/s/shardsvr_reshard_collection_command.cpp | 2 +- src/mongo/db/service_entry_point_common.cpp | 2 +- src/mongo/s/SConscript | 2 +- .../s/catalog/sharding_catalog_client_impl.cpp | 2 +- ...harding_catalog_client_read_preference_test.cpp | 2 +- src/mongo/s/sharding_cluster_parameters.idl | 112 +++++++++++++++++++++ 20 files changed, 171 insertions(+), 145 deletions(-) delete mode 100644 src/mongo/db/s/sharding_cluster_parameters.idl create mode 100644 src/mongo/s/sharding_cluster_parameters.idl diff --git a/jstests/libs/cluster_server_parameter_utils.js b/jstests/libs/cluster_server_parameter_utils.js index 4f84d5f42a6..2a531240530 100644 --- a/jstests/libs/cluster_server_parameter_utils.js +++ b/jstests/libs/cluster_server_parameter_utils.js @@ -5,15 +5,20 @@ * If it's test-only, add its definition to kTestOnlyClusterParameters. * Otherwise, add to kNonTestOnlyClusterParameters. * The keyname will be the name of the cluster-wide server parameter, - * it's value will be an object with at least three keys named: + * its value will be an object with at least two keys named: * * 'default': Properties to expect on an unset CWSP * * 'testValues': List of two other valid values of the CWSP to set for testing purposes - * An additional property 'featureFlag' may also be set if the - * parameter depends on a featureFlag. - * Use the name of the featureFlag if it is required in - * order to consider the parameter. - * Prefix the name with a bang '!' if it is only considered - * when the featureFlag is disabled. + * + * An additional property 'featureFlag' may also be set if the parameter depends on a featureFlag. + * Use the name of the featureFlag if it is required in order to consider the parameter. + * Prefix the name with a bang '!' if it is only considered when the featureFlag is disabled. + * + * Analogously, the 'setParameters', 'serverless' and 'standaloneIncompatible' properties may + * be set to specify that the scenarios under which a parameter can be validated. + * + * CWSPs with the 'isSetInternally' property are set by the cluster itself, and generally not by + * the user. We don't set them nor check their value from generic tests, as we can not assume that + * they will remain at a given value. However, we check that they exist, i.e. that we can get them. */ import {FeatureFlagUtil} from "jstests/libs/feature_flag_util.js"; @@ -47,6 +52,20 @@ export const kNonTestOnlyClusterParameters = { setParameters: {'multitenancySupport': true}, serverless: true, standaloneIncompatible: false, + }, + addOrRemoveShardInProgress: { + default: {inProgress: false}, + testValues: [{inProgress: true}, {inProgress: false}], + isSetInternally: true, + }, + shardedClusterCardinalityForDirectConns: { + default: {hasTwoOrMoreShards: false}, + testValues: [{hasTwoOrMoreShards: true}, {hasTwoOrMoreShards: false}], + isSetInternally: true, + }, + configServerReadPreferenceForCatalogQueries: { + default: {mustAlwaysUseNearest: false}, + testValues: [{mustAlwaysUseNearest: true}, {mustAlwaysUseNearest: false}], } }; @@ -77,6 +96,9 @@ export const kAllClusterParameters = export const kAllClusterParameterNames = Object.keys(kAllClusterParameters); +export const kAllClusterParameterSetInternallyNames = + kAllClusterParameterNames.filter(name => kAllClusterParameters[name].isSetInternally); + export const kAllClusterParameterDefaults = kAllClusterParameterNames.map( (name) => Object.assign({_id: name}, kAllClusterParameters[name].default)); @@ -175,6 +197,12 @@ export function runSetClusterParameter(conn, update, tenantId) { if (!considerParameter(paramName, conn)) { return; } + if (kAllClusterParameterSetInternallyNames.includes(paramName)) { + // Skip setting parameters used internally by the cluster, + // as this may break the cluster in ways generic tests aren't prepared to handle. + return; + } + let updateCopy = Object.assign({}, update); delete updateCopy._id; delete updateCopy.clusterParameterTime; @@ -245,6 +273,12 @@ export function runGetClusterParameterNode(conn, return false; } + if (kAllClusterParameterSetInternallyNames.includes(expectedClusterParameters[i]._id)) { + // Skip validation of parameters used internally by the cluster, + // as their values could change for reasons outside the control of the tests. + continue; + } + if (bsonWoCompare(expectedClusterParameters[i], actual[id]) !== 0) { jsTest.log('Server parameter mismatch on node: ' + conn.host + '\n' + 'Expected: ' + tojson(expectedClusterParameters[i]) + '\n' + diff --git a/jstests/noPassthrough/cluster_server_parameter_refresher.js b/jstests/noPassthrough/cluster_server_parameter_refresher.js index 08f26929eae..cb496c5767a 100644 --- a/jstests/noPassthrough/cluster_server_parameter_refresher.js +++ b/jstests/noPassthrough/cluster_server_parameter_refresher.js @@ -11,6 +11,7 @@ */ import { kAllClusterParameterDefaults, + kAllClusterParameterSetInternallyNames, runGetClusterParameterSharded } from "jstests/libs/cluster_server_parameter_utils.js"; import {TwoPhaseDropCollectionTest} from "jstests/replsets/libs/two_phase_drops.js"; @@ -51,6 +52,9 @@ function runTest(st, startupRefreshIntervalMS) { if (obj.id === kRefreshLogId) { let cpd = obj.attr.clusterParameterDocuments[0].updatedParameters; + // We may observe updates to parameters done by MongoDB itself; exclude them + cpd = cpd.filter( + elem => !kAllClusterParameterSetInternallyNames.includes(elem._id)); cpd.sort(bsonWoCompare); if (bsonWoCompare(cpd, expectedLogged) === 0) { return true; diff --git a/src/mongo/db/SConscript b/src/mongo/db/SConscript index 8d4058d685a..a131b6f9216 100644 --- a/src/mongo/db/SConscript +++ b/src/mongo/db/SConscript @@ -1080,7 +1080,6 @@ env.CppUnitTest( 'commands_test_example', 'repl/replmocks', 's/sharding_catalog_manager', - 's/sharding_cluster_parameters_idl', 'service_context_d_test_fixture', 'shard_role_api', ], diff --git a/src/mongo/db/direct_connection_util.cpp b/src/mongo/db/direct_connection_util.cpp index 8932db114cd..eb4b4eb5ce0 100644 --- a/src/mongo/db/direct_connection_util.cpp +++ b/src/mongo/db/direct_connection_util.cpp @@ -33,9 +33,9 @@ #include "mongo/db/auth/authorization_session.h" #include "mongo/db/curop.h" #include "mongo/db/s/sharding_api_d_params_gen.h" -#include "mongo/db/s/sharding_cluster_parameters_gen.h" #include "mongo/db/s/sharding_statistics.h" #include "mongo/logv2/log.h" +#include "mongo/s/sharding_cluster_parameters_gen.h" #include "mongo/s/sharding_feature_flags_gen.h" #include "mongo/s/sharding_state.h" diff --git a/src/mongo/db/replica_set_endpoint_sharding_state.cpp b/src/mongo/db/replica_set_endpoint_sharding_state.cpp index ecc690b5757..50cd1e583cb 100644 --- a/src/mongo/db/replica_set_endpoint_sharding_state.cpp +++ b/src/mongo/db/replica_set_endpoint_sharding_state.cpp @@ -29,7 +29,7 @@ #include "mongo/db/replica_set_endpoint_sharding_state.h" #include "mongo/db/multitenancy_gen.h" -#include "mongo/db/s/sharding_cluster_parameters_gen.h" +#include "mongo/s/sharding_cluster_parameters_gen.h" #include "mongo/s/sharding_feature_flags_gen.h" #define MONGO_LOGV2_DEFAULT_COMPONENT ::mongo::logv2::LogComponent::kSharding diff --git a/src/mongo/db/replica_set_endpoint_sharding_state_test.cpp b/src/mongo/db/replica_set_endpoint_sharding_state_test.cpp index 99826a8166a..2d301c39c9a 100644 --- a/src/mongo/db/replica_set_endpoint_sharding_state_test.cpp +++ b/src/mongo/db/replica_set_endpoint_sharding_state_test.cpp @@ -31,9 +31,9 @@ #include "mongo/db/auth/authz_manager_external_state_mock.h" #include "mongo/db/replica_set_endpoint_test_fixture.h" -#include "mongo/db/s/sharding_cluster_parameters_gen.h" #include "mongo/db/service_context_d_test_fixture.h" #include "mongo/idl/server_parameter_test_util.h" +#include "mongo/s/sharding_cluster_parameters_gen.h" #include "mongo/unittest/death_test.h" namespace mongo { diff --git a/src/mongo/db/replica_set_endpoint_test_fixture.cpp b/src/mongo/db/replica_set_endpoint_test_fixture.cpp index 69b01a7b696..01d8d0505c1 100644 --- a/src/mongo/db/replica_set_endpoint_test_fixture.cpp +++ b/src/mongo/db/replica_set_endpoint_test_fixture.cpp @@ -29,7 +29,7 @@ #include "mongo/db/replica_set_endpoint_test_fixture.h" -#include "mongo/db/s/sharding_cluster_parameters_gen.h" +#include "mongo/s/sharding_cluster_parameters_gen.h" #define MONGO_LOGV2_DEFAULT_COMPONENT ::mongo::logv2::LogComponent::kTest diff --git a/src/mongo/db/replica_set_endpoint_test_fixture.h b/src/mongo/db/replica_set_endpoint_test_fixture.h index ed8be17b424..551658a25b1 100644 --- a/src/mongo/db/replica_set_endpoint_test_fixture.h +++ b/src/mongo/db/replica_set_endpoint_test_fixture.h @@ -29,7 +29,7 @@ #pragma once -#include "mongo/db/s/sharding_cluster_parameters_gen.h" +#include "mongo/s/sharding_cluster_parameters_gen.h" #include "mongo/unittest/unittest.h" namespace mongo { diff --git a/src/mongo/db/s/SConscript b/src/mongo/db/s/SConscript index 52514dd23bc..d3e795a2bfe 100644 --- a/src/mongo/db/s/SConscript +++ b/src/mongo/db/s/SConscript @@ -402,7 +402,6 @@ env.Library( '$BUILD_DIR/mongo/util/pcre_wrapper', 'forwardable_operation_metadata', 'resharding_server_parameters_idl', - 'sharding_cluster_parameters_idl', 'sharding_logging', 'user_writes_recoverable_critical_section', ], @@ -735,15 +734,6 @@ env.Library( LIBDEPS_PRIVATE=["$BUILD_DIR/mongo/db/server_base"], ) -env.Library( - target="sharding_cluster_parameters_idl", - source=["sharding_cluster_parameters.idl"], - LIBDEPS_PRIVATE=[ - "$BUILD_DIR/mongo/db/server_base", - "$BUILD_DIR/mongo/idl/cluster_server_parameter", - ], -) - env.CppUnitTest( target='shard_server_op_observer_test', source=[ @@ -954,7 +944,6 @@ env.CppUnitTest( '$BUILD_DIR/mongo/idl/cluster_server_parameter_common', '$BUILD_DIR/mongo/util/version_impl', 'config_server_test_fixture', - 'sharding_cluster_parameters_idl', 'sharding_commands_d', ], ) diff --git a/src/mongo/db/s/config/sharding_catalog_manager_shard_operations.cpp b/src/mongo/db/s/config/sharding_catalog_manager_shard_operations.cpp index 9aae7dce6e0..3383cd05fdc 100644 --- a/src/mongo/db/s/config/sharding_catalog_manager_shard_operations.cpp +++ b/src/mongo/db/s/config/sharding_catalog_manager_shard_operations.cpp @@ -102,7 +102,6 @@ #include "mongo/db/s/add_shard_util.h" #include "mongo/db/s/config/sharding_catalog_manager.h" #include "mongo/db/s/range_deletion_task_gen.h" -#include "mongo/db/s/sharding_cluster_parameters_gen.h" #include "mongo/db/s/sharding_config_server_parameters_gen.h" #include "mongo/db/s/sharding_ddl_util.h" #include "mongo/db/s/sharding_logging.h" @@ -145,6 +144,7 @@ #include "mongo/s/request_types/sharded_ddl_commands_gen.h" #include "mongo/s/request_types/shardsvr_join_ddl_coordinators_request_gen.h" #include "mongo/s/request_types/shardsvr_join_migrations_request_gen.h" +#include "mongo/s/sharding_cluster_parameters_gen.h" #include "mongo/s/sharding_feature_flags_gen.h" #include "mongo/s/sharding_state.h" #include "mongo/s/write_ops/batched_command_response.h" diff --git a/src/mongo/db/s/resharding/resharding_coordinator_test.cpp b/src/mongo/db/s/resharding/resharding_coordinator_test.cpp index c40ba728388..d1a2b7ed186 100644 --- a/src/mongo/db/s/resharding/resharding_coordinator_test.cpp +++ b/src/mongo/db/s/resharding/resharding_coordinator_test.cpp @@ -63,7 +63,6 @@ #include "mongo/db/s/resharding/resharding_coordinator_service.h" #include "mongo/db/s/resharding/resharding_metrics.h" #include "mongo/db/s/resharding/resharding_util.h" -#include "mongo/db/s/sharding_cluster_parameters_gen.h" #include "mongo/db/s/transaction_coordinator_service.h" #include "mongo/db/service_context.h" #include "mongo/db/session/logical_session_cache.h" @@ -82,6 +81,7 @@ #include "mongo/s/resharding/common_types_gen.h" #include "mongo/s/resharding/type_collection_fields_gen.h" #include "mongo/s/shard_key_pattern.h" +#include "mongo/s/sharding_cluster_parameters_gen.h" #include "mongo/unittest/assert.h" #include "mongo/unittest/bson_test_util.h" #include "mongo/unittest/framework.h" diff --git a/src/mongo/db/s/sharding_cluster_parameters.idl b/src/mongo/db/s/sharding_cluster_parameters.idl deleted file mode 100644 index b0b24f5578f..00000000000 --- a/src/mongo/db/s/sharding_cluster_parameters.idl +++ /dev/null @@ -1,112 +0,0 @@ -# Copyright (C) 2023-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 -# . -# -# 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. - -imports: - - "mongo/idl/cluster_server_parameter.idl" - -global: - cpp_namespace: mongo - -structs: - ShardedClusterCardinalityParam: - description: >- - Cluster parameter for the number of shards in a sharded cluster. Used to allow or disallow - direct writes to the cluster. - inline_chained_structs: true - chained_structs: - ClusterServerParameter: clusterServerParameter - fields: - hasTwoOrMoreShards: - description: >- - Whether there are or have been two or more shards in the cluster. Shards should disallow - direct writes if set to true. - type: bool - default: false - - AddOrRemoveShardInProgressParam: - description: >- - Reflects whether there is a sharding topology change (e.g. addShard, removeShard) currently - ongoing. - inline_chained_structs: true - chained_structs: - ClusterServerParameter: clusterServerParameter - fields: - inProgress: - description: "True when there's an ongoing sharding topology change. False otherwise." - type: bool - default: false - - ConfigServerReadPreferenceForCatalogQueriesParam: - description: >- - Cluster parameter to always use nearest as the read preference for catalog queries targeting - the config server. - inline_chained_structs: true - chained_structs: - ClusterServerParameter: clusterServerParameter - fields: - mustAlwaysUseNearest: - description: >- - When true, catalog queries targeting the config server will always use nearest as read - preference. Otherwise, the read preference for all those queries is chosen depending on - whether the cluster has a config shard (primaryPreferred) or not (nearest). - type: bool - default: false - -server_parameters: - shardedClusterCardinalityForDirectConns: - description: >- - Cluster parameter for the number of shards in a sharded cluster. Used to allow or - disallow direct writes to the cluster. - set_at: cluster - omit_in_ftdc: false - cpp_vartype: ShardedClusterCardinalityParam - cpp_varname: shardedClusterCardinalityForDirectConns - redact: false - - addOrRemoveShardInProgress: - description: >- - Reflects whether there is a sharding topology change (e.g. addShard, removeShard) currently - ongoing. - set_at: cluster - omit_in_ftdc: false - cpp_vartype: AddOrRemoveShardInProgressParam - cpp_varname: addOrRemoveShardInProgress - redact: false - condition: - min_fcv: 8.0 - - configServerReadPreferenceForCatalogQueries: - description: >- - Cluster parameter to always use nearest as the read preference for catalog queries targeting - the config server. - set_at: cluster - omit_in_ftdc: false - cpp_vartype: ConfigServerReadPreferenceForCatalogQueriesParam - cpp_varname: configServerReadPreferenceForCatalogQueries - redact: false - condition: - min_fcv: 8.0 diff --git a/src/mongo/db/s/sharding_ddl_coordinator_service.cpp b/src/mongo/db/s/sharding_ddl_coordinator_service.cpp index 5750aa99615..276c4c707b6 100644 --- a/src/mongo/db/s/sharding_ddl_coordinator_service.cpp +++ b/src/mongo/db/s/sharding_ddl_coordinator_service.cpp @@ -69,7 +69,6 @@ #include "mongo/db/s/rename_collection_coordinator.h" #include "mongo/db/s/reshard_collection_coordinator.h" #include "mongo/db/s/set_allow_migrations_coordinator.h" -#include "mongo/db/s/sharding_cluster_parameters_gen.h" #include "mongo/db/s/sharding_ddl_coordinator.h" #include "mongo/db/s/untrack_unsplittable_collection_coordinator.h" #include "mongo/logv2/log.h" @@ -77,6 +76,7 @@ #include "mongo/logv2/log_component.h" #include "mongo/logv2/redaction.h" #include "mongo/s/database_version.h" +#include "mongo/s/sharding_cluster_parameters_gen.h" #include "mongo/util/assert_util.h" #include "mongo/util/fail_point.h" #include "mongo/util/future_impl.h" diff --git a/src/mongo/db/s/sharding_ddl_util.cpp b/src/mongo/db/s/sharding_ddl_util.cpp index 8557976fe0f..08081f90f95 100644 --- a/src/mongo/db/s/sharding_ddl_util.cpp +++ b/src/mongo/db/s/sharding_ddl_util.cpp @@ -74,7 +74,6 @@ #include "mongo/db/resource_yielder.h" #include "mongo/db/s/config/initial_split_policy.h" #include "mongo/db/s/remove_tags_gen.h" -#include "mongo/db/s/sharding_cluster_parameters_gen.h" #include "mongo/db/s/sharding_logging.h" #include "mongo/db/server_options.h" #include "mongo/db/service_context.h" @@ -102,6 +101,7 @@ #include "mongo/s/grid.h" #include "mongo/s/request_types/set_allow_migrations_gen.h" #include "mongo/s/shard_key_pattern.h" +#include "mongo/s/sharding_cluster_parameters_gen.h" #include "mongo/s/sharding_feature_flags_gen.h" #include "mongo/s/write_ops/batched_command_request.h" #include "mongo/s/write_ops/batched_command_response.h" diff --git a/src/mongo/db/s/shardsvr_reshard_collection_command.cpp b/src/mongo/db/s/shardsvr_reshard_collection_command.cpp index 86c73918229..e2fe072f808 100644 --- a/src/mongo/db/s/shardsvr_reshard_collection_command.cpp +++ b/src/mongo/db/s/shardsvr_reshard_collection_command.cpp @@ -45,7 +45,6 @@ #include "mongo/db/s/reshard_collection_coordinator.h" #include "mongo/db/s/reshard_collection_coordinator_document_gen.h" #include "mongo/db/s/resharding/resharding_util.h" -#include "mongo/db/s/sharding_cluster_parameters_gen.h" #include "mongo/db/s/sharding_ddl_coordinator_gen.h" #include "mongo/db/s/sharding_ddl_coordinator_service.h" #include "mongo/db/service_context.h" @@ -53,6 +52,7 @@ #include "mongo/s/cluster_ddl.h" #include "mongo/s/request_types/sharded_ddl_commands_gen.h" #include "mongo/s/resharding/resharding_feature_flag_gen.h" +#include "mongo/s/sharding_cluster_parameters_gen.h" #include "mongo/s/sharding_state.h" #include "mongo/util/assert_util.h" #include "mongo/util/future.h" diff --git a/src/mongo/db/service_entry_point_common.cpp b/src/mongo/db/service_entry_point_common.cpp index e272d01a93d..82ab65fb84d 100644 --- a/src/mongo/db/service_entry_point_common.cpp +++ b/src/mongo/db/service_entry_point_common.cpp @@ -111,7 +111,6 @@ #include "mongo/db/repl/tenant_migration_access_blocker_util.h" #include "mongo/db/request_execution_context.h" #include "mongo/db/s/operation_sharding_state.h" -#include "mongo/db/s/sharding_cluster_parameters_gen.h" #include "mongo/db/s/sharding_statistics.h" #include "mongo/db/s/transaction_coordinator_factory.h" #include "mongo/db/server_feature_flags_gen.h" @@ -160,6 +159,7 @@ #include "mongo/s/query_analysis_sampler.h" #include "mongo/s/shard_cannot_refresh_due_to_locks_held_exception.h" #include "mongo/s/shard_version.h" +#include "mongo/s/sharding_cluster_parameters_gen.h" #include "mongo/s/sharding_feature_flags_gen.h" #include "mongo/s/sharding_state.h" #include "mongo/s/stale_exception.h" diff --git a/src/mongo/s/SConscript b/src/mongo/s/SConscript index 27b30d3b552..293041cd614 100644 --- a/src/mongo/s/SConscript +++ b/src/mongo/s/SConscript @@ -290,6 +290,7 @@ env.Library( 'shard_cannot_refresh_due_to_locks_held_exception.cpp', 'shard_key_pattern.cpp', 'shard_version_factory.cpp', + 'sharding_cluster_parameters.idl', 'sharding_feature_flags.cpp', 'sharding_feature_flags.idl', 'stale_exception.cpp', @@ -740,7 +741,6 @@ env.CppUnitTest( '$BUILD_DIR/mongo/db/pipeline/process_interface/mongos_process_interface_factory', '$BUILD_DIR/mongo/db/query/query_test_service_context', '$BUILD_DIR/mongo/db/repl/replmocks', - '$BUILD_DIR/mongo/db/s/sharding_cluster_parameters_idl', '$BUILD_DIR/mongo/db/service_context_non_d', '$BUILD_DIR/mongo/db/timeseries/timeseries_conversion_util', '$BUILD_DIR/mongo/db/timeseries/timeseries_options', diff --git a/src/mongo/s/catalog/sharding_catalog_client_impl.cpp b/src/mongo/s/catalog/sharding_catalog_client_impl.cpp index 41e286fbacb..eec262752e9 100644 --- a/src/mongo/s/catalog/sharding_catalog_client_impl.cpp +++ b/src/mongo/s/catalog/sharding_catalog_client_impl.cpp @@ -73,7 +73,6 @@ #include "mongo/db/pipeline/pipeline.h" #include "mongo/db/repl/optime.h" #include "mongo/db/repl/read_concern_args.h" -#include "mongo/db/s/sharding_cluster_parameters_gen.h" #include "mongo/db/server_options.h" #include "mongo/db/vector_clock.h" #include "mongo/idl/idl_parser.h" @@ -93,6 +92,7 @@ #include "mongo/s/client/shard_registry.h" #include "mongo/s/database_version.h" #include "mongo/s/grid.h" +#include "mongo/s/sharding_cluster_parameters_gen.h" #include "mongo/s/write_ops/batched_command_request.h" #include "mongo/s/write_ops/batched_command_response.h" #include "mongo/util/assert_util.h" diff --git a/src/mongo/s/catalog/sharding_catalog_client_read_preference_test.cpp b/src/mongo/s/catalog/sharding_catalog_client_read_preference_test.cpp index e87f308e208..ed87c51b65b 100644 --- a/src/mongo/s/catalog/sharding_catalog_client_read_preference_test.cpp +++ b/src/mongo/s/catalog/sharding_catalog_client_read_preference_test.cpp @@ -35,7 +35,6 @@ #include "mongo/db/commands.h" #include "mongo/db/query/find_command.h" #include "mongo/db/query/query_request_helper.h" -#include "mongo/db/s/sharding_cluster_parameters_gen.h" #include "mongo/executor/network_test_env.h" #include "mongo/executor/remote_command_request.h" #include "mongo/idl/cluster_server_parameter_gen.h" @@ -43,6 +42,7 @@ #include "mongo/rpc/metadata/repl_set_metadata.h" #include "mongo/rpc/op_msg.h" #include "mongo/s/catalog/sharding_catalog_client.h" +#include "mongo/s/sharding_cluster_parameters_gen.h" #include "mongo/s/sharding_mongos_test_fixture.h" #include "mongo/unittest/assert.h" #include "mongo/unittest/bson_test_util.h" diff --git a/src/mongo/s/sharding_cluster_parameters.idl b/src/mongo/s/sharding_cluster_parameters.idl new file mode 100644 index 00000000000..b0b24f5578f --- /dev/null +++ b/src/mongo/s/sharding_cluster_parameters.idl @@ -0,0 +1,112 @@ +# Copyright (C) 2023-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 +# . +# +# 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. + +imports: + - "mongo/idl/cluster_server_parameter.idl" + +global: + cpp_namespace: mongo + +structs: + ShardedClusterCardinalityParam: + description: >- + Cluster parameter for the number of shards in a sharded cluster. Used to allow or disallow + direct writes to the cluster. + inline_chained_structs: true + chained_structs: + ClusterServerParameter: clusterServerParameter + fields: + hasTwoOrMoreShards: + description: >- + Whether there are or have been two or more shards in the cluster. Shards should disallow + direct writes if set to true. + type: bool + default: false + + AddOrRemoveShardInProgressParam: + description: >- + Reflects whether there is a sharding topology change (e.g. addShard, removeShard) currently + ongoing. + inline_chained_structs: true + chained_structs: + ClusterServerParameter: clusterServerParameter + fields: + inProgress: + description: "True when there's an ongoing sharding topology change. False otherwise." + type: bool + default: false + + ConfigServerReadPreferenceForCatalogQueriesParam: + description: >- + Cluster parameter to always use nearest as the read preference for catalog queries targeting + the config server. + inline_chained_structs: true + chained_structs: + ClusterServerParameter: clusterServerParameter + fields: + mustAlwaysUseNearest: + description: >- + When true, catalog queries targeting the config server will always use nearest as read + preference. Otherwise, the read preference for all those queries is chosen depending on + whether the cluster has a config shard (primaryPreferred) or not (nearest). + type: bool + default: false + +server_parameters: + shardedClusterCardinalityForDirectConns: + description: >- + Cluster parameter for the number of shards in a sharded cluster. Used to allow or + disallow direct writes to the cluster. + set_at: cluster + omit_in_ftdc: false + cpp_vartype: ShardedClusterCardinalityParam + cpp_varname: shardedClusterCardinalityForDirectConns + redact: false + + addOrRemoveShardInProgress: + description: >- + Reflects whether there is a sharding topology change (e.g. addShard, removeShard) currently + ongoing. + set_at: cluster + omit_in_ftdc: false + cpp_vartype: AddOrRemoveShardInProgressParam + cpp_varname: addOrRemoveShardInProgress + redact: false + condition: + min_fcv: 8.0 + + configServerReadPreferenceForCatalogQueries: + description: >- + Cluster parameter to always use nearest as the read preference for catalog queries targeting + the config server. + set_at: cluster + omit_in_ftdc: false + cpp_vartype: ConfigServerReadPreferenceForCatalogQueriesParam + cpp_varname: configServerReadPreferenceForCatalogQueries + redact: false + condition: + min_fcv: 8.0 -- cgit v1.2.3