kshitijk4poor
db339f0051
fix(state): consolidate gateway SessionDB writers via process-wide shared registry
...
A gateway process opened state.db from ~12 call sites, each minting its
own writer connection, self._lock, close-time WAL checkpoint, and
token-writer thread. With N independent writers on one WAL file, one
connection's close-time checkpoint could race another's growth — the
lost/reordered-page-write signature across 11+ incidents (#90837 ).
Adds hermes_state_registry.py: a process-wide, per-path, refcounted
shared registry owning the writer boundary.
- acquire(path): same resolved path returns the same instance (one
writer connection, one lock, one token-writer thread) for every
long-lived in-process caller (gateway runner, SessionStore, per-agent
lazy recall, cron per-job, mirror, channel_directory, slash_commands,
shutdown_flush, session_search, react_to_message, delegate, mcp_serve,
auto_archive, tui_gateway).
- close() on a shared instance is a NO-OP — the registry owns the
lifecycle, so one caller's close can never tear down a writer other
callers still hold.
- Generation-aware retirement on inode change: a replaced state.db
RETIRES the live generation (never lent again) but keeps it alive for
existing holders; release is object-keyed so holders of the old
generation drain it independently of the new one. The old
generation's own write path still fails with the typed
StateDbReplacedError (existing protection, unchanged).
- Replacement-open failure leaves NO registry entry for the path —
the next acquire retries fresh, never hands out a closed stale object.
- All teardown runs OUTSIDE the registry lock: a final release's WAL
checkpoint can never stall acquisition for every state.db.
- close_shared_session_dbs() at gateway shutdown drains every
generation (live + retired) as the final safety net.
CLI one-shots, recovery flows, and read-only cross-profile opens keep
using SessionDB() directly with their own close() — only long-lived
in-process sites route through the registry.
References #90837 (root-cause tracker stays open: the #10 EOF signature
and the WAL-lifecycle A/B verdict remain under investigation there).
2026-09-01 20:55:35 +05:30
..
2026-08-31 16:28:21 +10:00
2026-08-31 11:47:16 -07:00
2026-08-24 23:50:23 -07:00
2026-08-30 05:16:19 -07:00
2026-08-21 21:53:11 +05:30
2026-09-01 02:14:35 -07:00
2026-08-27 20:53:02 -07:00
2026-08-23 03:57:47 -07:00
2026-08-19 22:56:14 -07:00
2026-08-31 01:04:11 -07:00
2026-08-31 01:04:11 -07:00
2026-08-31 01:04:11 -07:00
2026-08-31 01:04:11 -07:00
2026-08-31 01:04:11 -07:00
2026-08-31 01:04:11 -07:00
2026-08-27 07:33:36 -07:00
2026-08-31 01:04:11 -07:00
2026-08-20 19:56:01 -07:00
2026-08-29 07:25:17 -07:00
2026-08-16 01:51:10 -07:00
2026-08-27 17:21:26 +05:30
2026-08-21 22:33:45 +05:30
2026-08-21 22:54:04 +05:30
2026-08-21 22:33:45 +05:30
2026-08-21 22:33:45 +05:30
2026-08-21 22:33:45 +05:30
2026-08-29 20:03:48 +05:30
2026-08-31 10:06:34 -07:00
2026-08-31 07:28:30 -07:00
2026-08-31 09:05:41 -07:00
2026-08-31 09:05:41 -07:00
2026-08-31 07:30:44 -07:00
2026-08-31 20:57:30 +05:30
2026-08-31 09:49:30 -07:00
2026-08-20 19:56:01 -07:00
2026-08-30 19:52:43 -07:00
2026-08-29 07:25:17 -07:00
2026-08-31 09:57:13 -07:00
2026-08-27 12:42:38 +05:30
2026-08-31 12:21:01 -07:00
2026-08-31 01:04:11 -07:00
2026-08-26 09:59:17 -07:00
2026-08-22 16:45:00 -07:00
2026-08-22 18:05:26 -07:00
2026-08-14 21:47:16 -07:00
2026-08-27 20:39:11 +05:30
2026-08-14 21:47:16 -07:00
2026-08-29 19:13:00 -07:00
2026-08-26 04:49:39 -07:00
2026-08-26 04:49:39 -07:00
2026-08-22 14:55:04 +05:30
2026-08-29 07:25:17 -07:00
2026-08-16 01:55:51 -07:00
2026-08-31 06:28:25 -07:00
2026-08-27 07:33:36 -07:00
2026-08-31 10:06:34 -07:00
2026-08-20 15:31:21 +10:00
2026-08-31 10:54:58 -07:00
2026-08-15 14:20:27 -07:00
2026-08-29 20:03:48 +05:30
2026-08-29 20:57:55 -07:00
2026-08-31 12:04:10 -07:00
2026-08-18 16:08:29 -07:00
2026-08-21 19:11:55 -07:00
2026-08-18 15:04:45 -07:00
2026-08-28 11:45:19 -07:00
2026-08-28 11:45:19 -07:00
2026-08-28 11:45:19 -07:00
2026-08-31 01:04:11 -07:00
2026-08-31 01:04:11 -07:00
2026-08-31 01:04:11 -07:00
2026-08-30 22:19:06 -07:00
2026-08-31 01:04:11 -07:00
2026-08-31 01:04:11 -07:00
2026-08-30 20:39:58 -07:00
2026-08-30 22:19:06 -07:00
2026-08-31 01:04:11 -07:00
2026-08-31 09:57:13 -07:00
2026-08-20 15:31:21 +10:00
2026-08-26 15:31:36 -07:00
2026-08-26 10:25:33 -07:00
2026-08-31 09:56:54 -07:00
2026-08-16 01:50:44 -07:00
2026-08-18 16:08:29 -07:00
2026-08-27 22:06:17 +05:30
2026-08-17 15:12:13 +05:30
2026-08-25 13:25:48 +05:30
2026-08-16 19:54:42 -07:00
2026-09-01 20:55:35 +05:30
2026-08-31 10:06:34 -07:00
2026-08-16 01:49:53 -07:00
2026-08-29 19:13:00 -07:00
2026-08-30 05:16:10 -07:00
2026-08-26 04:49:39 -07:00
2026-08-19 02:00:16 -07:00
2026-08-29 07:25:17 -07:00
2026-08-29 20:03:48 +05:30
2026-08-31 07:28:39 -07:00
2026-08-31 07:28:30 -07:00
2026-08-31 14:54:18 -07:00
2026-08-23 03:57:47 -07:00
2026-08-20 15:31:21 +10:00
2026-08-31 09:56:54 -07:00
2026-08-24 03:20:46 -07:00
2026-08-23 03:56:28 -07:00
2026-08-27 07:33:36 -07:00
2026-08-24 03:20:06 -07:00
2026-08-31 10:06:34 -07:00
2026-08-27 07:51:37 -07:00
2026-08-14 21:41:26 -07:00
2026-08-26 04:49:39 -07:00
2026-08-14 21:56:33 -07:00
2026-08-23 20:00:30 -07:00
2026-08-27 17:21:26 +05:30
2026-08-23 18:25:12 -07:00
2026-08-31 09:58:32 -07:00
2026-08-20 15:31:21 +10:00
2026-08-24 15:37:22 +05:30
2026-08-31 12:46:32 -07:00
2026-08-31 11:47:16 -07:00
2026-08-31 09:58:24 -07:00
2026-08-31 14:40:09 -07:00
2026-08-22 17:30:35 +02:00
2026-08-23 17:38:38 -07:00
2026-08-31 14:54:18 -07:00
2026-08-31 12:46:32 -07:00
2026-08-31 10:41:54 -07:00
2026-08-31 12:21:01 -07:00
2026-08-26 13:02:04 -03:00
2026-08-21 09:08:02 +10:00
2026-08-21 16:25:24 +05:30
2026-08-21 16:25:24 +05:30
2026-08-18 01:38:40 -07:00
2026-08-31 11:23:48 -07:00
2026-09-01 20:55:35 +05:30
2026-08-31 14:02:55 -07:00
2026-08-31 12:32:33 -07:00
2026-08-31 09:57:13 -07:00
2026-08-30 05:16:10 -07:00
2026-08-31 12:21:01 -07:00
2026-08-27 20:06:16 +05:30
2026-08-31 10:09:23 -07:00
2026-08-31 11:42:23 -07:00
2026-08-14 21:47:16 -07:00
2026-09-01 20:55:35 +05:30
2026-08-24 20:03:24 -07:00
2026-08-27 15:33:32 +10:00
2026-08-26 15:54:53 -07:00
2026-08-27 15:33:32 +10:00
2026-08-27 15:33:32 +10:00
2026-08-20 15:31:21 +10:00
2026-08-26 15:54:53 -07:00
2026-08-27 15:33:32 +10:00
2026-08-29 07:25:17 -07:00
2026-08-20 15:31:21 +10:00
2026-08-20 15:31:21 +10:00
2026-08-16 20:32:09 -07:00
2026-08-14 21:57:41 -07:00
2026-08-31 14:01:39 -07:00
2026-08-17 15:46:23 -07:00
2026-08-31 10:41:54 -07:00
2026-08-15 01:04:19 -07:00
2026-08-31 12:21:01 -07:00
2026-08-20 15:31:21 +10:00
2026-08-20 15:31:21 +10:00
2026-08-27 07:33:36 -07:00
2026-08-27 07:33:36 -07:00
2026-08-20 15:31:21 +10:00
2026-08-20 15:31:21 +10:00
2026-08-30 20:40:14 -07:00
2026-08-25 12:07:33 +05:30
2026-08-29 11:04:38 +05:30
2026-08-21 16:25:24 +05:30
2026-08-16 02:03:01 -07:00
2026-08-29 20:57:55 -07:00
2026-08-21 16:25:24 +05:30
2026-08-31 12:28:49 -07:00
2026-08-31 12:28:49 -07:00
2026-08-21 16:25:24 +05:30
2026-09-01 08:24:25 -07:00
2026-08-21 16:25:24 +05:30
2026-08-21 16:25:24 +05:30
2026-08-17 16:07:05 +05:30
2026-08-21 16:25:24 +05:30
2026-08-24 17:04:55 +05:30
2026-08-29 20:57:55 -07:00
2026-08-29 20:57:55 -07:00
2026-08-21 16:25:24 +05:30
2026-08-21 16:25:24 +05:30
2026-08-21 16:25:24 +05:30
2026-08-31 12:28:49 -07:00
2026-08-31 12:28:49 -07:00
2026-08-21 16:25:24 +05:30
2026-08-21 16:25:24 +05:30
2026-08-17 16:07:05 +05:30
2026-08-23 19:26:41 -07:00
2026-08-21 16:25:24 +05:30
2026-08-21 16:25:24 +05:30
2026-08-21 19:07:14 -07:00
2026-08-21 16:25:24 +05:30
2026-08-22 15:25:30 +05:30
2026-08-25 12:07:36 +05:30
2026-08-21 16:25:24 +05:30
2026-08-21 16:25:24 +05:30
2026-08-21 16:25:24 +05:30
2026-08-29 20:57:55 -07:00
2026-08-29 20:57:55 -07:00
2026-08-21 21:53:11 +05:30
2026-08-21 16:25:24 +05:30
2026-08-29 20:57:55 -07:00
2026-08-21 16:25:24 +05:30
2026-08-21 16:25:24 +05:30
2026-08-24 23:50:23 -07:00
2026-08-31 12:46:32 -07:00
2026-08-23 17:45:47 -05:00
2026-08-31 12:21:01 -07:00
2026-08-29 19:13:00 -07:00
2026-08-22 17:30:35 +02:00
2026-08-29 20:03:48 +05:30
2026-08-16 02:03:31 -07:00
2026-08-29 05:57:13 -07:00
2026-08-16 01:45:37 -07:00
2026-08-28 07:50:51 -07:00
2026-08-27 07:33:36 -07:00
2026-08-27 07:33:36 -07:00
2026-08-27 07:33:36 -07:00
2026-08-27 07:33:36 -07:00
2026-08-24 03:20:06 -07:00
2026-08-31 10:41:54 -07:00
2026-08-24 03:20:06 -07:00