Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-72004

NestedLoopStage incorrectly disables slots used during openInner

    • Type: Icon: Task Task
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 6.3.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • Fully Compatible
    • QE 2022-12-12, QE 2022-12-26
    • 5

      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.

            Assignee:
            anna.wawrzyniak@mongodb.com Anna Wawrzyniak
            Reporter:
            anna.wawrzyniak@mongodb.com Anna Wawrzyniak
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: