IssueRaiser

RFC: Pluggable SessionDB Provider — PostgreSQL, MySQL, and Beyond

# RFC: Pluggable SessionDB Provider — PostgreSQL, MySQL, and Beyond **Tracking Issue: (to be created)** --- ## 1. Problem Statement ### 1.1 The Hot-Update Death Spiral When running Hermes and simultaneously updating it (`git pull`/`hermes update`), the shared `state.db` SQLite file inevitably suffers: 1. **Process A (old version)** has an open SQLite connection with WAL mode, mid-write 2. **Process B (new version)** starts, tries to connect → `database is locked` 3. **WAL checkpoint** is interrupted mid-flight by SIGTERM 4. **Result**: `state.db` is corrupted, `session_search` permanently broken until manual recovery This is **not** a theoretical edge case — it's the normal development workflow for anyone running Hermes from source. ### 1.2 SQLite's Fundamental Limits in Multi-Process Hermes Hermes runs multiple processes sharing one `state.db`: | Process | Writes | Reads | |---------|--------|-------| | CLI session | ✅ Every turn | ✅ session_search | | Gateway | ✅ Every turn | ✅ session_search | | Cron scheduler | ✅ Job results | ✅ Job config | | TUI | ✅ Session list | ✅ Session list | | API server | ✅ Session creation | ✅ Query | SQLite WAL mode allows concurrent **reads**, but **writes** are serialized at the OS level. Even with the current jitter-retry + `BEGIN IMMEDIATE` design, contention causes: - **#3139** (closed, fixed): `session_search` permanently disabled on lock timeout - **#5563** (open, P1): `state.db` corruption during normal use - **#860** (close

Posted by DoubleDD on May 11, 2026, 10:08 AM

Tags

Related issues

Raise real-world problems, find people facing the same issue, and discuss solutions.2,000 issues0 comments

reliability (Sysadmin)

RFC: Pluggable SessionDB Provider — PostgreSQL, MySQL, and Beyond

DoubleDDMay 11, 2026, 10:08 AM

# RFC: Pluggable SessionDB Provider — PostgreSQL, MySQL, and Beyond **Tracking Issue: (to be created)** --- ## 1. Problem Statement ### 1.1 The Hot-Update Death Spiral When running Hermes and simultaneously updating it (`git pull`/`hermes update`), the shared `state.db` SQLite file inevitably suffers: 1. **Process A (old version)** has an open SQLite connection with WAL mode, mid-write 2. **Process B (new version)** starts, tries to connect → `database is locked` 3. **WAL checkpoint** is interrupted mid-flight by SIGTERM 4. **Result**: `state.db` is corrupted, `session_search` permanently broken until manual recovery This is **not** a theoretical edge case — it's the normal development workflow for anyone running Hermes from source. ### 1.2 SQLite's Fundamental Limits in Multi-Process Hermes Hermes runs multiple processes sharing one `state.db`: | Process | Writes | Reads | |---------|--------|-------| | CLI session | ✅ Every turn | ✅ session_search | | Gateway | ✅ Every turn | ✅ session_search | | Cron scheduler | ✅ Job results | ✅ Job config | | TUI | ✅ Session list | ✅ Session list | | API server | ✅ Session creation | ✅ Query | SQLite WAL mode allows concurrent **reads**, but **writes** are serialized at the OS level. Even with the current jitter-retry + `BEGIN IMMEDIATE` design, contention causes: - **#3139** (closed, fixed): `session_search` permanently disabled on lock timeout - **#5563** (open, P1): `state.db` corruption during normal use - **#860** (close

Comments (0)

No comments yet. Start the discussion.

Comment on this issue