summaryrefslogtreecommitdiff
path: root/src/mongo/db/s/config
diff options
context:
space:
mode:
authorKaloian Manassiev <kaloian.manassiev@mongodb.com>2020-12-04 08:13:42 -0500
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-01-03 11:56:04 +0000
commit5431150d116b70fc9401c46deaacc9ae049f064e (patch)
treed1784b3cb2355cee9401e539f4574f0172995d8d /src/mongo/db/s/config
parent98a7731d21a8746e584f7092aadbee60a5fad6ef (diff)
downloadmongo-5431150d116b70fc9401c46deaacc9ae049f064e.tar.gz
SERVER-53227 Move the DistLockManager to only be available on MongoD
Diffstat (limited to 'src/mongo/db/s/config')
-rw-r--r--src/mongo/db/s/config/config_server_test_fixture.cpp20
-rw-r--r--src/mongo/db/s/config/config_server_test_fixture.h8
-rw-r--r--src/mongo/db/s/config/configsvr_clear_jumbo_flag_command.cpp6
-rw-r--r--src/mongo/db/s/config/configsvr_create_database_command.cpp6
-rw-r--r--src/mongo/db/s/config/configsvr_drop_collection_command.cpp8
-rw-r--r--src/mongo/db/s/config/configsvr_drop_database_command.cpp10
-rw-r--r--src/mongo/db/s/config/configsvr_enable_sharding_command.cpp11
-rw-r--r--src/mongo/db/s/config/configsvr_move_primary_command.cpp4
-rw-r--r--src/mongo/db/s/config/configsvr_refine_collection_shard_key_command.cpp18
-rw-r--r--src/mongo/db/s/config/configsvr_shard_collection_command.cpp5
-rw-r--r--src/mongo/db/s/config/initial_split_policy.h53
-rw-r--r--src/mongo/db/s/config/initial_split_policy_test.cpp12
-rw-r--r--src/mongo/db/s/config/sharding_catalog_manager.h8
-rw-r--r--src/mongo/db/s/config/sharding_catalog_manager_collection_operations.cpp34
-rw-r--r--src/mongo/db/s/config/sharding_catalog_manager_create_database_test.cpp2
-rw-r--r--src/mongo/db/s/config/sharding_catalog_manager_enable_sharding_test.cpp1
16 files changed, 74 insertions, 132 deletions
diff --git a/src/mongo/db/s/config/config_server_test_fixture.cpp b/src/mongo/db/s/config/config_server_test_fixture.cpp
index ab331cb2f4c..b8a21753d7e 100644
--- a/src/mongo/db/s/config/config_server_test_fixture.cpp
+++ b/src/mongo/db/s/config/config_server_test_fixture.cpp
@@ -51,13 +51,13 @@
#include "mongo/db/repl/repl_settings.h"
#include "mongo/db/repl/replication_coordinator_mock.h"
#include "mongo/db/s/config/sharding_catalog_manager.h"
+#include "mongo/db/s/dist_lock_catalog_replset.h"
+#include "mongo/db/s/dist_lock_manager_replset.h"
#include "mongo/executor/task_executor_pool.h"
#include "mongo/executor/thread_pool_task_executor_test_fixture.h"
#include "mongo/rpc/metadata/repl_set_metadata.h"
#include "mongo/rpc/metadata/tracking_metadata.h"
#include "mongo/s/balancer_configuration.h"
-#include "mongo/s/catalog/dist_lock_catalog_impl.h"
-#include "mongo/s/catalog/replset_dist_lock_manager.h"
#include "mongo/s/catalog/sharding_catalog_client_impl.h"
#include "mongo/s/catalog/type_chunk.h"
#include "mongo/s/catalog/type_collection.h"
@@ -161,25 +161,17 @@ void ConfigServerTestFixture::tearDown() {
ShardingMongodTestFixture::tearDown();
}
-std::unique_ptr<DistLockCatalog> ConfigServerTestFixture::makeDistLockCatalog() {
- return std::make_unique<DistLockCatalogImpl>();
-}
-
-std::unique_ptr<DistLockManager> ConfigServerTestFixture::makeDistLockManager(
- std::unique_ptr<DistLockCatalog> distLockCatalog) {
- invariant(distLockCatalog);
+std::unique_ptr<DistLockManager> ConfigServerTestFixture::makeDistLockManager() {
return std::make_unique<ReplSetDistLockManager>(
getServiceContext(),
"distLockProcessId",
- std::move(distLockCatalog),
+ std::make_unique<DistLockCatalogImpl>(),
ReplSetDistLockManager::kDistLockPingInterval,
ReplSetDistLockManager::kDistLockExpirationTime);
}
-std::unique_ptr<ShardingCatalogClient> ConfigServerTestFixture::makeShardingCatalogClient(
- std::unique_ptr<DistLockManager> distLockManager) {
- invariant(distLockManager);
- return std::make_unique<ShardingCatalogClientImpl>(std::move(distLockManager));
+std::unique_ptr<ShardingCatalogClient> ConfigServerTestFixture::makeShardingCatalogClient() {
+ return std::make_unique<ShardingCatalogClientImpl>();
}
std::unique_ptr<BalancerConfiguration> ConfigServerTestFixture::makeBalancerConfiguration() {
diff --git a/src/mongo/db/s/config/config_server_test_fixture.h b/src/mongo/db/s/config/config_server_test_fixture.h
index b5264d9131c..3e82cd8fcc3 100644
--- a/src/mongo/db/s/config/config_server_test_fixture.h
+++ b/src/mongo/db/s/config/config_server_test_fixture.h
@@ -167,13 +167,9 @@ protected:
*/
void setUpAndInitializeConfigDb();
- std::unique_ptr<DistLockCatalog> makeDistLockCatalog() override;
+ std::unique_ptr<DistLockManager> makeDistLockManager() override;
- std::unique_ptr<DistLockManager> makeDistLockManager(
- std::unique_ptr<DistLockCatalog> distLockCatalog) override;
-
- std::unique_ptr<ShardingCatalogClient> makeShardingCatalogClient(
- std::unique_ptr<DistLockManager> distLockManager) override;
+ std::unique_ptr<ShardingCatalogClient> makeShardingCatalogClient() override;
std::unique_ptr<ClusterCursorManager> makeClusterCursorManager() override;
diff --git a/src/mongo/db/s/config/configsvr_clear_jumbo_flag_command.cpp b/src/mongo/db/s/config/configsvr_clear_jumbo_flag_command.cpp
index ed955b9f209..c25d4dc9bdf 100644
--- a/src/mongo/db/s/config/configsvr_clear_jumbo_flag_command.cpp
+++ b/src/mongo/db/s/config/configsvr_clear_jumbo_flag_command.cpp
@@ -36,7 +36,7 @@
#include "mongo/db/commands.h"
#include "mongo/db/repl/repl_client_info.h"
#include "mongo/db/s/config/sharding_catalog_manager.h"
-#include "mongo/s/catalog/dist_lock_manager.h"
+#include "mongo/db/s/dist_lock_manager.h"
#include "mongo/s/grid.h"
#include "mongo/s/request_types/clear_jumbo_flag_gen.h"
@@ -70,10 +70,10 @@ public:
// Acquire distlocks on the namespace's database and collection.
DistLockManager::ScopedDistLock dbDistLock(
- uassertStatusOK(catalogClient->getDistLockManager()->lock(
+ uassertStatusOK(DistLockManager::get(opCtx)->lock(
opCtx, nss.db(), "clearJumboFlag", DistLockManager::kDefaultLockTimeout)));
DistLockManager::ScopedDistLock collDistLock(
- uassertStatusOK(catalogClient->getDistLockManager()->lock(
+ uassertStatusOK(DistLockManager::get(opCtx)->lock(
opCtx, nss.ns(), "clearJumboFlag", DistLockManager::kDefaultLockTimeout)));
CollectionType collType;
diff --git a/src/mongo/db/s/config/configsvr_create_database_command.cpp b/src/mongo/db/s/config/configsvr_create_database_command.cpp
index ec6793676b6..17725f4451d 100644
--- a/src/mongo/db/s/config/configsvr_create_database_command.cpp
+++ b/src/mongo/db/s/config/configsvr_create_database_command.cpp
@@ -42,6 +42,7 @@
#include "mongo/db/operation_context.h"
#include "mongo/db/repl/read_concern_args.h"
#include "mongo/db/s/config/sharding_catalog_manager.h"
+#include "mongo/db/s/dist_lock_manager.h"
#include "mongo/s/catalog/type_database.h"
#include "mongo/s/catalog_cache.h"
#include "mongo/s/grid.h"
@@ -90,9 +91,8 @@ public:
auto scopedLock =
ShardingCatalogManager::get(opCtx)->serializeCreateOrDropDatabase(opCtx, dbname);
- auto dbDistLock =
- uassertStatusOK(Grid::get(opCtx)->catalogClient()->getDistLockManager()->lock(
- opCtx, dbname, "createDatabase", DistLockManager::kDefaultLockTimeout));
+ auto dbDistLock = uassertStatusOK(DistLockManager::get(opCtx)->lock(
+ opCtx, dbname, "createDatabase", DistLockManager::kDefaultLockTimeout));
ShardingCatalogManager::get(opCtx)->createDatabase(opCtx, dbname, ShardId());
}
diff --git a/src/mongo/db/s/config/configsvr_drop_collection_command.cpp b/src/mongo/db/s/config/configsvr_drop_collection_command.cpp
index 005746b79f6..aa8b22651e6 100644
--- a/src/mongo/db/s/config/configsvr_drop_collection_command.cpp
+++ b/src/mongo/db/s/config/configsvr_drop_collection_command.cpp
@@ -36,8 +36,8 @@
#include "mongo/db/repl/read_concern_args.h"
#include "mongo/db/repl/repl_client_info.h"
#include "mongo/db/s/config/sharding_catalog_manager.h"
+#include "mongo/db/s/dist_lock_manager.h"
#include "mongo/db/s/operation_sharding_state.h"
-#include "mongo/s/catalog/dist_lock_manager.h"
#include "mongo/s/catalog/type_database.h"
#include "mongo/s/catalog_cache.h"
#include "mongo/s/client/shard_registry.h"
@@ -121,17 +121,15 @@ public:
setDropCollDistLockWait.execute(
[&](const BSONObj& data) { waitFor = Seconds(data["waitForSecs"].numberInt()); });
- auto const catalogClient = Grid::get(opCtx)->catalogClient();
-
auto scopedDbLock =
ShardingCatalogManager::get(opCtx)->serializeCreateOrDropDatabase(opCtx, nss.db());
auto scopedCollLock =
ShardingCatalogManager::get(opCtx)->serializeCreateOrDropCollection(opCtx, nss);
auto dbDistLock = uassertStatusOK(
- catalogClient->getDistLockManager()->lock(opCtx, nss.db(), "dropCollection", waitFor));
+ DistLockManager::get(opCtx)->lock(opCtx, nss.db(), "dropCollection", waitFor));
auto collDistLock = uassertStatusOK(
- catalogClient->getDistLockManager()->lock(opCtx, nss.ns(), "dropCollection", waitFor));
+ DistLockManager::get(opCtx)->lock(opCtx, nss.ns(), "dropCollection", waitFor));
ON_BLOCK_EXIT([opCtx, nss] {
Grid::get(opCtx)->catalogCache()->invalidateCollectionEntry_LINEARIZABLE(nss);
diff --git a/src/mongo/db/s/config/configsvr_drop_database_command.cpp b/src/mongo/db/s/config/configsvr_drop_database_command.cpp
index e2e69a6f042..7ef3658490c 100644
--- a/src/mongo/db/s/config/configsvr_drop_database_command.cpp
+++ b/src/mongo/db/s/config/configsvr_drop_database_command.cpp
@@ -37,15 +37,14 @@
#include "mongo/db/repl/repl_client_info.h"
#include "mongo/db/repl/replication_coordinator.h"
#include "mongo/db/s/config/sharding_catalog_manager.h"
+#include "mongo/db/s/dist_lock_manager.h"
#include "mongo/db/s/sharding_logging.h"
-#include "mongo/s/catalog/dist_lock_manager.h"
#include "mongo/s/catalog/type_database.h"
#include "mongo/s/catalog_cache.h"
#include "mongo/s/grid.h"
#include "mongo/util/scopeguard.h"
namespace mongo {
-
namespace {
/**
@@ -121,10 +120,9 @@ public:
auto const catalogClient = Grid::get(opCtx)->catalogClient();
auto const catalogManager = ShardingCatalogManager::get(opCtx);
- auto scopedLock =
- ShardingCatalogManager::get(opCtx)->serializeCreateOrDropDatabase(opCtx, dbname);
+ auto scopedLock = catalogManager->serializeCreateOrDropDatabase(opCtx, dbname);
- auto dbDistLock = uassertStatusOK(catalogClient->getDistLockManager()->lock(
+ auto dbDistLock = uassertStatusOK(DistLockManager::get(opCtx)->lock(
opCtx, dbname, "dropDatabase", DistLockManager::kDefaultLockTimeout));
// Invalidate the database metadata so the next access kicks off a full reload.
@@ -153,7 +151,7 @@ public:
// Drop the database's collections.
for (const auto& nss : catalogClient->getAllShardedCollectionsForDb(
opCtx, dbname, repl::ReadConcernArgs::get(opCtx).getLevel())) {
- auto collDistLock = uassertStatusOK(catalogClient->getDistLockManager()->lock(
+ auto collDistLock = uassertStatusOK(DistLockManager::get(opCtx)->lock(
opCtx, nss.ns(), "dropCollection", DistLockManager::kDefaultLockTimeout));
catalogManager->dropCollection(opCtx, nss);
}
diff --git a/src/mongo/db/s/config/configsvr_enable_sharding_command.cpp b/src/mongo/db/s/config/configsvr_enable_sharding_command.cpp
index aed8625b1b1..512448bf572 100644
--- a/src/mongo/db/s/config/configsvr_enable_sharding_command.cpp
+++ b/src/mongo/db/s/config/configsvr_enable_sharding_command.cpp
@@ -43,17 +43,13 @@
#include "mongo/db/operation_context.h"
#include "mongo/db/repl/read_concern_args.h"
#include "mongo/db/s/config/sharding_catalog_manager.h"
+#include "mongo/db/s/dist_lock_manager.h"
#include "mongo/s/catalog/type_database.h"
#include "mongo/s/catalog_cache.h"
#include "mongo/s/grid.h"
#include "mongo/util/scopeguard.h"
namespace mongo {
-
-using std::set;
-using std::shared_ptr;
-using std::string;
-
namespace {
/**
@@ -137,9 +133,8 @@ public:
// Make sure to force update of any stale metadata
ON_BLOCK_EXIT([opCtx, dbname] { Grid::get(opCtx)->catalogCache()->purgeDatabase(dbname); });
- auto dbDistLock =
- uassertStatusOK(Grid::get(opCtx)->catalogClient()->getDistLockManager()->lock(
- opCtx, dbname, "enableSharding", DistLockManager::kDefaultLockTimeout));
+ auto dbDistLock = uassertStatusOK(DistLockManager::get(opCtx)->lock(
+ opCtx, dbname, "enableSharding", DistLockManager::kDefaultLockTimeout));
ShardingCatalogManager::get(opCtx)->enableSharding(opCtx, dbname, shardId);
audit::logEnableSharding(Client::getCurrent(), dbname);
diff --git a/src/mongo/db/s/config/configsvr_move_primary_command.cpp b/src/mongo/db/s/config/configsvr_move_primary_command.cpp
index aabe58ef3a4..dc714ee9211 100644
--- a/src/mongo/db/s/config/configsvr_move_primary_command.cpp
+++ b/src/mongo/db/s/config/configsvr_move_primary_command.cpp
@@ -42,7 +42,7 @@
#include "mongo/db/operation_context.h"
#include "mongo/db/repl/read_concern_args.h"
#include "mongo/db/repl/repl_client_info.h"
-#include "mongo/db/s/config/sharding_catalog_manager.h"
+#include "mongo/db/s/dist_lock_manager.h"
#include "mongo/db/server_options.h"
#include "mongo/logv2/log.h"
#include "mongo/s/catalog/type_database.h"
@@ -145,7 +145,7 @@ public:
auto const catalogClient = Grid::get(opCtx)->catalogClient();
auto const shardRegistry = Grid::get(opCtx)->shardRegistry();
- auto dbDistLock = uassertStatusOK(catalogClient->getDistLockManager()->lock(
+ auto dbDistLock = uassertStatusOK(DistLockManager::get(opCtx)->lock(
opCtx, dbname, "movePrimary", DistLockManager::kDefaultLockTimeout));
auto dbType =
diff --git a/src/mongo/db/s/config/configsvr_refine_collection_shard_key_command.cpp b/src/mongo/db/s/config/configsvr_refine_collection_shard_key_command.cpp
index d3fa6bc250e..05b82b1af50 100644
--- a/src/mongo/db/s/config/configsvr_refine_collection_shard_key_command.cpp
+++ b/src/mongo/db/s/config/configsvr_refine_collection_shard_key_command.cpp
@@ -36,9 +36,9 @@
#include "mongo/db/commands.h"
#include "mongo/db/repl/repl_client_info.h"
#include "mongo/db/s/config/sharding_catalog_manager.h"
+#include "mongo/db/s/dist_lock_manager.h"
#include "mongo/db/s/shard_key_util.h"
#include "mongo/logv2/log.h"
-#include "mongo/s/catalog/dist_lock_manager.h"
#include "mongo/s/grid.h"
#include "mongo/s/request_types/refine_collection_shard_key_gen.h"
#include "mongo/s/stale_shard_version_helpers.h"
@@ -74,15 +74,15 @@ public:
// Acquire distlocks on the namespace's database and collection.
DistLockManager::ScopedDistLock dbDistLock(uassertStatusOK(
- catalogClient->getDistLockManager()->lock(opCtx,
- nss.db(),
- "refineCollectionShardKey",
- DistLockManager::kDefaultLockTimeout)));
+ DistLockManager::get(opCtx)->lock(opCtx,
+ nss.db(),
+ "refineCollectionShardKey",
+ DistLockManager::kDefaultLockTimeout)));
DistLockManager::ScopedDistLock collDistLock(uassertStatusOK(
- catalogClient->getDistLockManager()->lock(opCtx,
- nss.ns(),
- "refineCollectionShardKey",
- DistLockManager::kDefaultLockTimeout)));
+ DistLockManager::get(opCtx)->lock(opCtx,
+ nss.ns(),
+ "refineCollectionShardKey",
+ DistLockManager::kDefaultLockTimeout)));
// Validate the given namespace is (i) sharded, (ii) doesn't already have the proposed
// key, and (iii) has the same epoch as the router that received
diff --git a/src/mongo/db/s/config/configsvr_shard_collection_command.cpp b/src/mongo/db/s/config/configsvr_shard_collection_command.cpp
index 7cfc6445161..816369f690a 100644
--- a/src/mongo/db/s/config/configsvr_shard_collection_command.cpp
+++ b/src/mongo/db/s/config/configsvr_shard_collection_command.cpp
@@ -41,6 +41,7 @@
#include "mongo/db/query/collation/collator_factory_interface.h"
#include "mongo/db/repl/read_concern_args.h"
#include "mongo/db/s/config/sharding_catalog_manager.h"
+#include "mongo/db/s/dist_lock_manager.h"
#include "mongo/db/s/shard_key_util.h"
#include "mongo/s/balancer_configuration.h"
#include "mongo/s/catalog/type_database.h"
@@ -248,10 +249,10 @@ public:
// Make the distlocks boost::optional so that they can be released by being reset below.
boost::optional<DistLockManager::ScopedDistLock> dbDistLock(
- uassertStatusOK(catalogClient->getDistLockManager()->lock(
+ uassertStatusOK(DistLockManager::get(opCtx)->lock(
opCtx, nss.db(), "shardCollection", DistLockManager::kDefaultLockTimeout)));
boost::optional<DistLockManager::ScopedDistLock> collDistLock(
- uassertStatusOK(catalogClient->getDistLockManager()->lock(
+ uassertStatusOK(DistLockManager::get(opCtx)->lock(
opCtx, nss.ns(), "shardCollection", DistLockManager::kDefaultLockTimeout)));
// Ensure sharding is allowed on the database.
diff --git a/src/mongo/db/s/config/initial_split_policy.h b/src/mongo/db/s/config/initial_split_policy.h
index 75f2380baff..6687c53c933 100644
--- a/src/mongo/db/s/config/initial_split_policy.h
+++ b/src/mongo/db/s/config/initial_split_policy.h
@@ -66,6 +66,31 @@ public:
size_t numShards,
bool collectionIsEmpty);
+ virtual ~InitialSplitPolicy() {}
+
+ /**
+ * Generates a list of initial chunks to be created during a shardCollection operation.
+ */
+ struct ShardCollectionConfig {
+ std::vector<ChunkType> chunks;
+ Timestamp creationTime;
+
+ const auto& collVersion() const {
+ return chunks.back().getVersion();
+ }
+ };
+ virtual ShardCollectionConfig createFirstChunks(OperationContext* opCtx,
+ const ShardKeyPattern& shardKeyPattern,
+ SplitPolicyParams params) = 0;
+
+ /**
+ * Returns whether the chunk generation strategy being used is optimized or not. Since there is
+ * only a single unoptimized policy, we return true by default here.
+ */
+ virtual bool isOptimized() {
+ return true;
+ }
+
/**
* Returns split points to use for creating chunks in cases where the shard key contains a
* hashed field. For new collections which use hashed shard keys, we can can pre-split the range
@@ -79,15 +104,6 @@ public:
BSONObj prefix,
int numInitialChunks);
- struct ShardCollectionConfig {
- std::vector<ChunkType> chunks;
- Timestamp creationTime;
-
- const auto& collVersion() const {
- return chunks.back().getVersion();
- }
- };
-
/**
* Produces the initial chunks that need to be written for an *empty* collection which is being
* sharded based on a set of 'splitPoints' and 'numContiguousChunksPerShard'.
@@ -111,24 +127,7 @@ public:
const Timestamp& validAfter,
const std::vector<BSONObj>& splitPoints,
const std::vector<ShardId>& allShardIds,
- const int numContiguousChunksPerShard = 1);
-
- /**
- * Generates a list of initial chunks to be created during a shardCollection operation.
- */
- virtual ShardCollectionConfig createFirstChunks(OperationContext* opCtx,
- const ShardKeyPattern& shardKeyPattern,
- SplitPolicyParams params) = 0;
-
- /**
- * Returns whether the chunk generation strategy being used is optimized or not. Since there is
- * only a single unoptimized policy, we return true by default here.
- */
- virtual bool isOptimized() {
- return true;
- }
-
- virtual ~InitialSplitPolicy() {}
+ int numContiguousChunksPerShard);
};
/**
diff --git a/src/mongo/db/s/config/initial_split_policy_test.cpp b/src/mongo/db/s/config/initial_split_policy_test.cpp
index b583c6b87c4..b653e8f59c4 100644
--- a/src/mongo/db/s/config/initial_split_policy_test.cpp
+++ b/src/mongo/db/s/config/initial_split_policy_test.cpp
@@ -278,8 +278,13 @@ private:
TEST_F(GenerateInitialHashedSplitChunksTest, NoSplitPoints) {
const std::vector<BSONObj> splitPoints;
const std::vector<ShardId> shardIds = makeShardIds(2);
- const auto shardCollectionConfig = InitialSplitPolicy::generateShardCollectionInitialChunks(
- {nss(), boost::none, shardIds[0]}, shardKeyPattern(), timeStamp(), splitPoints, shardIds);
+ const auto shardCollectionConfig =
+ InitialSplitPolicy::generateShardCollectionInitialChunks({nss(), boost::none, shardIds[0]},
+ shardKeyPattern(),
+ timeStamp(),
+ splitPoints,
+ shardIds,
+ 1);
// there should only be one chunk
const auto expectedChunks =
@@ -296,7 +301,8 @@ TEST_F(GenerateInitialHashedSplitChunksTest, SplitPointsMoreThanAvailableShards)
shardKeyPattern(),
timeStamp(),
hashedSplitPoints(),
- shardIds);
+ shardIds,
+ 1);
// // chunks should be distributed in a round-robin manner
const std::vector<ChunkType> expectedChunks = makeChunks(
diff --git a/src/mongo/db/s/config/sharding_catalog_manager.h b/src/mongo/db/s/config/sharding_catalog_manager.h
index d68bd3a4dad..e9f0a69269a 100644
--- a/src/mongo/db/s/config/sharding_catalog_manager.h
+++ b/src/mongo/db/s/config/sharding_catalog_manager.h
@@ -47,14 +47,7 @@
namespace mongo {
-struct CollectionOptions;
-class OperationContext;
-class RemoteCommandTargeter;
-class ServiceContext;
-class UUID;
-
struct RemoveShardProgress {
-
/**
* Used to indicate to the caller of the removeShard method whether draining of chunks for
* a particular shard has started, is ongoing, or has been completed.
@@ -89,7 +82,6 @@ struct RemoveShardProgress {
class ShardingCatalogManager {
ShardingCatalogManager(const ShardingCatalogManager&) = delete;
ShardingCatalogManager& operator=(const ShardingCatalogManager&) = delete;
- friend class ConfigSvrShardCollectionCommand;
public:
ShardingCatalogManager(ServiceContext* serviceContext,
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 83af868f7f7..89246451c01 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
@@ -218,40 +218,6 @@ void triggerFireAndForgetShardRefreshes(OperationContext* opCtx, const Namespace
} // namespace
-void checkForExistingChunks(OperationContext* opCtx, const NamespaceString& nss) {
- BSONObjBuilder countBuilder;
- countBuilder.append("count", ChunkType::ConfigNS.coll());
- countBuilder.append("query", BSON(ChunkType::ns(nss.ns())));
-
- // OK to use limit=1, since if any chunks exist, we will fail.
- countBuilder.append("limit", 1);
-
- // Use readConcern local to guarantee we see any chunks that have been written and may
- // become committed; readConcern majority will not see the chunks if they have not made it
- // to the majority snapshot.
- repl::ReadConcernArgs readConcern(repl::ReadConcernLevel::kLocalReadConcern);
- readConcern.appendInfo(&countBuilder);
-
- auto cmdResponse = uassertStatusOK(
- Grid::get(opCtx)->shardRegistry()->getConfigShard()->runCommandWithFixedRetryAttempts(
- opCtx,
- kConfigReadSelector,
- ChunkType::ConfigNS.db().toString(),
- countBuilder.done(),
- Shard::kDefaultConfigCommandTimeout,
- Shard::RetryPolicy::kIdempotent));
- uassertStatusOK(cmdResponse.commandStatus);
-
- long long numChunks;
- uassertStatusOK(bsonExtractIntegerField(cmdResponse.response, "n", &numChunks));
- uassert(ErrorCodes::ManualInterventionRequired,
- str::stream() << "A previous attempt to shard collection " << nss.ns()
- << " failed after writing some initial chunks to config.chunks. Please "
- "manually delete the partially written chunks for collection "
- << nss.ns() << " from config.chunks",
- numChunks == 0);
-}
-
void sendDropCollectionToAllShards(OperationContext* opCtx, const NamespaceString& nss) {
const auto catalogClient = Grid::get(opCtx)->catalogClient();
diff --git a/src/mongo/db/s/config/sharding_catalog_manager_create_database_test.cpp b/src/mongo/db/s/config/sharding_catalog_manager_create_database_test.cpp
index 8e0cd0745f3..bc6d12ae396 100644
--- a/src/mongo/db/s/config/sharding_catalog_manager_create_database_test.cpp
+++ b/src/mongo/db/s/config/sharding_catalog_manager_create_database_test.cpp
@@ -38,9 +38,9 @@
#include "mongo/db/repl/read_concern_args.h"
#include "mongo/db/s/config/config_server_test_fixture.h"
#include "mongo/db/s/config/sharding_catalog_manager.h"
+#include "mongo/db/s/dist_lock_catalog_replset.h"
#include "mongo/rpc/get_status_from_command_result.h"
#include "mongo/rpc/metadata/tracking_metadata.h"
-#include "mongo/s/catalog/dist_lock_catalog_impl.h"
#include "mongo/s/catalog/type_database.h"
#include "mongo/s/catalog/type_shard.h"
#include "mongo/util/time_support.h"
diff --git a/src/mongo/db/s/config/sharding_catalog_manager_enable_sharding_test.cpp b/src/mongo/db/s/config/sharding_catalog_manager_enable_sharding_test.cpp
index 393e8533e50..6a09a6f1358 100644
--- a/src/mongo/db/s/config/sharding_catalog_manager_enable_sharding_test.cpp
+++ b/src/mongo/db/s/config/sharding_catalog_manager_enable_sharding_test.cpp
@@ -40,7 +40,6 @@
#include "mongo/db/s/config/sharding_catalog_manager.h"
#include "mongo/rpc/get_status_from_command_result.h"
#include "mongo/rpc/metadata/tracking_metadata.h"
-#include "mongo/s/catalog/dist_lock_catalog_impl.h"
#include "mongo/s/catalog/type_database.h"
#include "mongo/s/catalog/type_shard.h"
#include "mongo/s/client/shard_registry.h"