Skip to content

fix(session): use PASSIVE wal checkpoint on close and pre-VACUUM - #80346

Closed
webtecnica wants to merge 1 commit into
NousResearch:mainfrom
webtecnica:fix/80255-wal-passive-close
Closed

fix(session): use PASSIVE wal checkpoint on close and pre-VACUUM#80346
webtecnica wants to merge 1 commit into
NousResearch:mainfrom
webtecnica:fix/80255-wal-passive-close

Conversation

@webtecnica

Copy link
Copy Markdown
Contributor

Summary

SessionDB.close() and the pre-VACUUM path still used PRAGMA wal_checkpoint(TRUNCATE) — the same cross-linked b-tree corruption class fixed for the periodic path in #45383 (c2a3b9ce5, "use PASSIVE checkpoint for periodic WAL flush"). The shutdown path is the one most likely to be interrupted mid-checkpoint.

Root Cause

The #45383 fix converted only _try_wal_checkpoint() to PASSIVE. Two other wal_checkpoint(TRUNCATE) call sites remained: close() (L2752) and the pre-VACUUM flush (L9041).

Change

  • hermes_state.py: both remaining sites now use PRAGMA wal_checkpoint(PASSIVE); log messages and docstrings updated to match (zero TRUNCATE remains — all 3 paths use PASSIVE).
  • tests/test_wal_checkpoint_strategy.py: TestCloseUsesTruncateTestCloseUsesPassive (spy asserts 1×PASSIVE, 0×TRUNCATE on close) + new TestVacuumUsesPassive covering the pre-VACUUM site.
  • tests/test_hermes_state.py: test_writable_close_retains_truncate_checkpoint → asserts pragma wal_checkpoint(passive).

Verification

  • tests/test_wal_checkpoint_strategy.py + tests/test_hermes_state.py: 194 passed.

Closes #80255

@alt-glitch alt-glitch added type/bug Something isn't working comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P2 Medium — degraded but workaround exists sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state labels Aug 6, 2026
@webtecnica

Copy link
Copy Markdown
Contributor Author

Closing in favor of #84277 by @lkz-de — the superset fix: converts all THREE remaining TRUNCATE sites (close, pre-VACUUM, and the post-optimize-storage checkpoint in hermes_state_search.py that this PR missed) plus production corruption evidence. Glad the original identification on #80255 carried; the fuller fix deserves the merge. Thanks for the credit.

@webtecnica webtecnica closed this Aug 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P2 Medium — degraded but workaround exists sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

close() still uses TRUNCATE checkpoint — #45383 recurs on the shutdown path

2 participants