Skip to content

fix(sqlite): address Action Audit WAL contention and bounded Session recovery - #1457

Draft
twincelin-bot wants to merge 1 commit into
yyjeqhc:mainfrom
twincelin-bot:fix/upstream-sqlite-contention
Draft

twincelin-bot wants to merge 1 commit into
yyjeqhc:mainfrom
twincelin-bot:fix/upstream-sqlite-contention

Conversation

@twincelin-bot

Copy link
Copy Markdown

Summary

Related to #1456; follow-up to the merged Session WAL reservation fix in #1452 (which closed #1451). This draft is for design feedback, not a request to merge yet.

  • Reserve the Action Audit writer before window inventory repair to avoid a deferred read-to-write snapshot upgrade.
  • Bound retries for SQLite BUSY/LOCKED at transaction acquisition, with 100/200 ms backoff. Do not retry a transaction after a commit error.
  • Schedule up to two automatic retries (250/500 ms backoff) for a pending Session generation when acquisition contention persists, even without a new mutation notification. Retain failure observations and revision fences.
  • Add four concurrent-write and recovery regression tests; retain the upstream deterministic WAL regression.

Evidence

Issue #1456 contains redacted runtime observations and an isolated SQL-level reproduction. The remaining audit risk on current unpatched main is inferred from source and the SQL fixture, not a confirmed production reproduction on that revision. Historical failures cannot all be attributed to this mechanism.

Validation

Base: 13e4e1840cc8af52b6f2d109cc98513c8c145274.

cargo test --locked -p webcodex-store -p webcodex-workflow-session --lib -- --test-threads=2 on isolated Linux fixtures:

Module Passed Failed Ignored
webcodex-store 336 0 4
webcodex-workflow-session 306 0 10
Total 642 0 14

The four new focused tests also passed separately (not counted twice). The upstream WAL regression passed. git diff --check passed.

Limitations and review questions

  • Full server E2E, rustfmt verification, other platforms, and ignored tests have not been validated for this candidate. No production deployment has been performed.
  • The existing SQLite busy timeout applies to each acquisition attempt, so worst-case latency can grow. Backoff currently sleeps the worker thread, and the Session retry decision uses an error-message prefix derived from a typed WouldBlock error. Feedback on a typed internal error and interruptible scheduling would be welcome.
  • Would maintainers prefer splitting the audit-only fix from the retry/recovery policy? This draft intentionally leaves that decision open.

Prepared with coding-agent assistance and reviewed against the focused module test results. No private environment logs or credentials are included.

…sions

Reserve audit write transactions before inventory reads, bound retries for transient lock contention, and retry pending session persistence without requiring a new mutation. Add concurrent-write and recovery regression tests.
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.

[Bug / fix proposal] Workflow Session WAL write transaction can fail with database is locked during concurrent audit writes

1 participant