fix(state): reconnect self-heal when state.db is replaced under a live connection - #84885
Merged
Conversation
…try transient EIO on journal-mode probe Salvaged remainder of PR #82280 (state.db hardening rollup): - Runtime connection corruption: a sibling process replacing/truncating the backing file breaks the live write connection — every subsequent write raises 'file is not a database' and the gateway wedges permanently (messages pile up in memory). Add a bounded one-shot reconnect on the write path: close the broken connection, reopen the DB file (re-running WAL activation + schema reconciliation), retry the failed write once. - _on_disk_journal_mode: retry transient 'disk i/o error' (virtualized block devices) a few times before returning None, so a one-shot EIO doesn't push callers onto the fail-closed unknown-mode branch. The rollup's write-lock machinery, checkpoint-strategy changes, and repair serialization are intentionally NOT included — superseded by PRs #84277 and #69609, or wrong-direction per the POSIX lock-cancellation findings (#71724 lineage).
Contributor
૮ >ﻌ< ა ci reviewran on 9dcb6e8 — chore: AUTHOR_MAP for zhouou6@users.noreply.github.com → sha
|
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
state.dbwrites now survive the backing file being replaced under a live connection: a bounded one-shot reconnect self-heal fires on thefile is not a databaseerror class (previously a permanent wedge until process restart), and transient EIO during journal-mode probing is retried 4× instead of pushing callers onto the fail-closed unknown-mode branch.Salvaged remainder of #82280 by @shali10 (authorship preserved on the salvaged hunks). The rest of that rollup is deliberately NOT carried:
.write.lockflock around every write transaction — SQLite'sBEGIN IMMEDIATE+ busy handling + the existing jittered patience loop already serialize cross-process writers; a blocking no-timeout flock held across whole transactions defeats the patience/deadline semantics and adds a stale-lock surface. Also not carried:require_wal=True(would brick NFS/SMB installs that deliberately run degraded), the FK self-heal that silently resurrects deleted sessions, and per-site NUL guards main already fixed at the choke point.Changes
hermes_state.py:_is_not_a_database_error()helper;_notadb_reconnect_attemptedone-shot flag + reconnect branch in_execute_write+_reconnect_after_notadb()(mirrors_connect_and_init, keepsrequire_waldefault so NFS installs keep working);_on_disk_journal_modetransient-EIO retry (4 attempts, 50ms, None-on-final-failure preserved)tests/test_state_db_notadb_selfheal.py(9 tests: helper matching, healthy-file self-heal E2E, one-shot guard, failed-reconnect propagation, EIO retry bounded/clears/fails-fast)Validation
Infographic
https://files.catbox.moe/lellbv.png