You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have verified this feature I'm about to request hasn't been suggested before. (Searched issues for "database size", "sqlite", "vacuum", "event table", "bloat" — the existing specs/storage/remove-opencode-db.md work is a code-layer refactor, not data-retention governance.)
Describe the enhancement you want to request
Add event-log GC/compaction (and ideally per-project database isolation) to keep opencode.db bounded and prevent multi-instance startup hangs on large databases.
Motivation (measured, real-world)
After ~2 months of heavy daily use (~3,000 sessions, ~30 opencode instances kept alive in parallel across projects), my global opencode.db reached 3.99 GB, of which the event table is ~1,000,000 rows / 2.89 GB (72.4%). It grows on every streamed token because each message.part.updated.1 event stores a full snapshot of the part — append-only event sourcing with no retention mechanism.
Measured breakdown (SQLite dbstat):
Table
Rows (MAX(rowid))
Size
Share
event
~999,531
2.886 GB
72.4%
part
~273,816
0.826 GB
20.7%
message
~64,156
0.041 GB
1.0%
indexes + misc
—
~0.24 GB
~6%
session
~2,948
small
—
Total
~3.99 GB
Consequence at this scale: starting a newopencode instance hangs indefinitely — blank TUI (71 empty lines), zero log output (not even bootstrapping), no MCP subprocess spawn, all 86 threads idle in futex/epoll. Same binary/config starts fine when the DB is smaller or after most instances are closed. Increasing swap 8G→32G did not help; error-log evidence (timeout ~6k, 502 ~2k, 503 ~1k lines; network-layer errors: 2) points to SQLite single-writer contention behind a multi-GB file, not network or memory.
Positive check: session delete cascades correctly (zero orphan events verified), so cleanup exists per-session — but there is no bulk/retention tooling for users with thousands of sessions.
Requested enhancements
Event-log compaction/retention: snapshot-and-prune per aggregate (keep current part state + bounded recent history), or a retention policy (e.g. drop message.part.updated events older than N days / beyond the last K per aggregate). This directly bounds the 72% growth driver.
Per-project / sharded database: honor an explicit override (e.g. OPENCODE_DB_PATH) or document per-domain XDG_DATA_HOME isolation, so heavy multi-project users can split the single contention point.
Startup resilience (fallback if 1/2 are deferred): bound database access during boot with a timeout and degrade gracefully, so a huge/contended DB can never wedge the TUI before first render.
Activity
github-actions commentedon Sep 4, 2026
This issue might be a duplicate of existing issues. Please check:
message.updated.1event snapshots — same root cause (unbounded event table growth from full message snapshots)eventtable: opencode.db reaches 13GB+, mostlymessage.updated.1snapshots (no retention/compaction) #33356: Unbounded growth of theeventtable: opencode.db reaches 13GB+, mostlymessage.updated.1snapshots (no retention/compaction) — same root cause, already tracked under the 2.0 milestone