[SERVER-72004] NestedLoopStage incorrectly disables slots used during openInner Created: 09/Dec/22  Updated: 29/Oct/23  Resolved: 20/Dec/22

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 6.3.0-rc0

Type: Task Priority: Major - P3
Reporter: Anna Wawrzyniak Assignee: Anna Wawrzyniak
Resolution: Fixed Votes: 0
Labels: pm2697-m2
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Sprint: QE 2022-12-12, QE 2022-12-26
Participants:
Story Points: 5

 Description   

NestedLoopStage incorrectly disables slots used during openInner:

https://github.com/10gen/mongo/blob/master/src/mongo/db/exec/sbe/stages/loop_join.cpp#L214

This occurs when inner side of the loop has blocking stage that iterates over its children during open(), like:

NLJ(1) 
  left:
    scan A
  right:
    hashAgg
       2: NLJ(2)
         left:
           scan B
         right:
           scan C 

when NLJ(1) is doing openInner, and hashAgg is doing getNext() and scan C is yielding, then once scan C completes its getNext, its slots will be fine, but scan B will have invalid pointer as it didn't make the copy, and that pointer will be invalid until NLJ(2) calls getNextOuterSide.

 

Proposed changes:

  1. remove _outerGetNext flag. _outerGetNext is true if:
    • inner child was never opened - we don't need to disable slots, as the state is empty.
    •   We are reading outer side. In this case the _isReadingLeftSide == true, making _outerGetNext redundant.
    • openInner() is in progress - we can't disable slots here as the inner side slots may be currently used
  2. add regression unit tests to prevent similar issue in the future.


 Comments   
Comment by Githook User [ 20/Dec/22 ]

Author:

{'name': 'Anna Wawrzyniak', 'email': 'anna.wawrzyniak@mongodb.com', 'username': 'anna-wawrzyniak'}

Message: SERVER-72004 Fixed SBE slot disabling and prepare for yielding
Branch: master
https://github.com/mongodb/mongo/commit/99edb0c1a7aabf41d4a6d92cdf5b6511e82a3333

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