diff options
-rw-r--r-- | src/mongo/db/s/split_chunk.cpp | 14 | ||||
-rw-r--r-- | src/mongo/db/s/split_chunk_command.cpp | 9 |
2 files changed, 5 insertions, 18 deletions
diff --git a/src/mongo/db/s/split_chunk.cpp b/src/mongo/db/s/split_chunk.cpp index 2a9bc8ed366..968a4834419 100644 --- a/src/mongo/db/s/split_chunk.cpp +++ b/src/mongo/db/s/split_chunk.cpp @@ -43,7 +43,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" @@ -134,16 +134,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 = Grid::get(opCtx)->catalogClient()->getDistLockManager()->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 = |