summaryrefslogtreecommitdiff
path: root/src/mongo/db/s
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/s')
-rw-r--r--src/mongo/db/s/balancer/migration_manager_test.cpp3
-rw-r--r--src/mongo/db/s/config/sharding_catalog_manager_add_shard_test.cpp28
-rw-r--r--src/mongo/db/s/config/sharding_catalog_manager_database_operations.cpp12
3 files changed, 24 insertions, 19 deletions
diff --git a/src/mongo/db/s/balancer/migration_manager_test.cpp b/src/mongo/db/s/balancer/migration_manager_test.cpp
index ac54e2aa185..5aae83503a2 100644
--- a/src/mongo/db/s/balancer/migration_manager_test.cpp
+++ b/src/mongo/db/s/balancer/migration_manager_test.cpp
@@ -39,6 +39,7 @@
#include "mongo/s/catalog/type_locks.h"
#include "mongo/s/catalog/type_shard.h"
#include "mongo/s/config_server_test_fixture.h"
+#include "mongo/s/database_version_helpers.h"
#include "mongo/s/request_types/move_chunk_request.h"
#include "mongo/stdx/memory.h"
#include "mongo/util/scopeguard.h"
@@ -178,7 +179,7 @@ std::shared_ptr<RemoteCommandTargeterMock> MigrationManagerTest::shardTargeterMo
}
void MigrationManagerTest::setUpDatabase(const std::string& dbName, const ShardId primaryShard) {
- DatabaseType db(dbName, primaryShard, true);
+ DatabaseType db(dbName, primaryShard, true, databaseVersion::makeNew());
ASSERT_OK(catalogClient()->insertConfigDocument(
operationContext(), DatabaseType::ConfigNS, db.toBSON(), kMajorityWriteConcern));
}
diff --git a/src/mongo/db/s/config/sharding_catalog_manager_add_shard_test.cpp b/src/mongo/db/s/config/sharding_catalog_manager_add_shard_test.cpp
index 60bb75312d0..f0e5aa84f5e 100644
--- a/src/mongo/db/s/config/sharding_catalog_manager_add_shard_test.cpp
+++ b/src/mongo/db/s/config/sharding_catalog_manager_add_shard_test.cpp
@@ -50,6 +50,7 @@
#include "mongo/s/client/shard_registry.h"
#include "mongo/s/cluster_identity_loader.h"
#include "mongo/s/config_server_test_fixture.h"
+#include "mongo/s/database_version_helpers.h"
#include "mongo/s/write_ops/batched_command_response.h"
#include "mongo/util/fail_point_service.h"
#include "mongo/util/log.h"
@@ -396,8 +397,10 @@ TEST_F(AddShardTest, StandaloneBasicSuccess) {
expectedShard.setMaxSizeMB(100);
expectedShard.setState(ShardType::ShardState::kShardAware);
- DatabaseType discoveredDB1("TestDB1", ShardId("StandaloneShard"), false);
- DatabaseType discoveredDB2("TestDB2", ShardId("StandaloneShard"), false);
+ DatabaseType discoveredDB1(
+ "TestDB1", ShardId("StandaloneShard"), false, databaseVersion::makeNew());
+ DatabaseType discoveredDB2(
+ "TestDB2", ShardId("StandaloneShard"), false, databaseVersion::makeNew());
operationContext()->setWriteConcern(ShardingCatalogClient::kMajorityWriteConcern);
@@ -480,8 +483,10 @@ TEST_F(AddShardTest, StandaloneGenerateName) {
expectedShard.setMaxSizeMB(100);
expectedShard.setState(ShardType::ShardState::kShardAware);
- DatabaseType discoveredDB1("TestDB1", ShardId(expectedShardName), false);
- DatabaseType discoveredDB2("TestDB2", ShardId(expectedShardName), false);
+ DatabaseType discoveredDB1(
+ "TestDB1", ShardId(expectedShardName), false, databaseVersion::makeNew());
+ DatabaseType discoveredDB2(
+ "TestDB2", ShardId(expectedShardName), false, databaseVersion::makeNew());
auto future = launchAsync([this, &expectedShardName, &shardTarget] {
Client::initThreadIfNotAlready();
@@ -821,7 +826,8 @@ TEST_F(AddShardTest, ShardContainsExistingDatabase) {
targeterFactory()->addTargeterToReturn(connString, std::move(targeter));
std::string expectedShardName = "mySet";
- DatabaseType existingDB("existing", ShardId("existingShard"), false);
+ DatabaseType existingDB(
+ "existing", ShardId("existingShard"), false, databaseVersion::makeNew());
// Add a pre-existing database.
ASSERT_OK(catalogClient()->insertConfigDocument(operationContext(),
@@ -876,7 +882,8 @@ TEST_F(AddShardTest, SuccessfullyAddReplicaSet) {
expectedShard.setMaxSizeMB(100);
expectedShard.setState(ShardType::ShardState::kShardAware);
- DatabaseType discoveredDB("shardDB", ShardId(expectedShardName), false);
+ DatabaseType discoveredDB(
+ "shardDB", ShardId(expectedShardName), false, databaseVersion::makeNew());
auto future = launchAsync([this, &expectedShardName, &connString] {
Client::initThreadIfNotAlready();
@@ -941,7 +948,8 @@ TEST_F(AddShardTest, ReplicaSetExtraHostsDiscovered) {
expectedShard.setMaxSizeMB(100);
expectedShard.setState(ShardType::ShardState::kShardAware);
- DatabaseType discoveredDB("shardDB", ShardId(expectedShardName), false);
+ DatabaseType discoveredDB(
+ "shardDB", ShardId(expectedShardName), false, databaseVersion::makeNew());
auto future = launchAsync([this, &expectedShardName, &seedString] {
Client::initThreadIfNotAlready();
@@ -1007,8 +1015,10 @@ TEST_F(AddShardTest, AddShardSucceedsEvenIfAddingDBsFromNewShardFails) {
expectedShard.setMaxSizeMB(100);
expectedShard.setState(ShardType::ShardState::kShardAware);
- DatabaseType discoveredDB1("TestDB1", ShardId("StandaloneShard"), false);
- DatabaseType discoveredDB2("TestDB2", ShardId("StandaloneShard"), false);
+ DatabaseType discoveredDB1(
+ "TestDB1", ShardId("StandaloneShard"), false, databaseVersion::makeNew());
+ DatabaseType discoveredDB2(
+ "TestDB2", ShardId("StandaloneShard"), false, databaseVersion::makeNew());
// Enable fail point to cause all updates to fail. Since we add the databases detected from
// the shard being added with upserts, but we add the shard document itself via insert, this
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 8feb307bedc..fe87d6f7c1a 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
@@ -226,16 +226,10 @@ Status ShardingCatalogManager::commitMovePrimary(OperationContext* opCtx,
auto const currentDatabaseVersion = dbType.getVersion();
- uassert(ErrorCodes::InternalError,
- str::stream() << "DatabaseVersion doesn't exist in database entry despite the config "
- << "server being in FCV 4.0"
- << dbType.toBSON(),
- currentDatabaseVersion != boost::none);
-
- newDbType.setVersion(databaseVersion::makeIncremented(*currentDatabaseVersion));
+ newDbType.setVersion(databaseVersion::makeIncremented(currentDatabaseVersion));
auto updateQueryBuilder = BSONObjBuilder(BSON(DatabaseType::name << dbname));
- updateQueryBuilder.append(DatabaseType::version.name(), currentDatabaseVersion->toBSON());
+ updateQueryBuilder.append(DatabaseType::version.name(), currentDatabaseVersion.toBSON());
auto updateStatus = Grid::get(opCtx)->catalogClient()->updateConfigDocument(
opCtx,
@@ -258,7 +252,7 @@ Status ShardingCatalogManager::commitMovePrimary(OperationContext* opCtx,
uassert(ErrorCodes::IncompatibleShardingMetadata,
str::stream() << "Tried to update primary shard for database '" << dbname
<< " with version "
- << currentDatabaseVersion->getLastMod(),
+ << currentDatabaseVersion.getLastMod(),
updateStatus.getValue());
// Ensure the next attempt to retrieve the database or any of its collections will do a full