Repository navigation
Run queries on reader connections once one query has waited for another - #1780
Open
thekevinbot wants to merge 5 commits into
Open
thekevinbot wants to merge 5 commits into
thekevinbot wants to merge 5 commits into
Conversation
…runs after one overlap
thekevinbot
marked this pull request as ready for review
November 20, 2026 19:54
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.
Part of #1754 (PR 2 of 3; PR 3 adds the Node repro, the docs and
Fixes #1754).A
DirSQLinstance now answers queries concurrently after the first overlap, usingDb::promote()andDb::reader()from #1761:promote()before its statement. It holds the index, so watch batches and queries arriving during the copy wait for it. If the copy fails, queries stay on the writer.Db::may_call_batched, case-insensitive) holds a lock while it runs on a reader, because those workers gather one statement's arguments at a time.--persist/Db::open) follows the same trigger.promote()is a no-op there, since it is already a WAL file.The Rust repro is
packages/rust/tests/concurrent_queries.rs. After one overlap, a cheap query returns while a slow query runs. A watch batch also lands mid-query, and the slow query does not read it.Manual exercise
Release
dirsql server -c .dirsql.tomlover 8 JSON files, withSQLITE_TMPDIRset to a scratch directory. Each round sent a ~1.9 s query overPOST /queryand, 0.5 s later, acount(*):dirsql-<pid>-0.db,-wal,-shmA file written afterwards appeared through the watcher (
[{"n":9}]). After SIGTERM the temp dir was empty.Red: job 136443265863 (commit c2c856c, test only):
concurrent_queries.rs:88"a cheap query must be answered while a slow query runs once one overlap has been waited out" and:104"a watch batch must land while a slow query runs once one overlap has been waited out".E2E Verification
watch_speed_test(median 1.117x, spread 70%) while the host load average was 16. An interleaved A/B on the same host showed main failing the same bar (main medians 0.94-1.44, branch 1.01-1.36). The watch path gains only an atomic swap per batch until the first overlap.cargo test --workspace --features cli --no-fail-fastpass, exceptnon_utf8_names/non_utf8_names_e2e, which fail identically on main on this host (ZFSutf8only, os error 84)packages/python/e2e-attestations/<branch>.jsonreceipt written (just e2e-attest-python)packages/ts/e2e-attestations/<branch>.jsonreceipt written (just e2e-attest-ts)just e2e-attest-ts,just e2e-attest-python(twice),cargo test --workspace --features cli --no-fail-fast, at 0aa6c04 (final code; the later merge of main touched one test file only)Changelog / Migrations
packages/rust/changelog.d/packages/rust/migrations.d/