fix(state): proactively skip WAL journal mode on BTRFS filesystems (#30846)#31586
Open
Tranquil-Flow wants to merge 2 commits into
Open
fix(state): proactively skip WAL journal mode on BTRFS filesystems (#30846)#31586Tranquil-Flow wants to merge 2 commits into
Tranquil-Flow wants to merge 2 commits into
Conversation
Contributor
|
Nice approach. Proactive BTRFS detection via /proc/self/mountinfo is much cleaner than waiting for silent corruption and debugging backwards. The long-to-shortest-mount-path matching handles bind mounts correctly, and gating on /proc/self/mountinfo existence keeps it a no-op on macOS/Windows without needing explicit platform checks. I recently worked on the kanban WAL lifecycle (#31130 -- WAL fd leak on connect/close cycles) and this BTRFS edge case is a different class of the same 'WAL is great until your filesystem does something unexpected' problem. The kanban_db.py hunk here is minimal and surgical. |
46cd282 to
33eca0c
Compare
…ousResearch#30846) BTRFS Copy-on-Write can modify disk blocks after WAL records them, producing silent database corruption. This change adds proactive BTRFS detection via /proc/self/mountinfo (Linux-only) and skips WAL entirely on BTRFS, falling back to DELETE journal mode. - Add _is_on_btrfs() helper that parses /proc/self/mountinfo - Update apply_wal_with_fallback() to accept optional db_path and check BTRFS before attempting PRAGMA journal_mode=WAL - Pass db_path from SessionDB, kanban_db, api_server, and holographic memory store callers - Add regression tests for BTRFS detection and proactive WAL skip
33eca0c to
dc55360
Compare
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
SQLite WAL journal mode is incompatible with BTRFS Copy-on-Write. The existing exception-based fallback (catching
OperationalError) is too late — by the time SQLite raises, COW may have already corrupted WAL records. Users on BTRFS get persistentdisk I/O errorwithout understanding the root cause.Fix
Proactive BTRFS detection via
/proc/self/mountinfo(Linux only).apply_wal_with_fallback()now accepts an optionaldb_pathparameter. If the path resides on BTRFS, WAL is skipped entirely — before any pragma is executed — with a clear warning directing users tochattr +C.hermes_state.py— +81:_is_on_btrfs(),_decode_mountinfo_path(), proactive skip inapply_wal_with_fallback()db_path=argument (2 chars each):gateway/platforms/api_server.py,hermes_cli/kanban_db.py,plugins/memory/holographic/store.pydb_path=Nonepreserves full backward compatibilityMountinfo parsing handles edge cases
-separator (not fixed field index)\040→ space) for mount points with spacesos.path.commonpath()not rawstartswith()—/homebrewwon't match/homeTests
9 regression tests: mountinfo parser shape, path boundary guard, octal escape decoding, proactive WAL skip, warning deduplication, backward-compatible
db_path=None, post-fallback DB writability, non-Linux no-op, API contract.Fail-without-fix: reverting to upstream
hermes_state.py→ 9/9 BTRFS tests fail.Competitor check
Adjacent WAL PRs (#30700, #30823, #31294, #31014, #30654, #31130) address related SQLite/WAL issues but none implements proactive BTRFS filesystem detection for #30846.
Closes #30846