summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierlauro Sciarelli <pierlauro.sciarelli@mongodb.com>2022-03-29 13:47:08 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-03-30 17:24:41 +0000
commit0ca2e8841b68f48903fa7abd387b8a9413db353f (patch)
tree1854724f64c36a5a79f2dd6438588f821cc08ac6
parent9676cf4ad8d537518eb1b570fc79bad4f31d8a79 (diff)
downloadmongo-0ca2e8841b68f48903fa7abd387b8a9413db353f.tar.gz
SERVER-65013 Optional min bound for `moveRange`
-rw-r--r--src/mongo/db/s/balancer/balancer.cpp3
-rw-r--r--src/mongo/db/s/shardsvr_move_range_command.cpp7
-rw-r--r--src/mongo/s/commands/cluster_move_range_cmd.cpp3
-rw-r--r--src/mongo/s/request_types/move_range_request.idl1
4 files changed, 11 insertions, 3 deletions
diff --git a/src/mongo/db/s/balancer/balancer.cpp b/src/mongo/db/s/balancer/balancer.cpp
index 51901478f8e..b4466c22f2c 100644
--- a/src/mongo/db/s/balancer/balancer.cpp
+++ b/src/mongo/db/s/balancer/balancer.cpp
@@ -394,7 +394,8 @@ Status Balancer::moveRange(OperationContext* opCtx,
const auto cm = uassertStatusOK(
Grid::get(opCtx)->catalogCache()->getShardedCollectionRoutingInfoWithRefresh(opCtx,
nss));
- return cm.findIntersectingChunkWithSimpleCollation(request.getMin());
+ // TODO SERVER-64926 do not assume min always present
+ return cm.findIntersectingChunkWithSimpleCollation(*request.getMin());
}();
if (chunk.getShardId() == request.getToShard()) {
diff --git a/src/mongo/db/s/shardsvr_move_range_command.cpp b/src/mongo/db/s/shardsvr_move_range_command.cpp
index dc3e3887d1d..ad92264d0cd 100644
--- a/src/mongo/db/s/shardsvr_move_range_command.cpp
+++ b/src/mongo/db/s/shardsvr_move_range_command.cpp
@@ -92,7 +92,8 @@ public:
BSONObjBuilder moveChunkReqBuilder(originalReq.toBSON({}));
moveChunkReqBuilder.append(WriteConcernOptions::kWriteConcernField, WC.toBSON());
- const auto& min = request().getMin();
+ // TODO SERVER-64926 do not assume min always present
+ const auto& min = *request().getMin();
// TODO SERVER-64817 compute missing bound of `moveRange` within MigrationSourceManager
if (!originalReq.getMax().is_initialized()) {
@@ -224,10 +225,12 @@ public:
BSONObj computeMaxBound(OperationContext* opCtx,
const Chunk& owningChunk,
const ShardKeyPattern& skPattern) {
+ // TODO SERVER-64926 do not assume min always present
+ const auto& min = *request().getMin();
auto [splitKeys, _] = autoSplitVector(opCtx,
ns(),
skPattern.toBSON(),
- request().getMin(),
+ min,
owningChunk.getMax(),
*request().getMaxChunkSizeBytes(),
1);
diff --git a/src/mongo/s/commands/cluster_move_range_cmd.cpp b/src/mongo/s/commands/cluster_move_range_cmd.cpp
index 43b59cc3610..bb53559394b 100644
--- a/src/mongo/s/commands/cluster_move_range_cmd.cpp
+++ b/src/mongo/s/commands/cluster_move_range_cmd.cpp
@@ -63,6 +63,9 @@ public:
const auto nss = ns();
const auto& req = request();
+ // TODO SERVER-64926 do not assume min always present
+ uassert(ErrorCodes::InvalidOptions, "Missing required parameter 'min'", req.getMin());
+
ConfigsvrMoveRange configsvrRequest(nss);
configsvrRequest.setDbName(NamespaceString::kAdminDb);
configsvrRequest.setMoveRangeRequest(req.getMoveRangeRequest());
diff --git a/src/mongo/s/request_types/move_range_request.idl b/src/mongo/s/request_types/move_range_request.idl
index 69fe2c3bc1c..bb9edfbc240 100644
--- a/src/mongo/s/request_types/move_range_request.idl
+++ b/src/mongo/s/request_types/move_range_request.idl
@@ -57,6 +57,7 @@ structs:
min:
type: object
description: "The min key of the range to move"
+ optional: true
max:
type: object
description: "The max key of the range to move"