SessionDB & Concurrency

SessionDB High-Concurrency Write Lock & Jitter Retry Avoidance

Decrypting hermes_state.py SQLite transaction retry & WAL mode degradation details
Database Concurrency Write Locks
📊 Figure 4-1-1: Multi-Agent Concurrent Transaction Conflict, OperationalError Capture & Jitter Backoff Retry UML Sequence

💾 1. SQLite Concurrency Collision Avoidance Algorithm

In hermes_state.py, all agent session state is managed by SessionDB. Under large-scale concurrency, SQLite frequently throws OperationalError: database is locked. The system uses a Jitter Retry avoidance algorithm to self-heal this error, sleeping a random jitter duration to scatter lock contention timing.

DB Table Relationship ER Diagram
📊 Figure 4-1-2: SessionDB Core Data Tables, Foreign Key Relationships & Index Structure ER Diagram

📂 2. WAL Mode Degradation & writable_schema Online Self-Healing

  1. NFS/Mount Points WAL Auto-Degradation (apply_wal_with_fallback): The system attempts to set WAL at startup. On error, it immediately degrades to regular transactions, ensuring the agent can run normally.
  2. Online Schema Update Tolerance: When upgrading Hermes and discovering that new versions add table fields causing old DB errors, SessionDB automatically executes ALTER TABLE after catching the error, performing online hot updates at runtime.