How-To Series · 2: Daily Driver

Session Storage Recovery

What to do when Hermes stops writing and says another process still holds an old copy of the session database's write-ahead log, and why nothing is lost.

After this videoYou can clear the retired write-ahead log refusal in three steps, avoid the moves that cause real data loss, and tell which files beside state.db to keep.

Hermes keeps every conversation for a profile in one SQLite file, state.db, with two sidecar files SQLite manages itself: state.db-wal (the write-ahead log) and state.db-shm. The gateway, the Desktop app, the dashboard, cron and CLI commands can all share it safely. Rewriting the store while another process is writing to it is not safe, so any process still holding the old copy of the log stops writing on purpose and every turn answers with the refusal message. The fix: quit every Hermes process on that profile (hermes gateway stop, quit the Desktop app, hermes dashboard --stop), run hermes doctor until it no longer lists a holder as PID N (command), then start one process first and send your message again. Do not run hermes doctor --fix while processes are running, do not delete state.db-wal or state.db-shm, do not copy state.db alone, and do not ask the agent to fix it. hermes sessions optimize, optimize-storage and prune now refuse while another process holds the database; --dry-run is never blocked and --force runs anyway. If everything is stopped and the gateway still refuses, inspect the file with hermes sessions recover --source ~/.hermes/state.db --inspect-only.

About these resources. Every command and file name in this video comes from the Session Storage Recovery doc. For how sessions work day to day, see the Sessions episode below.

New words here · Plain English

one sentence each · full glossary
state.dbThe one SQLite file per profile where Hermes keeps every conversation. The gateway, the Desktop app, the dashboard, cron and CLI commands all share it safely.
Write-ahead log (WAL)The state.db-wal file beside state.db. It holds committed conversations that are not yet in the main file, so deleting it is the one move that causes real data loss.
Retired WAL refusalWhen the session store is rewritten under a live writer, any Hermes process still holding the old log stops writing on purpose so nothing is lost. Quit every process, check hermes doctor, then start one.
Inspect-only recoveryhermes sessions recover --source ~/.hermes/state.db --inspect-only checks a possibly damaged session store without modifying it, and prints the next command if it is recoverable.

Sources · What this video distills

1 docs page · every command below traces to it
Primary guide
Session Storage Recovery
Read ↗

Commands shown · Copy and paste

each shows the source doc it came from
Step 1: stop the gateway (add -p <profile> for a named profile)from source ↗
hermes gateway stop
Step 1: stop the dashboardfrom source ↗
hermes dashboard --stop
Step 2: list any process still holding the retired logfrom source ↗
hermes doctor
Last resort: inspect the store without writing to itfrom source ↗
hermes sessions recover --source ~/.hermes/state.db --inspect-only

Going deeper · Related Hermes docs

further reading · not sources of facts shown above

Next in the series · Episodes that build on this