Skip to content

test(datastore): Close keeps every write acknowledged to racing writers - #840

Open
TimeToBuildBob wants to merge 2 commits into
ActivityWatch:masterfrom
TimeToBuildBob:test/datastore-close-durability
Open

TimeToBuildBob wants to merge 2 commits into
ActivityWatch:masterfrom
TimeToBuildBob:test/datastore-close-durability

Conversation

@TimeToBuildBob

Copy link
Copy Markdown
Contributor

This adds an integration test for Datastore::close racing 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:

  • Each writer gets one acknowledged write, then all four race set_key_value against close().
  • close() must return within 5 s, so active writers cannot starve it.
  • An independent open_reader connection must see each writer's last acknowledged value.
  • The closed worker must reject later requests.

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

  • Passes 10/10 locally, about 0.1 s per run.
  • Mutation check: with the worker's final commit on Close swapped for a rollback, the test fails because the acknowledged key is missing after Close. Reverted.
  • cargo fmt and cargo clippy --test close_durability clean. Test-only change, no production code touched.

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
@greptile-apps

greptile-apps Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The PR appears safe to merge; the earlier unbounded writer-wait issue is fixed.

Summary

Adds a file-backed test that races four writers against Datastore::close across three rounds.

  • The datastore suite checks that Close keeps acknowledged writes.

Reviews (2) · Last reviewed commit: "test(datastore): bound writer completion..." · Reviewed by Greptile

Comment thread aw-datastore/tests/close_durability.rs Resolved
@codecov

codecov Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.66667% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.77%. Comparing base (656f3c9) to head (d7217b8).
⚠️ Report is 225 commits behind head on master.

Files with missing lines Patch % Lines
aw-datastore/tests/close_durability.rs 96.66% 2 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Git-Session-Id: 25d5f566-67ab-5baf-bdb1-e98d6a142cfa
@TimeToBuildBob

Copy link
Copy Markdown
Contributor Author

@greptileai review

@TimeToBuildBob

Copy link
Copy Markdown
Contributor Author

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.

@TimeToBuildBob

TimeToBuildBob commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 AI code review

Adds 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 findings

Confidence 5/5

✅ No findings. The diff looks correct to me on this pass.

Files changed (1) — the diff as I read it
  • aw-datastore/tests/close_durability.rs — Adds close_keeps_every_acknowledged_write_from_racing_writers with synchronized writers, completion timeouts, persisted-value assertions, and a post-close request rejection assertion.

Reviewed d7217b822fcf · panel: codex:gpt-6.1-sol · subscription engine · 24s · about this reviewer

Maintainer commands

@TimeToBuildBob review (own line) — fresh review · @TimeToBuildBob fix — a worker acts on the findings. Once per comment; 👀 = received.

Outage coverage: 1-pass, not merge evidence. Subscription review supplied findings while full consensus capacity was unavailable. The consensus merge gate remains unsatisfied.

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.

1 participant