diff options
author | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2021-04-13 08:36:38 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-04-13 19:38:30 +0000 |
commit | 56dd69e03b5495d0882ce5d0a049e55880b7cb95 (patch) | |
tree | 579630c380ab34e1d6a949ee302b552513b409df | |
parent | 6f4cec03cca5475b66dbbc26d1b9a6ad695331b8 (diff) | |
download | mongo-56dd69e03b5495d0882ce5d0a049e55880b7cb95.tar.gz |
SERVER-56063 Consolidate the FCV 4.4 <-> 5.0 upgrade checks
This change is just a cleanup in preparation for adding the FCV
serialisation for database and collection/chunk entries.
27 files changed, 119 insertions, 82 deletions
diff --git a/src/mongo/db/commands/set_feature_compatibility_version_command.cpp b/src/mongo/db/commands/set_feature_compatibility_version_command.cpp index 11c33ebab4f..6acd3b0eb1d 100644 --- a/src/mongo/db/commands/set_feature_compatibility_version_command.cpp +++ b/src/mongo/db/commands/set_feature_compatibility_version_command.cpp @@ -58,7 +58,6 @@ #include "mongo/db/views/view_catalog.h" #include "mongo/logv2/log.h" #include "mongo/rpc/get_status_from_command_result.h" -#include "mongo/s/sharded_collections_ddl_parameters_gen.h" #include "mongo/stdx/unordered_set.h" #include "mongo/util/exit.h" #include "mongo/util/fail_point.h" @@ -334,11 +333,6 @@ private: if (serverGlobalParams.clusterRole == ClusterRole::ConfigServer) { // TODO SERVER-53283: This block can removed once 5.0 becomes last-lts. - if (requestedVersion >= FeatureCompatibility::Version::kVersion49) { - ShardingCatalogManager::get(opCtx)->upgradeMetadataFor49(opCtx); - } - - // TODO SERVER-53283: This block can removed once 5.0 becomes last-lts. // TODO SERVER-53774: Replace kLatest by the version defined in the feature flag IDL if (requestedVersion >= FeatureCompatibility::kLatest) { ShardingCatalogManager::get(opCtx)->upgradeMetadataFor50(opCtx); diff --git a/src/mongo/db/s/SConscript b/src/mongo/db/s/SConscript index 7e8fe61b88c..0dfe8d132e3 100644 --- a/src/mongo/db/s/SConscript +++ b/src/mongo/db/s/SConscript @@ -248,13 +248,12 @@ env.Library( 'add_shard_util.cpp', 'balancer/balancer_chunk_selection_policy_impl.cpp', 'balancer/balancer_chunk_selection_policy.cpp', - 'balancer/balancer.cpp', 'balancer/balancer_policy.cpp', + 'balancer/balancer.cpp', 'balancer/cluster_statistics_impl.cpp', 'balancer/cluster_statistics.cpp', 'balancer/migration_manager.cpp', 'balancer/scoped_migration_request.cpp', - 'sharding_config_server_parameters.idl', 'balancer/type_migration.cpp', 'config/initial_split_policy.cpp', 'config/sharding_catalog_manager_chunk_operations.cpp', @@ -269,13 +268,14 @@ env.Library( 'dist_lock_manager.cpp', 'drop_collection_legacy.cpp', 'drop_database_legacy.cpp', + 'sharding_config_server_parameters.idl', + 'sharding_ddl_50_upgrade_downgrade.cpp', + 'sharding_util.cpp', 'type_lockpings.cpp', 'type_locks.cpp', - 'sharding_util.cpp', ], LIBDEPS=[ '$BUILD_DIR/mongo/db/catalog_raii', - '$BUILD_DIR/mongo/db/pipeline/process_interface/shardsvr_process_interface', '$BUILD_DIR/mongo/db/repl/read_concern_args', '$BUILD_DIR/mongo/db/rw_concern_d', '$BUILD_DIR/mongo/db/transaction', @@ -295,6 +295,7 @@ env.Library( '$BUILD_DIR/mongo/db/commands/set_feature_compatibility_version_idl', '$BUILD_DIR/mongo/db/common', '$BUILD_DIR/mongo/db/dbdirectclient', + '$BUILD_DIR/mongo/db/pipeline/process_interface/shardsvr_process_interface', '$BUILD_DIR/mongo/db/pipeline/sharded_agg_helpers', '$BUILD_DIR/mongo/db/repl/repl_coordinator_interface', '$BUILD_DIR/mongo/db/repl/replica_set_aware_service', diff --git a/src/mongo/db/s/config/configsvr_reshard_collection_cmd.cpp b/src/mongo/db/s/config/configsvr_reshard_collection_cmd.cpp index 2a7063b18eb..5cee7b9b6c0 100644 --- a/src/mongo/db/s/config/configsvr_reshard_collection_cmd.cpp +++ b/src/mongo/db/s/config/configsvr_reshard_collection_cmd.cpp @@ -45,7 +45,6 @@ #include "mongo/s/grid.h" #include "mongo/s/request_types/reshard_collection_gen.h" #include "mongo/s/resharding/resharding_feature_flag_gen.h" -#include "mongo/s/sharded_collections_ddl_parameters_gen.h" namespace mongo { namespace { diff --git a/src/mongo/db/s/config/initial_split_policy.cpp b/src/mongo/db/s/config/initial_split_policy.cpp index 4cded527e8a..b6b79643173 100644 --- a/src/mongo/db/s/config/initial_split_policy.cpp +++ b/src/mongo/db/s/config/initial_split_policy.cpp @@ -46,7 +46,6 @@ #include "mongo/s/catalog/type_shard.h" #include "mongo/s/grid.h" #include "mongo/s/shard_util.h" -#include "mongo/s/sharded_collections_ddl_parameters_gen.h" #include "mongo/stdx/unordered_map.h" namespace mongo { diff --git a/src/mongo/db/s/config/sharding_catalog_manager.cpp b/src/mongo/db/s/config/sharding_catalog_manager.cpp index 5b49ca6a5be..91147879587 100644 --- a/src/mongo/db/s/config/sharding_catalog_manager.cpp +++ b/src/mongo/db/s/config/sharding_catalog_manager.cpp @@ -43,6 +43,7 @@ #include "mongo/db/query/query_request_helper.h" #include "mongo/db/repl/repl_client_info.h" #include "mongo/db/s/balancer/type_migration.h" +#include "mongo/db/s/sharding_ddl_50_upgrade_downgrade.h" #include "mongo/db/s/sharding_util.h" #include "mongo/db/s/type_lockpings.h" #include "mongo/db/s/type_locks.h" @@ -58,7 +59,6 @@ #include "mongo/s/client/shard_registry.h" #include "mongo/s/database_version.h" #include "mongo/s/grid.h" -#include "mongo/s/sharded_collections_ddl_parameters_gen.h" #include "mongo/s/write_ops/batched_command_request.h" #include "mongo/s/write_ops/batched_command_response.h" #include "mongo/stdx/unordered_map.h" @@ -533,7 +533,7 @@ Status ShardingCatalogManager::setFeatureCompatibilityVersionOnShards(OperationC return Status::OK(); } -void ShardingCatalogManager::_removePre49LegacyMetadata(OperationContext* opCtx) { +void ShardingCatalogManager::_removePre50LegacyMetadata(OperationContext* opCtx) { const auto catalogClient = Grid::get(opCtx)->catalogClient(); // Delete all documents which have {dropped: true} from config.collections uassertStatusOK( @@ -555,26 +555,20 @@ void ShardingCatalogManager::_removePre49LegacyMetadata(OperationContext* opCtx) true /* multi */); } -void ShardingCatalogManager::upgradeMetadataFor49(OperationContext* opCtx) { - LOGV2(5276704, "Starting metadata upgrade to 4.9"); +void ShardingCatalogManager::upgradeMetadataFor50(OperationContext* opCtx) { + LOGV2(5581200, "Starting metadata upgrade to 5.0"); try { - _removePre49LegacyMetadata(opCtx); + _removePre50LegacyMetadata(opCtx); } catch (const DBException& e) { LOGV2(5276708, "Failed to upgrade sharding metadata: {error}", "error"_attr = e.toString()); throw; } - LOGV2(5276705, "Successfully upgraded metadata to 4.9"); -} - -void ShardingCatalogManager::upgradeMetadataFor50(OperationContext* opCtx) { - LOGV2(5581200, "Starting metadata upgrade to 5.0"); - if (feature_flags::gShardingFullDDLSupportTimestampedVersion.isEnabledAndIgnoreFCV()) { try { - _createDBTimestampsFor50(opCtx); - _upgradeCollectionsAndChunksMetadataFor50(opCtx); + _upgradeDatabasesEntriesTo50(opCtx); + _upgradeCollectionsAndChunksEntriesTo50(opCtx); } catch (const DBException& e) { LOGV2(5581201, "Failed to upgrade sharding metadata: {error}", @@ -591,8 +585,8 @@ void ShardingCatalogManager::downgradeMetadataToPre50(OperationContext* opCtx) { if (feature_flags::gShardingFullDDLSupportTimestampedVersion.isEnabledAndIgnoreFCV()) { try { - _downgradeConfigDatabasesEntriesToPre50(opCtx); - _downgradeCollectionsAndChunksMetadataToPre50(opCtx); + _downgradeCollectionsAndChunksEntriesToPre50(opCtx); + _downgradeDatabasesEntriesToPre50(opCtx); } catch (const DBException& e) { LOGV2(5581204, "Failed to downgrade sharding metadata: {error}", @@ -604,7 +598,7 @@ void ShardingCatalogManager::downgradeMetadataToPre50(OperationContext* opCtx) { LOGV2(5581205, "Successfully downgraded metadata to pre 5.0"); } -void ShardingCatalogManager::_createDBTimestampsFor50(OperationContext* opCtx) { +void ShardingCatalogManager::_upgradeDatabasesEntriesTo50(OperationContext* opCtx) { LOGV2(5258802, "Starting upgrade of config.databases"); auto const catalogCache = Grid::get(opCtx)->catalogCache(); @@ -659,7 +653,7 @@ void ShardingCatalogManager::_createDBTimestampsFor50(OperationContext* opCtx) { LOGV2(5258803, "Successfully upgraded config.databases"); } -void ShardingCatalogManager::_downgradeConfigDatabasesEntriesToPre50(OperationContext* opCtx) { +void ShardingCatalogManager::_downgradeDatabasesEntriesToPre50(OperationContext* opCtx) { LOGV2(5258806, "Starting downgrade of config.databases"); updateConfigDocumentDBDirect( @@ -706,7 +700,7 @@ void ShardingCatalogManager::_downgradeConfigDatabasesEntriesToPre50(OperationCo LOGV2(5258807, "Successfully downgraded config.databases"); } -void ShardingCatalogManager::_upgradeCollectionsAndChunksMetadataFor50(OperationContext* opCtx) { +void ShardingCatalogManager::_upgradeCollectionsAndChunksEntriesTo50(OperationContext* opCtx) { LOGV2(5276700, "Starting upgrade of config.collections and config.chunks"); auto const catalogCache = Grid::get(opCtx)->catalogCache(); @@ -833,8 +827,7 @@ void ShardingCatalogManager::_upgradeCollectionsAndChunksMetadataFor50(Operation LOGV2(5276701, "Successfully upgraded config.collections and config.chunks"); } -void ShardingCatalogManager::_downgradeCollectionsAndChunksMetadataToPre50( - OperationContext* opCtx) { +void ShardingCatalogManager::_downgradeCollectionsAndChunksEntriesToPre50(OperationContext* opCtx) { LOGV2(5276702, "Starting downgrade of config.collections and config.chunks"); auto const catalogCache = Grid::get(opCtx)->catalogCache(); diff --git a/src/mongo/db/s/config/sharding_catalog_manager.h b/src/mongo/db/s/config/sharding_catalog_manager.h index f8d444c9b8a..45abb93aa44 100644 --- a/src/mongo/db/s/config/sharding_catalog_manager.h +++ b/src/mongo/db/s/config/sharding_catalog_manager.h @@ -404,14 +404,6 @@ public: Status setFeatureCompatibilityVersionOnShards(OperationContext* opCtx, const BSONObj& cmdObj); /** - * Patches-up persistent metadata for 4.9. - * - * It shall be called when upgrading to 4.9 or newer versions. - * TODO SERVER-53283: Remove once 5.0 has been released. - */ - void upgradeMetadataFor49(OperationContext* opCtx); - - /** * Patches-up persistent metadata for 5.0. * * It shall be called when upgrading to 5.0 or newer versions. @@ -546,15 +538,15 @@ private: /** * Removes all entries from the config server's config.collections where 'dropped' is true. * - * Before 4.9, when a collection was dropped, its entry in config.collections remained, tagged + * Before 5.0, when a collection was dropped, its entry in config.collections remained, tagged * as 'dropped: true'. As those are no longer needed, this method cleans up the leftover * metadata. * - * It shall be called when upgrading to 4.9 or newer versions. + * It shall be called when upgrading to 5.0 or newer versions. * * TODO SERVER-53283: Remove once 5.0 has becomes last-lts. */ - void _removePre49LegacyMetadata(OperationContext* opCtx); + void _removePre50LegacyMetadata(OperationContext* opCtx); /** * Creates a 'version.timestamp' for each one of the entries in the config server's @@ -562,7 +554,7 @@ private: * * TODO SERVER-53283: Remove once 5.0 becomes last-lts. */ - void _createDBTimestampsFor50(OperationContext* opCtx); + void _upgradeDatabasesEntriesTo50(OperationContext* opCtx); /** * Downgrades the config.databases entries to prior 4.9 version. More specifically, it removes @@ -570,7 +562,7 @@ private: * * TODO SERVER-53283: Remove once 5.0 becomes last-lts. */ - void _downgradeConfigDatabasesEntriesToPre50(OperationContext* opCtx); + void _downgradeDatabasesEntriesToPre50(OperationContext* opCtx); /** * For each one of the entries in config.collections where there is no 'timestamp', @@ -581,7 +573,7 @@ private: * * TODO SERVER-53283: Remove once 5.0 becomes last-lts. */ - void _upgradeCollectionsAndChunksMetadataFor50(OperationContext* opCtx); + void _upgradeCollectionsAndChunksEntriesTo50(OperationContext* opCtx); /** * For each one of the entries in config.collections where there is a 'timestamp', @@ -592,7 +584,7 @@ private: * * TODO SERVER-53283: Remove once 5.0 becomes last-lts. */ - void _downgradeCollectionsAndChunksMetadataToPre50(OperationContext* opCtx); + void _downgradeCollectionsAndChunksEntriesToPre50(OperationContext* opCtx); // The owning service context ServiceContext* const _serviceContext; diff --git a/src/mongo/db/s/config/sharding_catalog_manager_chunk_operations.cpp b/src/mongo/db/s/config/sharding_catalog_manager_chunk_operations.cpp index bdd3582bce1..223573752ec 100644 --- a/src/mongo/db/s/config/sharding_catalog_manager_chunk_operations.cpp +++ b/src/mongo/db/s/config/sharding_catalog_manager_chunk_operations.cpp @@ -60,7 +60,6 @@ #include "mongo/s/grid.h" #include "mongo/s/shard_key_pattern.h" #include "mongo/s/shard_util.h" -#include "mongo/s/sharded_collections_ddl_parameters_gen.h" #include "mongo/s/write_ops/batched_command_request.h" #include "mongo/util/fail_point.h" #include "mongo/util/str.h" diff --git a/src/mongo/db/s/config/sharding_catalog_manager_collection_operations.cpp b/src/mongo/db/s/config/sharding_catalog_manager_collection_operations.cpp index 4b4503a3c40..356d7eb2c83 100644 --- a/src/mongo/db/s/config/sharding_catalog_manager_collection_operations.cpp +++ b/src/mongo/db/s/config/sharding_catalog_manager_collection_operations.cpp @@ -70,7 +70,6 @@ #include "mongo/s/request_types/flush_routing_table_cache_updates_gen.h" #include "mongo/s/shard_key_pattern.h" #include "mongo/s/shard_util.h" -#include "mongo/s/sharded_collections_ddl_parameters_gen.h" #include "mongo/s/write_ops/batched_command_request.h" #include "mongo/s/write_ops/batched_command_response.h" #include "mongo/transport/service_entry_point.h" @@ -79,16 +78,11 @@ #include "mongo/util/str.h" namespace mongo { - -using CollectionUUID = UUID; -using std::set; -using std::string; -using std::vector; +namespace { MONGO_FAIL_POINT_DEFINE(hangRefineCollectionShardKeyBeforeUpdatingChunks); MONGO_FAIL_POINT_DEFINE(hangRefineCollectionShardKeyBeforeCommit); -namespace { const ReadPreferenceSetting kConfigReadSelector(ReadPreference::Nearest, TagSet{}); const WriteConcernOptions kNoWaitWriteConcern(1, WriteConcernOptions::SyncMode::UNSET, Seconds(0)); const char kWriteConcernField[] = "writeConcern"; diff --git a/src/mongo/db/s/config/sharding_catalog_manager_config_initialization_test.cpp b/src/mongo/db/s/config/sharding_catalog_manager_config_initialization_test.cpp index 269ba43b11f..c29d6bcdde0 100644 --- a/src/mongo/db/s/config/sharding_catalog_manager_config_initialization_test.cpp +++ b/src/mongo/db/s/config/sharding_catalog_manager_config_initialization_test.cpp @@ -41,6 +41,7 @@ #include "mongo/db/repl/replication_coordinator_mock.h" #include "mongo/db/s/config/config_server_test_fixture.h" #include "mongo/db/s/config/sharding_catalog_manager.h" +#include "mongo/db/s/sharding_ddl_50_upgrade_downgrade.h" #include "mongo/db/s/type_lockpings.h" #include "mongo/db/s/type_locks.h" #include "mongo/s/catalog/config_server_version.h" @@ -50,7 +51,6 @@ #include "mongo/s/catalog/type_shard.h" #include "mongo/s/catalog/type_tags.h" #include "mongo/s/client/shard.h" -#include "mongo/s/sharded_collections_ddl_parameters_gen.h" #include "mongo/util/scopeguard.h" namespace mongo { diff --git a/src/mongo/db/s/config/sharding_catalog_manager_database_operations.cpp b/src/mongo/db/s/config/sharding_catalog_manager_database_operations.cpp index 1ca8f52d4a1..048c093f648 100644 --- a/src/mongo/db/s/config/sharding_catalog_manager_database_operations.cpp +++ b/src/mongo/db/s/config/sharding_catalog_manager_database_operations.cpp @@ -40,6 +40,7 @@ #include "mongo/db/ops/write_ops.h" #include "mongo/db/repl/repl_client_info.h" #include "mongo/db/s/dist_lock_manager.h" +#include "mongo/db/s/sharding_ddl_50_upgrade_downgrade.h" #include "mongo/db/server_options.h" #include "mongo/db/vector_clock.h" #include "mongo/db/write_concern.h" @@ -49,7 +50,6 @@ #include "mongo/s/client/shard.h" #include "mongo/s/grid.h" #include "mongo/s/shard_util.h" -#include "mongo/s/sharded_collections_ddl_parameters_gen.h" namespace mongo { namespace { 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 f1c51ef9cf1..90be09ba273 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 @@ -56,6 +56,7 @@ #include "mongo/db/repl/repl_set_config.h" #include "mongo/db/s/add_shard_cmd_gen.h" #include "mongo/db/s/add_shard_util.h" +#include "mongo/db/s/sharding_ddl_50_upgrade_downgrade.h" #include "mongo/db/s/sharding_logging.h" #include "mongo/db/s/type_shard_identity.h" #include "mongo/db/vector_clock_mutable.h" @@ -72,7 +73,6 @@ #include "mongo/s/cluster_identity_loader.h" #include "mongo/s/database_version.h" #include "mongo/s/grid.h" -#include "mongo/s/sharded_collections_ddl_parameters_gen.h" #include "mongo/s/write_ops/batched_command_request.h" #include "mongo/s/write_ops/batched_command_response.h" #include "mongo/util/fail_point.h" diff --git a/src/mongo/db/s/create_collection_coordinator.cpp b/src/mongo/db/s/create_collection_coordinator.cpp index ea95b3678d9..64c3f48c40c 100644 --- a/src/mongo/db/s/create_collection_coordinator.cpp +++ b/src/mongo/db/s/create_collection_coordinator.cpp @@ -49,7 +49,6 @@ #include "mongo/s/cluster_write.h" #include "mongo/s/grid.h" #include "mongo/s/request_types/shard_collection_gen.h" -#include "mongo/s/sharded_collections_ddl_parameters_gen.h" namespace mongo { namespace { diff --git a/src/mongo/db/s/rename_collection_coordinator.cpp b/src/mongo/db/s/rename_collection_coordinator.cpp index 896867860e6..c4d88097a63 100644 --- a/src/mongo/db/s/rename_collection_coordinator.cpp +++ b/src/mongo/db/s/rename_collection_coordinator.cpp @@ -49,10 +49,8 @@ #include "mongo/s/client/shard_registry.h" #include "mongo/s/grid.h" #include "mongo/s/request_types/sharded_ddl_commands_gen.h" -#include "mongo/s/sharded_collections_ddl_parameters_gen.h" namespace mongo { - namespace { boost::optional<CollectionType> getShardedCollection(OperationContext* opCtx, @@ -66,6 +64,7 @@ boost::optional<CollectionType> getShardedCollection(OperationContext* opCtx, } } // namespace + RenameCollectionCoordinator::RenameCollectionCoordinator(const BSONObj& initialState) : ShardingDDLCoordinator(initialState), _doc(RenameCollectionCoordinatorDocument::parse( diff --git a/src/mongo/db/s/resharding/resharding_coordinator_service.cpp b/src/mongo/db/s/resharding/resharding_coordinator_service.cpp index e3f9562fed0..2e16e375d66 100644 --- a/src/mongo/db/s/resharding/resharding_coordinator_service.cpp +++ b/src/mongo/db/s/resharding/resharding_coordinator_service.cpp @@ -41,6 +41,7 @@ #include "mongo/db/s/resharding/resharding_metrics.h" #include "mongo/db/s/resharding/resharding_server_parameters_gen.h" #include "mongo/db/s/resharding_util.h" +#include "mongo/db/s/sharding_ddl_50_upgrade_downgrade.h" #include "mongo/db/s/sharding_logging.h" #include "mongo/db/s/sharding_util.h" #include "mongo/db/storage/duplicate_key_error_info.h" @@ -51,7 +52,6 @@ #include "mongo/s/grid.h" #include "mongo/s/request_types/flush_resharding_state_change_gen.h" #include "mongo/s/shard_id.h" -#include "mongo/s/sharded_collections_ddl_parameters_gen.h" #include "mongo/s/write_ops/batched_command_response.h" #include "mongo/util/fail_point.h" #include "mongo/util/future_util.h" diff --git a/src/mongo/db/s/shard_collection_legacy.cpp b/src/mongo/db/s/shard_collection_legacy.cpp index 42e36c0f8e2..9724f7ed485 100644 --- a/src/mongo/db/s/shard_collection_legacy.cpp +++ b/src/mongo/db/s/shard_collection_legacy.cpp @@ -53,6 +53,7 @@ #include "mongo/db/s/shard_collection_legacy.h" #include "mongo/db/s/shard_filtering_metadata_refresh.h" #include "mongo/db/s/shard_key_util.h" +#include "mongo/db/s/sharding_ddl_50_upgrade_downgrade.h" #include "mongo/db/s/sharding_ddl_util.h" #include "mongo/db/s/sharding_logging.h" #include "mongo/db/s/sharding_state.h" @@ -68,7 +69,6 @@ #include "mongo/s/request_types/clone_collection_options_from_primary_shard_gen.h" #include "mongo/s/request_types/shard_collection_gen.h" #include "mongo/s/shard_util.h" -#include "mongo/s/sharded_collections_ddl_parameters_gen.h" #include "mongo/util/fail_point.h" #include "mongo/util/scopeguard.h" #include "mongo/util/str.h" diff --git a/src/mongo/db/s/shard_metadata_util.cpp b/src/mongo/db/s/shard_metadata_util.cpp index a0fb83169ef..ab34c117639 100644 --- a/src/mongo/db/s/shard_metadata_util.cpp +++ b/src/mongo/db/s/shard_metadata_util.cpp @@ -46,12 +46,10 @@ #include "mongo/s/catalog/type_chunk.h" #include "mongo/s/catalog/type_collection.h" #include "mongo/s/chunk_version.h" -#include "mongo/s/sharded_collections_ddl_parameters_gen.h" #include "mongo/s/write_ops/batched_command_response.h" namespace mongo { namespace shardmetadatautil { - namespace { const WriteConcernOptions kLocalWriteConcern(1, diff --git a/src/mongo/db/s/sharding_ddl_50_upgrade_downgrade.cpp b/src/mongo/db/s/sharding_ddl_50_upgrade_downgrade.cpp new file mode 100644 index 00000000000..6c691187976 --- /dev/null +++ b/src/mongo/db/s/sharding_ddl_50_upgrade_downgrade.cpp @@ -0,0 +1,34 @@ +/** + * Copyright (C) 2021-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/platform/basic.h" + +#include "mongo/db/s/sharding_ddl_50_upgrade_downgrade.h" + +namespace mongo {} // namespace mongo diff --git a/src/mongo/db/s/sharding_ddl_50_upgrade_downgrade.h b/src/mongo/db/s/sharding_ddl_50_upgrade_downgrade.h new file mode 100644 index 00000000000..8f94a935f6f --- /dev/null +++ b/src/mongo/db/s/sharding_ddl_50_upgrade_downgrade.h @@ -0,0 +1,39 @@ +/** + * Copyright (C) 2021-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/s/sharding_ddl_50_upgrade_downgrade_gen.h" + +namespace mongo { + +// TODO SERVER-56063: Add the DatabaseEntryFormat selector +// TODO SERVER-56065: Add the CollectionEntryFormat selector + +} // namespace mongo diff --git a/src/mongo/db/s/shardsvr_create_collection_command.cpp b/src/mongo/db/s/shardsvr_create_collection_command.cpp index 641d3e52079..965a4c8b383 100644 --- a/src/mongo/db/s/shardsvr_create_collection_command.cpp +++ b/src/mongo/db/s/shardsvr_create_collection_command.cpp @@ -40,6 +40,7 @@ #include "mongo/db/query/collation/collator_factory_interface.h" #include "mongo/db/s/create_collection_coordinator.h" #include "mongo/db/s/shard_collection_legacy.h" +#include "mongo/db/s/sharding_ddl_50_upgrade_downgrade.h" #include "mongo/db/s/sharding_ddl_coordinator_service.h" #include "mongo/db/s/sharding_state.h" #include "mongo/db/timeseries/timeseries_lookup.h" @@ -47,16 +48,13 @@ #include "mongo/s/grid.h" #include "mongo/s/request_types/shard_collection_gen.h" #include "mongo/s/request_types/sharded_ddl_commands_gen.h" -#include "mongo/s/sharded_collections_ddl_parameters_gen.h" namespace mongo { namespace { -void inferCollationFromLocalCollection( - OperationContext* opCtx, - const NamespaceString& nss, - const ShardsvrCreateCollection& request, - ShardsvrShardCollectionRequest* shardsvrShardCollectionRequest) { +BSONObj inferCollationFromLocalCollection(OperationContext* opCtx, + const NamespaceString& nss, + const ShardsvrCreateCollection& request) { auto& collation = request.getCollation().value(); auto collator = uassertStatusOK( CollatorFactoryInterface::get(opCtx->getServiceContext())->makeFromBSON(collation)); @@ -82,7 +80,7 @@ void inferCollationFromLocalCollection( auto status = bsonExtractTypedField(collectionOptions, "collation", BSONType::Object, &collationElement); if (status.isOK()) { - defaultCollation = collationElement.Obj().getOwned(); + defaultCollation = collationElement.Obj(); uassert(ErrorCodes::BadValue, "Default collation in collection metadata cannot be empty.", !defaultCollation.isEmpty()); @@ -90,7 +88,7 @@ void inferCollationFromLocalCollection( uassertStatusOK(status); } - shardsvrShardCollectionRequest->setCollation(defaultCollation.getOwned()); + return defaultCollation.getOwned(); } // TODO (SERVER-54879): Remove this path after 5.0 branches @@ -165,7 +163,8 @@ CreateCollectionResponse createCollectionLegacy(OperationContext* opCtx, request.getInitialSplitPoints().value()); if (request.getCollation()) { - inferCollationFromLocalCollection(opCtx, nss, request, &shardsvrShardCollectionRequest); + shardsvrShardCollectionRequest.setCollation( + inferCollationFromLocalCollection(opCtx, nss, request)); } return shardCollectionLegacy( diff --git a/src/mongo/db/s/shardsvr_drop_collection_command.cpp b/src/mongo/db/s/shardsvr_drop_collection_command.cpp index 05a457d3b50..db62684ef5e 100644 --- a/src/mongo/db/s/shardsvr_drop_collection_command.cpp +++ b/src/mongo/db/s/shardsvr_drop_collection_command.cpp @@ -36,12 +36,12 @@ #include "mongo/db/curop.h" #include "mongo/db/s/drop_collection_coordinator.h" #include "mongo/db/s/drop_collection_legacy.h" +#include "mongo/db/s/sharding_ddl_50_upgrade_downgrade.h" #include "mongo/db/s/sharding_ddl_coordinator_service.h" #include "mongo/db/s/sharding_state.h" #include "mongo/logv2/log.h" #include "mongo/s/grid.h" #include "mongo/s/request_types/sharded_ddl_commands_gen.h" -#include "mongo/s/sharded_collections_ddl_parameters_gen.h" namespace mongo { namespace { diff --git a/src/mongo/db/s/shardsvr_drop_database_command.cpp b/src/mongo/db/s/shardsvr_drop_database_command.cpp index 67b9ca40d56..eb19887273e 100644 --- a/src/mongo/db/s/shardsvr_drop_database_command.cpp +++ b/src/mongo/db/s/shardsvr_drop_database_command.cpp @@ -37,12 +37,12 @@ #include "mongo/db/curop.h" #include "mongo/db/s/drop_database_coordinator.h" #include "mongo/db/s/drop_database_legacy.h" +#include "mongo/db/s/sharding_ddl_50_upgrade_downgrade.h" #include "mongo/db/s/sharding_ddl_coordinator_service.h" #include "mongo/db/s/sharding_state.h" #include "mongo/logv2/log.h" #include "mongo/s/grid.h" #include "mongo/s/request_types/sharded_ddl_commands_gen.h" -#include "mongo/s/sharded_collections_ddl_parameters_gen.h" namespace mongo { namespace { diff --git a/src/mongo/db/s/shardsvr_move_primary_command.cpp b/src/mongo/db/s/shardsvr_move_primary_command.cpp index 6d736afd830..9fcba92c055 100644 --- a/src/mongo/db/s/shardsvr_move_primary_command.cpp +++ b/src/mongo/db/s/shardsvr_move_primary_command.cpp @@ -41,7 +41,6 @@ #include "mongo/logv2/log.h" #include "mongo/s/grid.h" #include "mongo/s/request_types/move_primary_gen.h" -#include "mongo/s/sharded_collections_ddl_parameters_gen.h" namespace mongo { namespace { diff --git a/src/mongo/db/s/shardsvr_rename_collection_command.cpp b/src/mongo/db/s/shardsvr_rename_collection_command.cpp index 2ce50da2005..61e11b3ae32 100644 --- a/src/mongo/db/s/shardsvr_rename_collection_command.cpp +++ b/src/mongo/db/s/shardsvr_rename_collection_command.cpp @@ -38,13 +38,13 @@ #include "mongo/db/s/collection_sharding_state.h" #include "mongo/db/s/rename_collection_coordinator.h" #include "mongo/db/s/rename_collection_coordinator_document_gen.h" +#include "mongo/db/s/sharding_ddl_50_upgrade_downgrade.h" #include "mongo/db/s/sharding_ddl_coordinator_service.h" #include "mongo/db/s/sharding_state.h" #include "mongo/logv2/log.h" #include "mongo/s/cluster_commands_helpers.h" #include "mongo/s/grid.h" #include "mongo/s/request_types/sharded_ddl_commands_gen.h" -#include "mongo/s/sharded_collections_ddl_parameters_gen.h" namespace mongo { namespace { diff --git a/src/mongo/db/s/shardsvr_shard_collection_command.cpp b/src/mongo/db/s/shardsvr_shard_collection_command.cpp index c47dafa1232..b61f3784f89 100644 --- a/src/mongo/db/s/shardsvr_shard_collection_command.cpp +++ b/src/mongo/db/s/shardsvr_shard_collection_command.cpp @@ -36,12 +36,12 @@ #include "mongo/db/commands/feature_compatibility_version.h" #include "mongo/db/namespace_string.h" #include "mongo/db/s/shard_collection_legacy.h" +#include "mongo/db/s/sharding_ddl_50_upgrade_downgrade.h" #include "mongo/db/s/sharding_state.h" #include "mongo/logv2/log.h" #include "mongo/s/grid.h" #include "mongo/s/request_types/shard_collection_gen.h" #include "mongo/s/request_types/sharded_ddl_commands_gen.h" -#include "mongo/s/sharded_collections_ddl_parameters_gen.h" // TODO (SERVER-54879): Remove this command entirely after 5.0 branches namespace mongo { diff --git a/src/mongo/s/SConscript b/src/mongo/s/SConscript index 6aefcfd7acb..b20f5ddcf52 100644 --- a/src/mongo/s/SConscript +++ b/src/mongo/s/SConscript @@ -158,8 +158,8 @@ env.Library( 'request_types/commit_chunk_migration_request_type.cpp', 'request_types/commit_reshard_collection.idl', 'request_types/ensure_chunk_version_is_greater_than.idl', - 'request_types/flush_resharding_state_change.idl', 'request_types/flush_database_cache_updates.idl', + 'request_types/flush_resharding_state_change.idl', 'request_types/flush_routing_table_cache_updates.idl', 'request_types/get_database_version.idl', 'request_types/merge_chunk_request_type.cpp', @@ -184,7 +184,7 @@ env.Library( 'shard_cannot_refresh_due_to_locks_held_exception.cpp', 'shard_id.cpp', 'shard_invalidated_for_targeting_exception.cpp', - 'sharded_collections_ddl_parameters.idl', + 'sharding_ddl_50_upgrade_downgrade.idl', 'stale_exception.cpp', 'would_change_owning_shard_exception.cpp', ], diff --git a/src/mongo/s/catalog/type_chunk.cpp b/src/mongo/s/catalog/type_chunk.cpp index 0d2cd870982..663a355ec20 100644 --- a/src/mongo/s/catalog/type_chunk.cpp +++ b/src/mongo/s/catalog/type_chunk.cpp @@ -39,7 +39,6 @@ #include "mongo/bson/simple_bsonobj_comparator.h" #include "mongo/bson/util/bson_extract.h" #include "mongo/db/server_options.h" -#include "mongo/s/sharded_collections_ddl_parameters_gen.h" #include "mongo/util/assert_util.h" #include "mongo/util/str.h" diff --git a/src/mongo/s/sharded_collections_ddl_parameters.idl b/src/mongo/s/sharding_ddl_50_upgrade_downgrade.idl index 203e4eb47bd..203e4eb47bd 100644 --- a/src/mongo/s/sharded_collections_ddl_parameters.idl +++ b/src/mongo/s/sharding_ddl_50_upgrade_downgrade.idl |