Repository navigation
Conversation
The tests pin what a change of how results are owned must keep: `dbIsValid()` before and after `dbClearResult()`, a second `dbClearResult()`, the error of every use of a cleared result, a result cleared when the next query is sent, a result collected without being cleared, the warning of `dbDisconnect()` with results in use, and a handler that catches the busy guard's error and clears the result after its fetch. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
The external pointer of a result owns a `DbResultPtr`, a `boost::shared_ptr<DbResult>`, as the external pointer of a connection owns a `DbConnectionPtr`. `dbClearResult()` and the finalizer drop R's share. It is the only share, so a result is freed exactly when it was before. A later change lets an Arrow stream hold a share of its own, so that the stream can outlive `dbClearResult()`. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
|
Review of this pull request at 2f319a7, by a Claude Code reviewer with clean context that read the description, the two commits 7387832..2f319a7, the code around them ( What was run
What holds
HighNone. MediumNone. Low
Generated by Claude Code |
A `DbResultPtr` is built from the `DbResult*` that `create_and_send_query()` returns, so it deletes the `SqliteResult` through a pointer to its base, as the external pointer did before. A virtual destructor makes that deletion well-defined, also for any later owner that holds a `DbResultPtr`. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
…after `dbDisconnect()` The disconnect test ended with a `gc()` that could not fail. Its last result now holds a read lock on a database file, which blocks a write from a second connection until the result is collected. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
Superseded: Accepted limitationsSuperseded by the current copy. The clean review found nothing above Low; ten lifetime scenarios gave identical results to #855's head, plain and under AddressSanitizer with
Generated by Claude Code |
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd432Aef98ibnZSSsYn
Question: make the disconnect test independent of the journal mode and the busy timeout?The new test "disconnecting with an open result warns, the result holds the connection" checks that the finalizer releases the last result after
Kirill decides. If nobody decides, the test stays as it is, and the limitation stays checked in the "Accepted limitations". Generated by Claude Code |
Accepted limitationsThe clean review found nothing above Low; ten lifetime scenarios gave identical results to #855's head, plain and under AddressSanitizer with
Generated by Claude Code |
This is the second pull request of the reworked Arrow stack, as planned in #829 (comment). The external pointer of a result now owns a
DbResultPtr, aboost::shared_ptr<DbResult>, the way the external pointer of a connection owns aDbConnectionPtr. This lets a later pull request give an Arrow stream a share of the result, so that the stream can outlivedbClearResult(). Nothing changes in behavior or messages.What changes
DbResult.hdeclaresDbResultPtrnext toDbConnectionPtr, and makes~DbResult()virtual. The shared pointer is built from theDbResult*thatcreate_and_send_query()returns, so it deletes theSqliteResultthrough a pointer to its base, as cpp11's deleter did before. That was undefined behavior on the base too, harmless only becauseSqliteResulthas no members of its own. A virtual destructor is the smallest fix (one line), and it covers any later owner of aDbResultPtr, such as the Arrow stream, not justresult_create(). Its cost is one vtable pointer per result.result_create()wraps the new result in aDbResultPtrand returns an external pointer to it, asconnection_connect()does with aDbConnectionPtr.result_release(), behinddbClearResult(), and cpp11's finalizer delete thatDbResultPtr, which drops R's share of the result.as_cpp()specialisations forDbResult*andSqliteResult*inRSQLite_types.hread theDbResultPtrand return the result it points to. So the entry points that take aDbResult*or aSqliteResult*are unchanged.result_valid()andresult_release(), including fix: Never restart a statement after an error indbFetch()ordbBind()#830's busy guard, look through the shared pointer.src/cpp11.cppis regenerated for the new types of the three entry points.What a reviewer may want to check
dbClearResult(), or by the finalizer of a result that was never cleared. The finalizer of a cleared result finds the external pointer cleared and does nothing, as before. The "results in use" warning ofdbDisconnect()counts the shares of the connection, and each result still holds one.as_cpp(),result_valid()andresult_release()also check that the shared pointer is not empty, as feat: Implement the DBI Arrow interface natively #795 does. It never is, becausecreate_and_send_query()throws instead of returningNULL, so these checks change nothing today.RSQLite_types.h, and itsresult_create(),result_release()andresult_valid()without the Arrow calls around them. feat: Implement the DBI Arrow interface natively #795 keeps the non-virtual destructor.Left out
The second owner of a result, an Arrow stream that keeps it after
dbClearResult()anddbDisconnect(), comes in pull request 10 of the plan. The thread-aware busy mark and the deferred release of results let go on other threads, which #795 adds for streams read by arrow's scanner, come in pull request 15. Everything else Arrow comes later too.Tests
Six new tests in
test-dbClearResult.RcoverdbIsValid()before and afterdbClearResult()and a seconddbClearResult()with its warning. They pin the exact error of every use of a cleared result, through bothas_cpp()specialisations. They also cover a result cleared when the next query is sent, a result collected bygc()without being cleared (the connection still runs queries and disconnects without the "results in use" warning), and the exact warning ofdbDisconnect()with results in use, after which the result still fetches and clears. In that test, the last result holds a read lock on a database file after the disconnect, and a write from a second connection fails untilgc()collects the result, so the test fails if the finalizer doesn't free a result afterdbDisconnect(). The last test has a handler that catches the busy guard's error, after which the result is cleared normally. The tests pass on #855 (7387832 and c352631) and on this branch, and eachtest_that()block passes on its own afterpkgload::load_all().devtools::test()passes except for the three errors intest-httpvfs.Rthatmainhas as well (#832, #837).A script of the finalizer cases lets the finalizer run after
dbClearResult()and afterdbDisconnect(), collects a connection before its uncleared result, and collects both together. Under valgrind's memcheck, the script,test-dbClearResult.Randtest-dbSendQuery.Rfound no errors and no definite or indirect leaks. They ran before the destructor became virtual. With the virtual destructor, the script,test-dbClearResult.R,test-dbSendQuery.R,test-dbBind.Randtest-read-ahead.Rrun without an AddressSanitizer report on an installed build, with the callr interrupt test included.Stack
Based on #855 (
claude/arrow-param-source), which is based on #830 and #850. The branch merges #855's latest head (c352631). Next in the new stack: vendoring nanoarrow.Review
The clean review found nothing above Low; both points are fixed in d608525 and e5b871d. See the accepted limitations.
https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
Generated by Claude Code