summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaloian Manassiev <kaloian.manassiev@mongodb.com>2021-06-09 11:06:21 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-06-14 16:08:21 +0000
commit230067d0d9b084b619bda213b6af3b25db8b8aac (patch)
tree095576d06c17fd38029aba2c0713d8e48d9ae249
parent3a42f34b634eb9e5b0ccde551f6d8439ed1700c2 (diff)
downloadmongo-230067d0d9b084b619bda213b6af3b25db8b8aac.tar.gz
SERVER-56654 Do not use the collection distributed lock for chunk splits
(cherry picked from commit 92a8ceb94681642b438c20351f95c441498a29cf)
-rw-r--r--src/mongo/db/s/split_chunk.cpp14
-rw-r--r--src/mongo/db/s/split_chunk_command.cpp9
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 =