summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaloian Manassiev <kaloian.manassiev@mongodb.com>2021-06-27 15:57:26 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-06-28 10:07:36 +0000
commitab8a0797f06940df4240a39f05e0bfdcc4c59481 (patch)
tree92cbc2de39e163f9ee0c6f05fc2208a149793abb
parent7f07faf0e31bae949a33b03303d1030bac4966cc (diff)
downloadmongo-ab8a0797f06940df4240a39f05e0bfdcc4c59481.tar.gz
SERVER-58109 Make shardChunksInRangeQuery satisfiable from the index only
-rw-r--r--src/mongo/db/s/config/sharding_catalog_manager_chunk_operations.cpp14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/mongo/db/s/config/sharding_catalog_manager_chunk_operations.cpp b/src/mongo/db/s/config/sharding_catalog_manager_chunk_operations.cpp
index f45fd0e6e5c..3f50a47ae07 100644
--- a/src/mongo/db/s/config/sharding_catalog_manager_chunk_operations.cpp
+++ b/src/mongo/db/s/config/sharding_catalog_manager_chunk_operations.cpp
@@ -532,11 +532,7 @@ StatusWith<BSONObj> ShardingCatalogManager::commitChunkSplit(
BSON("query" << BSON(ChunkType::ns(nss.ns()) << ChunkType::min() << range.getMin()
<< ChunkType::max() << range.getMax())
<< "orderby" << BSON(ChunkType::lastmod() << -1)));
- {
- BSONObjBuilder bb(b.subobjStart("res"));
- bb.append(ChunkType::epoch(), requestEpoch);
- bb.append(ChunkType::shard(), shardName);
- }
+ b.append("res", BSON(ChunkType::epoch(requestEpoch) << ChunkType::shard(shardName)));
preCond.append(b.obj());
}
@@ -601,6 +597,8 @@ StatusWith<BSONObj> ShardingCatalogManager::commitChunkMerge(
// This method must never be called with empty chunks to merge
invariant(!chunkBoundaries.empty());
+ const auto configShard = Grid::get(opCtx)->shardRegistry()->getConfigShard();
+
// Take _kChunkOpLock in exclusive mode to prevent concurrent chunk splits, merges, and
// migrations
// TODO(SERVER-25359): Replace with a collection-specific lock map to allow splits/merges/
@@ -622,7 +620,7 @@ StatusWith<BSONObj> ShardingCatalogManager::commitChunkMerge(
// Get the max chunk version for this namespace.
auto swCollVersion = getMaxChunkVersionFromQueryResponse(
nss,
- Grid::get(opCtx)->shardRegistry()->getConfigShard()->exhaustiveFindOnConfig(
+ configShard->exhaustiveFindOnConfig(
opCtx,
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
repl::ReadConcernLevel::kLocalReadConcern,
@@ -809,10 +807,10 @@ StatusWith<BSONObj> ShardingCatalogManager::commitChunksMerge(
// 2. Retrieve the list of chunks belonging to the requested shard + key range.
const auto shardChunksInRangeQuery = [&]() {
BSONObjBuilder queryBuilder;
- queryBuilder << ChunkType::epoch(coll.getEpoch());
+ queryBuilder << ChunkType::ns(coll.getNs().ns());
queryBuilder << ChunkType::shard(shardId.toString());
queryBuilder << ChunkType::min(BSON("$gte" << chunkRange.getMin()));
- queryBuilder << ChunkType::max(BSON("$lte" << chunkRange.getMax()));
+ queryBuilder << ChunkType::min(BSON("$lt" << chunkRange.getMax()));
return queryBuilder.obj();
}();