fix(kanban): skip redundant WAL pragma on already-WAL connections#32489
Closed
steveonjava wants to merge 4 commits into
Closed
fix(kanban): skip redundant WAL pragma on already-WAL connections#32489steveonjava wants to merge 4 commits into
steveonjava wants to merge 4 commits into
Conversation
Format-only pass on lines outside the feature scope. Separates pre-existing whitespace drift from the WAL probe fix to keep the feature diff reviewable.
…te.py Format-only pass on pre-existing lines, separate from the WAL probe feature commit.
apply_wal_with_fallback() issued PRAGMA journal_mode=WAL on every call,
including connections to DBs already in WAL mode. This triggered the WAL
init code path, causing SQLite to acquire EXCLUSIVE, checkpoint, and unlink
kanban.db-{wal,shm}. Other open connections received (deleted) FDs and
raised sqlite3.OperationalError: disk I/O error.
Add a cheap read probe (PRAGMA journal_mode, no flock/checkpoint/unlink)
before the set-pragma path. If already wal, return early. The set-pragma
and DELETE fallback paths are unchanged.
Closes NousResearch#31158. Addresses root cause that PRs NousResearch#32226 and NousResearch#32322 attempted
via connection-sharing/caching approaches.
This was referenced May 26, 2026
Closed
Closed
Contributor
Author
|
Bundled into #32857 for batch review. This draft remains open as a cherry-pick fallback if maintainers prefer surgical landing. |
Collaborator
|
Merged via #33482 (commit dc98314). Cherry-picked with authorship preserved as part of the @steveonjava batch salvage from #32857. Thanks! |
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.
What does this PR do?
This fix adds a read-only
PRAGMA journal_modeprobe to skip redundant WAL initialization on already-WAL connections inapply_wal_with_fallback(). It does not affect any security boundary: no new user-facing surface, no credential or path handling, no trust-model change. Per the upstream SECURITY.md (scope: shell injection, prompt injection, path traversal, privilege escalation), this change is out of scope for private advisory and appropriate for a public PR.Root cause:
apply_wal_with_fallback()unconditionally issuesPRAGMA journal_mode=WALon every connection, including connections to DBs already in WAL mode. This triggers the WAL-init code path and, under the_wal_init_flock(Bug H mitigation on fork), causes SQLite to acquire EXCLUSIVE, checkpoint, and unlinkkanban.db-{wal,shm}. Other still-open connections receive(deleted)FDs; subsequent PRAGMA calls raisesqlite3.OperationalError: disk I/O error.The fix: insert a cheap read probe (
PRAGMA journal_mode— read-only, no flock) before the set-pragma path. If alreadywal, return early. 99%+ of calls hit this fast path.Verification: Deployed on fork
local/runtimease147588e2. Live metrics: 0 EIO events over 9+ minutes vs ~1500/min pre-patch.Related Issue
Fixes #31158
Type of Change
Changes Made
hermes_state.py—apply_wal_with_fallback(): add early-return read probe for already-WAL connectionstests/test_hermes_state.pyand/ortests/hermes_cli/test_kanban_dispatcher_wal.py: regression + adversarial tests covering:How to Test
scripts/run_tests.sh— all 223 implementer tests + 7 adversarial verifier tests passconnect()cycles per second per board), observe:sqlite3.OperationalError: disk I/O errorraised fromapply_wal_with_fallback(deleted)FD accumulation (check via/proc/self/fdon Linux orfcntlprobe on macOS)_log_wal_fallback_oncededup still fires once per process on actual fallback (not on early-return)Checklist
Code
fix(kanban): ...,chore(release): ...pytest tests/ -qand all tests pass (223 implementer + 7 adversarial = 230 total)Documentation & Housekeeping
cli-config.yaml.example— or N/A (no config keys added)CONTRIBUTING.mdorAGENTS.md— or N/A (no architecture change)sqlite3.Connection.execute()only (no POSIX-specific syscalls);/proc/self/fdprobe guarded with@pytest.mark.skipif(sys.platform != "linux");scripts/check-windows-footguns.pypassesRelated Work
This PR addresses the root cause; PR #31973 handles the symptom:
nuch1011) removes EIO from_WAL_INCOMPAT_MARKERSso transient EIO doesn't trigger fallback to DELETE. That's a necessary safety check, but doesn't prevent the unlink-and-EIO cycle.Cross-references: