-
Type:
Bug
-
Resolution: Unresolved
-
Priority:
Major - P3
-
None
-
Affects Version/s: 7.0.0, 8.0.0, 8.3.0
-
Component/s: None
-
None
-
Catalog and Routing
-
ALL
-
1
-
🟩 Routing and Topology
-
None
-
None
-
None
-
None
-
None
-
None
Description
The [MinKey, MaxKey] fast path in ChunkManager::getShardIdsForRange() is missing its return;, so it populates the output and then falls through into forEachOverlappingChunk(), which re-scans every chunk in the collection. The optimization is fully defeated. The comment ("return all shard ids right away") confirms
the return was intended.
if (!_clusterTime && ChunkMap::allElementsAreOfType(BSONType::minKey, min) &&
ChunkMap::allElementsAreOfType(BSONType::maxKey, max)) {
_rt->optRt->getAllShardIds(shardIds);
if (chunkRanges) {
getAllChunkRanges(chunkRanges);
}
} // <-- missing `return;` (line 850)
Impact
Performance only; results stay correct. Turns ~O(#shards) into an O(#chunks) full scan on a common query shape (whole-collection targeting).
Fix
Add return; at line 850.
- is caused by
-
SERVER-72987 analyzeShardKey misclassifies range queries in hashed sharding
-
- Closed
-
- is related to
-
SERVER-46487 The mongos routing for scatter/gather ops can have unbounded latency
-
- Closed
-