Skip to content

fix: Time out stalled HTTP VFS transfers - #842

Open
krlmlr wants to merge 2 commits into
mainfrom
claude/httpvfs-timeouts
Open

krlmlr wants to merge 2 commits into
mainfrom
claude/httpvfs-timeouts

Conversation

@krlmlr

@krlmlr krlmlr commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

The HTTP VFS set no libcurl limits, so a server that accepted a connection and never answered blocked R, and with it R CMD check, indefinitely. Every handle now gives up connecting after RSQLITE_HTTP_CONNECT_TIMEOUT seconds (default 30) and aborts a transfer that receives less than one byte per second for RSQLITE_HTTP_STALL_TIMEOUT seconds (default 60). Only whole numbers of seconds of at least 1 are honored, in any notation R writes such as 1e+05; larger values are capped at 2147483 seconds (and libcurl 8.19.0 or later caps the stall timeout at 65535 seconds itself), and anything else uses the default, as documented in ?sqliteHttpConfig, which now also says that these settings are read each time a remote database is opened. A handle whose limits cannot be set is not used, and the open then fails with "unable to open database file", a query with "disk I/O error".

Opening used to probe the server up to four times, since the file size and the header read each sent a HEAD and a GET. A failed probe is now not repeated within one open, and a HEAD that cannot connect or times out skips the GET, so a silent server costs one timeout. A stall during the open reports "unable to open database file", during a query "disk I/O error".

The test server can now accept requests without answering them. A new test opens such a server with RSQLITE_HTTP_STALL_TIMEOUT=1, expects the open to fail within seconds, and checks that the server received exactly one request, the HEAD, so a refused connection cannot pass for a stall.

An interrupt still cannot abort a transfer here: Ctrl-C takes effect only once the stall timeout ends the transfer. #843 adds that, and completes the wording on aborted transfers in the documentation.

Part of the stack that splits the earlier combined #832 into scoped pull requests, as the maintainer asked there. This code was reviewed as part of #832, in three clean reviews of the combined version; a clean review of the split found one Low finding here, in the documentation, fixed in c3b58ae, and what remains is under Accepted limitations.

https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE


Generated by Claude Code

krlmlr commented Nov 11, 2026

Copy link
Copy Markdown
Member Author

Accepted limitations

The clean review of the split found nothing above Low. Its finding 3, the documentation that said these settings are read on the first open in the process, is fixed in c3b58ae: they are read each time a remote database is opened. This remains from the reviews of the combined version:

  • tests/testthat/test-httpvfs.R#L94: the request count of the stall test proves that the HEAD reached a live server, but cannot show that the GET is skipped after the HEAD times out, since the test server stops reading requests while it stalls. The clean review of the split confirmed the skip with a threaded server that logs every request. Relevance: low; reviewer's confidence: high.

Generated by Claude Code

@krlmlr
krlmlr force-pushed the claude/httpvfs-timeouts branch from c3b58ae to 86d031b Compare November 13, 2026 15:42
@krlmlr krlmlr mentioned this pull request Nov 27, 2026
16 of 22 tasks
Base automatically changed from claude/httpvfs-remote-extensions to main November 27, 2026 20:33
The HTTP VFS set no libcurl limits,
so a server that accepted a connection and never answered blocked R indefinitely,
and with it any `R CMD check` that runs the HTTP VFS tests.
Every handle now gives up connecting after `RSQLITE_HTTP_CONNECT_TIMEOUT` seconds (default 30),
and aborts a transfer that receives less than one byte per second for `RSQLITE_HTTP_STALL_TIMEOUT` seconds (default 60).
The aborted transfer fails the open with "unable to open database file" and a query with "disk I/O error".

Only whole numbers of seconds of at least 1 are honored, in any notation R writes such as `1e+05`,
and values above 2147483 seconds, the largest connect timeout libcurl accepts, are capped.
Anything else, such as `0`, `2.9`, `inf` or `5abc`, uses the default, as `?sqliteHttpConfig` now documents,
along with the cap of 65535 seconds that libcurl 8.19.0 or later sets on the stall timeout itself.
A handle whose limits cannot be set is not used, since it could block forever,
and the open then fails with "unable to open database file", a query with "disk I/O error".

Opening probed the server up to four times,
because the file size and the header read each start a HEAD and a GET request.
A failed probe is no longer repeated within one open,
and a HEAD request that cannot connect or times out skips the GET,
so a silent server costs one timeout.

The test server can now accept requests without ever answering them.
A new test opens such a server with a one-second stall timeout,
and checks that the server received exactly one request, the HEAD,
so a refused connection cannot pass for a stall.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
The documentation said the values are read on the first open in the process.
They are in fact read each time a remote database is opened,
in httpOpen() and in the metadata probe,
which includes RSQLITE_HTTP_CONNECT_TIMEOUT and RSQLITE_HTTP_STALL_TIMEOUT.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
@krlmlr

krlmlr commented Nov 27, 2026

Copy link
Copy Markdown
Member Author

@davidrsch: This and the next PR change the extension's code. What do you think? Do we need this?

@davidrsch

Copy link
Copy Markdown
Contributor

Thanks for asking. #842: yes. Without a timeout, a server that never answers hangs R and R CMD check. The libcurl limits fix that cleanly.

#843: I'd rather not as is. It makes http.c depend on R headers, and so far it only needs SQLite and libcurl. With #842 a stalled transfer already ends on its own. If we want Ctrl-C, the R check could live on the RSQLite side and be passed in as an optional callback.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants