Repository navigation
test(datastore): Close keeps every write acknowledged to racing writers - #840
TimeToBuildBob wants to merge 2 commits into
Conversation
aw-tauri closes the shared datastore at shutdown while tray and API clones may still be writing. Race four writers against Close on a real SQLite file and check with an independent reader that each writer's last acknowledged value survived, that Close is not starved, and that the closed worker rejects requests. Git-Session-Id: 290bb976-cfe5-490b-a9de-ae87ca85565a
[Low impact] The PR appears safe to merge; the earlier unbounded writer-wait issue is fixed. SummaryAdds a file-backed test that races four writers against
Reviews (2) · Last reviewed commit: "test(datastore): bound writer completion..." · Reviewed by Greptile |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #840 +/- ##
===========================================
+ Coverage 70.81% 85.77% +14.95%
===========================================
Files 51 90 +39
Lines 2916 12926 +10010
===========================================
+ Hits 2065 11087 +9022
- Misses 851 1839 +988 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Git-Session-Id: 25d5f566-67ab-5baf-bdb1-e98d6a142cfa
|
@greptileai review |
|
CI-green and mergeable (Greptile 5/5) — waiting only on a maintainer click. This PR is ready to merge, but the bot has pull-only access to this repo and can't self-merge — surfacing it here so it isn't lost. The monitoring loop will stop re-flagging it now that this note is posted. |
🤖 AI code reviewAdds an integration test that races four cloned Datastore writers against close() across three temporary SQLite databases. The test bounds completion time, reads each writer's last acknowledged value through open_reader(), and checks that the closed datastore rejects subsequent requests. Safe to merge — no P0/P1 findingsConfidence 5/5 ✅ No findings. The diff looks correct to me on this pass. Files changed (1) — the diff as I read it
Reviewed Maintainer commands
|
This adds an integration test for
Datastore::closeracing active writers.aw-tauri closes the server's shared datastore at shutdown while tray and settings-API clones may still be writing. ActivityWatch/aw-tauri#302 relied on a one-off probe for this (ten databases, eight writers, 80 assertions). That probe only ever lived in
/tmp, so a future change to the worker's Close/commit path would have no regression signal.aw-datastore/tests/close_durability.rs, run for 3 rounds × 4 writers on a real SQLite file in a tempdir:set_key_valueagainstclose().close()must return within 5 s, so active writers cannot starve it.open_readerconnection must see each writer's last acknowledged value.Limit: Close does not drain in-flight HTTP handlers (noted on the aw-tauri#302 review). This test covers requests to the worker only.
Verification
cargo fmtandcargo clippy --test close_durabilityclean. Test-only change, no production code touched.