[SERVER-4791] shard selection code ignores bound inclusivity Created: 27/Jan/12  Updated: 07/Dec/15  Resolved: 07/Dec/15

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

Type: Improvement Priority: Major - P3
Reporter: Aaron Staple Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-20768 Mongos find query including upper bou... Backlog
is duplicated by SERVER-5365 range query on shard key incorrectly ... Closed
is duplicated by SERVER-13487 Incorrect mongos shard routing for so... Closed
Participants:

 Description   

        void getShardsForRange(set<Shard>& shards, const BSONObj& min, const BSONObj& max, bool fullKeyReq = true) const; // [min, max)

The [min, max) comment is incorrect here, both min and max are treated as inclusive bounds. That means for a query like {a:{$lt:5}} a chunk [

{a:5}

,

{a:6}

) will be considered to potentially contain matches even though it cannot contain matches. Similarly, it looks like the datasize command calls this function with the expectation that max is treated as an exclusive bound, even though it is not.

There's no functional error here, just a possibility of sending the operation to a shard unnecessarily. And also, currently there are cases where an inclusive upper bound must be supported - so to optimize we'd need to support both inclusive and exclusive bounds.

Descriptive test written, push pending bb code freeze.



 Comments   
Comment by David Storch [ 07/Dec/15 ]

Closing as a duplicate of SERVER-20768.

Comment by auto [ 22/Mar/12 ]

Author:

{u'login': u'astaple', u'name': u'Aaron', u'email': u'aaron@10gen.com'}

Message: SERVER-4791 fix comment
Branch: master
https://github.com/mongodb/mongo/commit/e2c12ed81f65efe0525c64c64bef8c88175e65ec

Comment by auto [ 07/Feb/12 ]

Author:

{u'login': u'astaple', u'name': u'Aaron', u'email': u'aaron@10gen.com'}

Message: SERVER-4791 descriptive test
Branch: master
https://github.com/mongodb/mongo/commit/dd6da27e3290febad8214aa4f833dc7f7ed24b3c

Generated at Thu Feb 08 03:07:00 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.