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:
- 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
- add regression unit tests to prevent similar issue in the future.