[SERVER-60287] Make clustered collection scan respect min bounds Created: 28/Sep/21  Updated: 29/Oct/23  Resolved: 06/Oct/21

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

Type: Task Priority: Major - P3
Reporter: Haley Connelly Assignee: Haley Connelly
Resolution: Fixed Votes: 0
Labels: PM-2311-M1
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
is depended on by SERVER-60002 Enable TTLDeletions on clustered coll... Closed
Backwards Compatibility: Fully Compatible
Sprint: Execution Team 2021-10-04, Execution Team 2021-10-18
Participants:

 Description   

Inside collection_scan.cpp atEndOfRangeInclusive() is used to determine if a recordId is exceeds beyond the end bound. However, there is no check whether a recordId is before the start bound.Consider the following:

Recall RecordIds generated from type ‘objectId’ begin with typebits 78, RecordIds generated from type ‘date’ begin with typebits 64

  • Suppose recId0 is generated from a date type (begins with 64)
  • maxRecord = 78***, minRecord = 78** (both of type ObjectId)
  • Inside CollectionScan::returnIfMatches(), we are not inside at the end of the rangeBound, and there is no filter provided so it passes the filter and returns PlanStage::Advanced
  • The caller of returnIfMatches will think there is new work to be done with the document found (recId0)
  • This means a result of different type than the bounds may be misinterpreted as within the bounds

Instead of returning PlanStage::Advanced, returnIfMatches should check if the recId found is outside the start bound, and return PlanStage::NEED_TIME if so to prompt another pass



 Comments   
Comment by Githook User [ 05/Oct/21 ]

Author:

{'name': 'Haley Connelly', 'email': 'haley.connelly@mongodb.com', 'username': 'haleyConnelly'}

Message: SERVER-60287 Make clustered collection scan respect minimum bound
Branch: master
https://github.com/mongodb/mongo/commit/2a1be4c86a90eff9023ab3cbf9978d8c105f42d7

Comment by Louis Williams [ 28/Sep/21 ]

The only part that's missing here is that seekNear is allowed to return a RecordId that starts with 64 even when searching for a RecordId that starts with 78. This is described in the comment for seekNear()

Generated at Thu Feb 08 05:49:25 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.