summaryrefslogtreecommitdiff
path: root/src/mongo/db/s/config
diff options
context:
space:
mode:
authorKaloian Manassiev <kaloian.manassiev@mongodb.com>2021-04-13 08:36:38 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-04-13 19:38:30 +0000
commit56dd69e03b5495d0882ce5d0a049e55880b7cb95 (patch)
tree579630c380ab34e1d6a949ee302b552513b409df /src/mongo/db/s/config
parent6f4cec03cca5475b66dbbc26d1b9a6ad695331b8 (diff)
downloadmongo-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.
Diffstat (limited to 'src/mongo/db/s/config')
-rw-r--r--src/mongo/db/s/config/configsvr_reshard_collection_cmd.cpp1
-rw-r--r--src/mongo/db/s/config/initial_split_policy.cpp1
-rw-r--r--src/mongo/db/s/config/sharding_catalog_manager.cpp33
-rw-r--r--src/mongo/db/s/config/sharding_catalog_manager.h22
-rw-r--r--src/mongo/db/s/config/sharding_catalog_manager_chunk_operations.cpp1
-rw-r--r--src/mongo/db/s/config/sharding_catalog_manager_collection_operations.cpp8
-rw-r--r--src/mongo/db/s/config/sharding_catalog_manager_config_initialization_test.cpp2
-rw-r--r--src/mongo/db/s/config/sharding_catalog_manager_database_operations.cpp2
-rw-r--r--src/mongo/db/s/config/sharding_catalog_manager_shard_operations.cpp2
9 files changed, 24 insertions, 48 deletions
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"