Repository navigation
Conversation
…rror An Arrow fetch reads its chunk and then raises the warnings about its values from R. A warning made an error, as with `options(warn = 2)`, a handler that exits, or a failure to build the warnings lost the chunk, while its rows counted as fetched. The result now keeps the chunk until the warnings have returned: the next fetch returns it whole, without warning again. Until then, `dbGetRowCount()` doesn't count its rows and `dbHasCompleted()` is `FALSE`. A chunk kept from a handler's own fetch comes after the chunk that the handler interrupted. `dbBind()`, `dbClearResult()` and the garbage collector free a kept chunk. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd7QnTD4acgzTUihnF4
…' into claude/rb-arrow-kept-chunk
…' into claude/rb-arrow-kept-chunk
Member
Author
Question: which order should a kept Arrow chunk come back in, when a warning handler fetched more meanwhile?This pull request keeps an Arrow chunk whose conversion warnings didn't finish, for example under
Kirill decides. Until then the first option stays as implemented. Generated by Claude Code |
The entry point took the chunk from the result after R allocated the external pointers and the list of warnings, so a finalizer run by the garbage collector in between could clear the result or fetch from it. It now takes the chunk first, into its own owner, and holds a share of the result. A failed allocation hands the chunk back with its warnings still to come. A chunk joins the queue once its coercions are complete. The validation of a kept chunk is a test of its own, so that a skip for an old nanoarrow skips nothing else. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd7QnTD4acgzTUihnF4
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd7QnTD4acgzTUihnF4
This was referenced Dec 1, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No change of behavior for DBI methods: Arrow fetching is still internal. For the internal Arrow fetch, a chunk whose conversion warnings don't return is no longer lost. #961 reads an Arrow chunk and then raises its conversion warnings from R. With
options(warn = 2), an exiting handler (tryCatch(warning = )), or a failure while building the warnings, the chunk was dropped while its rows already counted as fetched, sodbGetRowCount()anddbHasCompleted()described rows the caller never received.The result now keeps the chunk until the warnings have returned.
result_fetch_arrow_chunk()builds the chunk into the result and then hands it out to R; if the warnings unwind,fetch_arrow_chunk_warn()hands the chunk back with the new internalresult_keep_arrow_chunk()fromon.exit(). The next fetch returns the kept chunk whole and ignores itsn: a fetch of one row after a kept chunk of two returns both. It doesn't warn again: the warnings belong to the fetch that read the rows, and warning again would make the chunk unreachable underoptions(warn = 2). The entry point takes the chunk out of the result before it allocates anything in R, keeping the result alive with its own share, so a finalizer that clears or fetches from the result meanwhile can't pull the chunk away; a failed allocation hands the chunk back, with its warnings still to come. Until the chunk is handed out,dbGetRowCount()doesn't count its rows anddbHasCompleted()isFALSE. Kept chunks form a queue in the order of their rows: when a calling handler's own fetch is kept and then the interrupted fetch unwinds too, the interrupted chunk comes first. Rows can come out of order when a calling handler's own fetch is handed out: if the handler of chunk A fetches chunk B and gets it, and A's warning then unwinds, A is kept and the caller sees B's rows before A's. The alternative would be to drop A and lose its rows; the open question is #962 (comment). A chunk handed back afterdbBind()(from a handler) belongs to an earlier execution and is dropped;dbBind(),dbClearResult()and the finalizer free kept chunks. A calling handler that clears the result still gets its chunk, as in #961.Tests: the new
test-arrow-kept-chunk.Rcoverswarn = 2followed by a refetch that returns the same rows in order (also for a chunk of all rows), an exiting handler, warnings that fail to build (mockedwarn_coercions()), nested handlers that keep one or two chunks, a calling handler that clears the result before an exit or underwarn = 2, a rebind outside and inside a handler, anddbClearResult()of a kept chunk, withdbGetRowCount()anddbHasCompleted()at each step. Two expectations intest-arrow-coercion.Rthat encoded the loss are removed. The Arrow validation of a kept chunk is a test of its own, so that a skip for nanoarrow < 0.6.0 skips nothing else. Red on #961's head: 6 of the 8 other new tests fail (the two release tests pass there, as nothing is kept); green with the fix. Full suite withNOT_CRAN=true: FAIL 0. The new test file and a script that lets the garbage collector free a kept chunk with its connection, and runs keep/hand-out/clear undergctorture(), are clean under valgrind (0 errors, 0 bytes definitely or indirectly lost).Layer F4b of the rebuilt chain, planned in #880; based on #961. Ported from
KeptArrowChunkin the old chain's #862 (claude/arrow-coercion-reports), adapted to warnings raised from R instead of C++; nothing for mixed data-frame/Arrow fetching.Coordinating session: https://claude.ai/code/session_01Hr1rd7QnTD4acgzTUihnF4
https://claude.ai/code/session_01Hr1rd7QnTD4acgzTUihnF4
Generated by Claude Code