rows/rowscanner: set isFinished=true when last page has no more rows#359
rows/rowscanner: set isFinished=true when last page has no more rows#359Dev-X25874 wants to merge 1 commit into
Conversation
|
This change is functionally a no-op — Tracing The early-exit guard at line 117 ( |
|
You're right, and I appreciate the careful trace. I missed that getNextPage()'s fetch loop always executes at least once — Contains(Start() + Count()) resolves to start + count <= start + count - 1, which is always false — so lines 201–205 unconditionally write isFinished from HasMoreRows before returning. By the time HasNext() reaches the !nrp.GetHasMoreRows() branch, isFinished is already true, and the guard at line 117 correctly handles all subsequent calls. |
Problem
In
resultPageIterator.HasNext(), when a fetched page hasHasMoreRows == false,the code calls
rpf.Close()to close the operation handle on the server but neversets
rpf.isFinished = true.After
Next()consumes that last page and clearsnextResultPage, any subsequentcall to
HasNext()bypasses the early-exit guard at the top of the function(which checks
isFinished && nextResultPage == nil) and falls through togetNextPage(). SinceisFinishedis stillfalse,getNextPage()proceeds toissue a
FetchResultsRPC against an already-closed operation handle, resultingin a spurious server-side error instead of a clean
io.EOF.Fix
Set
rpf.isFinished = truealongsiderpf.Close()in the no-more-rows branch,mirroring what the error path in the same function already does correctly:
Impact
Any caller that invokes
HasNext()more than once after the last page is consumed— a reasonable and common pattern — would previously receive an unexpected RPC
error. After this fix they receive
false/io.EOFas intended.