Repository navigation
Fix infinite RecursiveCursor out-of-band behavior - #4136
Conversation
| // Stop before child. | ||
| continuation = buildContinuation(depth); | ||
| } | ||
| final RecordCursorContinuation continuation = buildContinuation(depth + 1); |
There was a problem hiding this comment.
For preorder, won't this occasionally lose a node that had emitPending and hits the scan limit before the first child? The new test doesn't see this because its indexes are efficient enough that you always get a record each scan, until the end.
There was a problem hiding this comment.
That’s correct. I verified this through a test that performs “inefficient” scans by disabling the secondary indexes and discovered that sometimes, that node is missing between the out-of-band and the continuation resumption. To address this, I modified the code by adding a conditional that reduces the depth of the saved continuation by one if we’re in preorder traversal and the node was in the emit-pending state so we don't miss it.
When
recursionLoop()encountered an out-of-band stop, it built the continuation atdepth - 1(postorder) ordepth(preorder before first emit), discarding the child cursor's scan progress. On resume,addChildNodewould create a fresh node with a START continuation, causing the child cursor to re-scan from the beginning and hit the same limit indefinitely.This fixes #4135.