[SERVER-36741] ChunkManager::getShardIdsForRange invariants when max = MaxKey Created: 17/Aug/18  Updated: 29/Oct/23  Resolved: 29/Aug/18

Status: Closed
Project: Core Server
Component/s: Sharding
Affects Version/s: 3.6.7
Fix Version/s: 3.6.8

Type: Bug Priority: Major - P3
Reporter: Kaloian Manassiev Assignee: Kaloian Manassiev
Resolution: Fixed Votes: 0
Labels: Sharding:BugfixDay, neweng
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: Sharding 2018-09-10
Participants:
Linked BF Score: 2

 Description   

The ChunkManager::getShardIdsForRange call contains an invariant to ensure that the range it is passed is contained within the shard key space for the collection.

However, this invariant is incorrect when the range ends in MaxKey, because MaxKey is not a valid key value. The invariant should be extended to account for MaxKey and as part of fixing this we should write unit-tests to validate this logic.

This bug does not exist in versions 4.0 and later, because we use a different structure for the chunk ranges.



 Comments   
Comment by Githook User [ 29/Aug/18 ]

Author:

{'name': 'Kaloian Manassiev', 'email': 'kaloian.manassiev@mongodb.com', 'username': 'kaloianm'}

Message: SERVER-36741 Remove overzealous invariant in ChunkManager::getShardIdsForRange

The invariant disallows looking up ranges [MaxKey, MaxKey). While such a
range is not valid, it is difficult to prevent it from being generated by
the query system in a query such as {_id: MaxKey}.
Branch: v3.6
https://github.com/mongodb/mongo/commit/d836cb8ed7375d5898d4ea60e3e8c4ab53b94cc1

Generated at Thu Feb 08 04:43:57 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.