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-24 10:18:25 +0000 |
commit | 465368486675f6b9a45b50fea17be47b6284df41 (patch) | |
tree | 8955cf85297e73e204ca57952e66d1e01e901046 | |
parent | 0e0c905d987713004f273ffb8504e98a988b9fbd (diff) | |
download | mongo-465368486675f6b9a45b50fea17be47b6284df41.tar.gz |
SERVER-56654 Do not use the collection distributed lock for chunk splits
(cherry picked from commit d8401e342a8d273c1f8b466a93a9d002a8b363cb)
-rw-r--r-- | src/mongo/db/s/split_chunk.cpp | 19 | ||||
-rw-r--r-- | src/mongo/db/s/split_chunk_command.cpp | 9 |
2 files changed, 5 insertions, 23 deletions
diff --git a/src/mongo/db/s/split_chunk.cpp b/src/mongo/db/s/split_chunk.cpp index 89cddf3d812..e9a36fd6575 100644 --- a/src/mongo/db/s/split_chunk.cpp +++ b/src/mongo/db/s/split_chunk.cpp @@ -44,7 +44,7 @@ #include "mongo/db/keypattern.h" #include "mongo/db/namespace_string.h" #include "mongo/db/query/internal_plans.h" -#include "mongo/db/s/collection_metadata.h" +#include "mongo/db/s/active_migrations_registry.h" #include "mongo/db/s/collection_sharding_state.h" #include "mongo/db/s/shard_filtering_metadata_refresh.h" #include "mongo/db/s/sharding_state.h" @@ -135,21 +135,8 @@ StatusWith<boost::optional<ChunkRange>> splitChunk(OperationContext* opCtx, const std::vector<BSONObj>& splitKeys, const std::string& shardName, const OID& expectedCollectionEpoch) { - // - // Lock the collection's metadata and get highest version for the current shard - // TODO(SERVER-25086): Remove distLock acquisition from split chunk - // - const std::string whyMessage( - str::stream() << "splitting chunk " << redact(chunkRange.toString()) << " in " - << nss.toString()); - auto scopedDistLock = Grid::get(opCtx)->catalogClient()->getDistLockManager()->lock( - opCtx, nss.ns(), whyMessage, DistLockManager::kSingleLockAttemptTimeout); - 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 type // NumberLong. diff --git a/src/mongo/db/s/split_chunk_command.cpp b/src/mongo/db/s/split_chunk_command.cpp index 896625ff1e0..079dc705eb6 100644 --- a/src/mongo/db/s/split_chunk_command.cpp +++ b/src/mongo/db/s/split_chunk_command.cpp @@ -48,11 +48,6 @@ #include "mongo/util/mongoutils/str.h" namespace mongo { - -using std::string; -using std::unique_ptr; -using std::vector; - namespace { class SplitChunkCommand : public ErrmsgCommandDeprecated { @@ -117,13 +112,13 @@ public: auto chunkRange = uassertStatusOK(ChunkRange::fromBSON(cmdObj)); - string shardName; + std::string shardName; auto parseShardNameStatus = bsonExtractStringField(cmdObj, "from", &shardName); uassertStatusOK(parseShardNameStatus); log() << "received splitChunk request: " << redact(cmdObj); - vector<BSONObj> splitKeys; + std::vector<BSONObj> splitKeys; { BSONElement splitKeysElem; auto splitKeysElemStatus = |