Conversation
RonLi79
force-pushed
the
fix/sqlite-write-patience-budget
branch
from
August 5, 2026 07:37
8734c16 to
c223673
Compare
Author
|
Rebased onto current |
This was referenced Aug 17, 2026
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.
Summary
Make
_execute_write()'s application-levelpatience_sbudget authoritative for SQLite write-lock acquisition.SessionDBkeeps the existing 1-second SQLite timeout for direct connection operations. DuringBEGIN IMMEDIATE, it now snapshotsPRAGMA busy_timeout, temporarily sets it to0, and restores the original value infinally. The randomized application retry loop therefore owns the complete wall-clock budget without leaking a fail-fast timeout to later connection users.Root cause
The writer connection is opened with a native SQLite busy timeout, while some application write classes use a shorter patience budget (notably 0.5 seconds for S1 activity writes).
BEGIN IMMEDIATEcould block inside SQLite's busy handler before_execute_write()regained control to check its deadline. The configured application budget was therefore not end-to-end enforceable.Changes
PRAGMA busy_timeoutaround write-lock acquisition.busy_timeout=0only forBEGIN IMMEDIATE, so lock contention fails fast into the existing deadline-bounded jitter loop.Verification
Fresh evidence on rebased commit
c22367383:15 passed—tests/state/test_write_lock_patience.pyplustests/gateway/test_watchdog_review_76354.py40 passed— completetests/stateplus the gateway watchdog regressionruff check hermes_state.py tests/state/test_write_lock_patience.py— cleanpy_compilefor implementation and test — cleangit diff --check upstream/main...HEAD— cleanbusy_timeout=73msis restored after both success and lock exhaustionThe pre-fix release candidate reproduced the short-budget failures at roughly 3.7–4.1 seconds despite a 0.5-second budget. The patched snapshot keeps the existing retry/error semantics while enforcing the configured wall-clock deadline.
Independent review
Read-only diff review with Codex
gpt-5.3-codex-spark: APPROVE, no blockers. Claude Fable was attempted first but its OAuth session was expired; no Fable verdict is claimed.