[SERVER-65961] Copy only BSON types during yielding of SBE plans Created: 26/Apr/22  Updated: 29/Oct/23  Resolved: 29/Apr/22

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 6.0.0-rc4, 6.1.0-rc0

Type: Bug Priority: Blocker - P1
Reporter: Nikita Lapkov (Inactive) Assignee: Nikita Lapkov (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Depends
is depended on by SERVER-62287 Fix disabled Query Execution tests fa... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v6.0
Sprint: QE 2022-05-02
Participants:
Linked BF Score: 155

 Description   

Imagine we have the following SBE plan:

unwind s13 s14
project [s13 = if (getArraySize (s12) > 0, s12, [null])]
group [] [s12 = addToSet (s10)]
// Some part of the tree producing s10

Basically, we are collecting some values into ArraySet in s12, make a reference to s12 with s13 and then unwind ArraySet from s13.

Now imagine that after unwinding first N elements, yield happens. All values in the tree will be copied, including the value behind s13. Unwind will update its reference to ArraySet to point to the freshly copied value and skip first N elements. The problem is, we have no guarantee that these N elements are in fact the same elements produced before, since ArraySet does not have ordering guarantees.

Since all non-BSON values are always owned by the SBE tree, it makes sense to copy only BSON values during yielding. This will also solve the problem outlined above.



 Comments   
Comment by Githook User [ 29/Apr/22 ]

Author:

{'name': 'Nikita Lapkov', 'email': 'nikita.lapkov@mongodb.com', 'username': 'laplab'}

Message: SERVER-65961 Copy only BSON types during yielding of SBE plans

(cherry picked from commit a88230980fbeefa27f3b7cc07776650c6dfdb49f)
Branch: v6.0
https://github.com/mongodb/mongo/commit/6017abecf4150fbf05778b15145aaf7141cf1b12

Comment by Githook User [ 28/Apr/22 ]

Author:

{'name': 'Nikita Lapkov', 'email': 'nikita.lapkov@mongodb.com', 'username': 'laplab'}

Message: SERVER-65961 Copy only BSON types during yielding of SBE plans
Branch: master
https://github.com/mongodb/mongo/commit/a88230980fbeefa27f3b7cc07776650c6dfdb49f

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