diff options
author | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2021-06-09 11:06:21 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-06-14 12:26:49 +0000 |
commit | 92a8ceb94681642b438c20351f95c441498a29cf (patch) | |
tree | 7920ab4707ea0b6e9cc4707a2b3f73f7eecb7c7e | |
parent | 69ea6153374eaa35128871ea13e48cd8735f0f04 (diff) | |
download | mongo-92a8ceb94681642b438c20351f95c441498a29cf.tar.gz |
SERVER-56654 Do not use the collection distributed lock for chunk splits
-rw-r--r-- | src/mongo/db/s/active_migrations_registry.cpp | 1 | ||||
-rw-r--r-- | src/mongo/db/s/split_chunk.cpp | 14 | ||||
-rw-r--r-- | src/mongo/db/s/split_chunk_command.cpp | 9 |
3 files changed, 5 insertions, 19 deletions
diff --git a/src/mongo/db/s/active_migrations_registry.cpp b/src/mongo/db/s/active_migrations_registry.cpp index 3ec8706c32d..500d30bf102 100644 --- a/src/mongo/db/s/active_migrations_registry.cpp +++ b/src/mongo/db/s/active_migrations_registry.cpp @@ -35,7 +35,6 @@ #include "mongo/db/catalog_raii.h" #include "mongo/db/s/collection_sharding_runtime.h" -#include "mongo/db/s/dist_lock_manager.h" #include "mongo/db/s/migration_session_id.h" #include "mongo/db/s/migration_source_manager.h" #include "mongo/db/service_context.h" diff --git a/src/mongo/db/s/split_chunk.cpp b/src/mongo/db/s/split_chunk.cpp index 9cd07adae36..3f6f3a63029 100644 --- a/src/mongo/db/s/split_chunk.cpp +++ b/src/mongo/db/s/split_chunk.cpp @@ -43,8 +43,8 @@ #include "mongo/db/keypattern.h" #include "mongo/db/namespace_string.h" #include "mongo/db/query/internal_plans.h" +#include "mongo/db/s/active_migrations_registry.h" #include "mongo/db/s/collection_sharding_runtime.h" -#include "mongo/db/s/dist_lock_manager.h" #include "mongo/db/s/shard_filtering_metadata_refresh.h" #include "mongo/db/s/sharding_state.h" #include "mongo/logv2/log.h" @@ -133,16 +133,8 @@ StatusWith<boost::optional<ChunkRange>> splitChunk(OperationContext* opCtx, const std::vector<BSONObj>& splitKeys, const std::string& shardName, const OID& expectedCollectionEpoch) { - const std::string whyMessage(str::stream() - << "splitting chunk " << redact(chunkRange.toString()) << " in " - << nss.toString()); - auto scopedDistLock = DistLockManager::get(opCtx)->lock( - opCtx, nss.ns(), whyMessage, DistLockManager::kDefaultLockTimeout); - if (!scopedDistLock.isOK()) { - return scopedDistLock.getStatus().withContext( - str::stream() << "could not acquire collection lock for " << nss.toString() - << " to split chunk " << chunkRange.toString()); - } + auto scopedSplitOrMergeChunk(uassertStatusOK( + ActiveMigrationsRegistry::get(opCtx).registerSplitOrMergeChunk(opCtx, nss, chunkRange))); // If the shard key is hashed, then we must make sure that the split points are of supported // data types. diff --git a/src/mongo/db/s/split_chunk_command.cpp b/src/mongo/db/s/split_chunk_command.cpp index 3fe52d2c585..9a17b009b2d 100644 --- a/src/mongo/db/s/split_chunk_command.cpp +++ b/src/mongo/db/s/split_chunk_command.cpp @@ -47,11 +47,6 @@ #include "mongo/util/str.h" namespace mongo { - -using std::string; -using std::unique_ptr; -using std::vector; - namespace { class SplitChunkCommand : public ErrmsgCommandDeprecated { @@ -116,7 +111,7 @@ public: auto chunkRange = uassertStatusOK(ChunkRange::fromBSON(cmdObj)); - string shardName; + std::string shardName; auto parseShardNameStatus = bsonExtractStringField(cmdObj, "from", &shardName); uassertStatusOK(parseShardNameStatus); @@ -125,7 +120,7 @@ public: "Received splitChunk request", "request"_attr = redact(cmdObj)); - vector<BSONObj> splitKeys; + std::vector<BSONObj> splitKeys; { BSONElement splitKeysElem; auto splitKeysElemStatus = |