Repository navigation
Keep queries out of an open watch batch - #1637
Merged
Merged
Conversation
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.
Fixes #1616
A query that skips its own read of the disk (the TypeScript binding's queries, or any core caller with fresh reads off) took only the DB mutex, which a watch batch releases between statements while its transaction is open. The query then ran inside that transaction and could see one table updated and another not, or rows a foreign-key failure later rolled back. Fix: every query holds the index-still lock that watch batches and reconciles take, whether or not it reads the disk first (
DirSQL::refreshinpackages/rust/src/lib.rs).The CLI server's queries already wait on that lock since #1577 (they reconcile first), so the issue's server repros pass on
main;watch_batch_isolation_e2e.rskeeps them as a regression guard. The red proof iswatch_batch_isolation.rs, which queries mid-batch with fresh reads off.Red run (test commit 67c2a59): https://github.com/thekevinscott/dirsql/actions/runs/41916391931 --
Integration testsandWindows testsfail on exactly the new assertions:torn read: [{"na": Integer(2), "nb": Integer(1)}]andread rows the batch rolled back([c1]vs[c1, orphan]).Hand check with the release binary: the issue's torn repro answers
{"na":2,"nb":2}25/25; the dirty repro never returnsc2(the query reports the foreign-key violation instead, from its own read of the disk).E2E Verification
packages/python/e2e-attestations/<branch>.jsonreceipt written ifpackages/pythonchanged (just e2e-attest-python)packages/ts/e2e-attestations/<branch>.jsonreceipt written ifpackages/tschanged (just e2e-attest-ts)cargo test -p dirsql --features cli --tests --no-fail-fast(all pass)testing-conventions e2e attest 'uv run python -m pytest tests/e2e/fresh_declared_repros_test.py tests/e2e/query_contract_test.py tests/e2e/on_file_query_test.py tests/e2e/watch_speed_test.py tests/e2e/server_speed_test.py -x -q'testing-conventions e2e attest 'pnpm exec vitest run --dir tests/e2e fresh-declared-repros query-contract fanout'Changelog / Migrations
<root>/<pkg>/changelog.d/for each changed package (or:skip-changelogtrailer on a commit with reason)<root>/<pkg>/migrations.d/for each changed package (every subsection but Summary_None._when nothing breaks)