fix(state): throttle repeated VACUUM rewrites (salvage #67351) - #76839
Merged
kshitijk4poor merged 2 commits intoAug 2, 2026
Merged
Conversation
This was referenced Aug 2, 2026
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.
Salvages #67351 by @nkreadly07 — both commits cherry-picked to preserve authorship, retargeted onto current main (the original branch was ~3.9K commits behind and its
hermes_cli/config.pyhunk targetedDEFAULT_CONFIGbefore it moved tohermes_cli/config_defaults.pyin 1fe0611).Context — what this fixes, for whom
Users with
sessions.auto_prune: trueand a largestate.dbpay a repeated startup stall: once a prune frees any rows (pruned > 0), main's gate (if vacuum and pruned > 0:— hermes_state.py:8574) runs a fullVACUUMon every maintenance sweep. On a multi-GB DB with FTS5 shadow tables, VACUUM holds an exclusive lock for the entire rewrite — seconds per 100MB, so tens of seconds of blocked writes at CLI/gateway startup, repeating day after day even though a recent VACUUM already reclaimed the space.What the fix does (from #67351, kept verbatim)
min_vacuum_interval_days(default 30) tomaybe_auto_prune_and_vacuum: after a successful VACUUM, stampslast_vacuuminstate_meta; subsequent sweeps skip VACUUM until the interval elapses. Pruning itself keeps its normal cadence — SQLite reuses freed pages meanwhile.last_vacuummeta falls through to "vacuum due" (test-covered).cli.py_run_state_db_auto_maintenance,gateway/run.pymaintenance hook), config default, and EN+zh docs.Retargeting done in this salvage (no behavior change vs the original)
hermes_cli/config_defaults.py(whereDEFAULT_CONFIGlives now); verifiedhermes_cli.config.DEFAULT_CONFIGre-export picks it up.Verification
tests/test_hermes_state.py+tests/test_session_vacuum_config.py: 146 passed on current main (includes the PR's 4 throttle tests: success-stamp, recent-skip, interval-expiry retry, failed-vacuum retry — plus the config-default and CLI-forwarding tests)hermes_state.pyto main makes all 4 throttle tests fail; restoring goes greenCloses #67351 (superseded by this salvage — original author credited via cherry-pick authorship).