Skip to content

opencode.db grows unbounded - event table (4.1GB after ~6 months) has no retention policy or cleanup command #47729

Closed as not planned

Description

@ljieyao

Description

opencode.db grows without bound because the event table has no retention policy or cleanup command. On a ~6-month-old install: 6.2GB database, of which the event table alone is 4.1GB (655k rows hanging off ~1.1k live event_sequence aggregates — ~600 events per aggregate on average), next to 931MB of part and 338MB of message.

There is no documented way to trim it: session rows can be deleted manually (children cascade), but the event stream for remaining sessions keeps growing indefinitely, and the serve process appears to hold a large heap (~8GB in our case) that seems correlated with database contents.

Proposed solution

Any of:

  • A built-in retention setting (e.g. keep N days / N events per aggregate)
  • A opencode db cleanup / vacuum command that prunes old events (and optionally old sessions) safely with the server stopped
  • Automatic compaction of event history for sessions older than a threshold

OpenCode version

1.18.29 (linuxbrew install)

Operating System

Linux x86_64 (Ubuntu), headless opencode serve behind the OpenChamber web/desktop client.

Additional context

We had to stop the server, hand-write SQLite deletes + VACUUM to reclaim space. Also worth noting: cascading deletes only fire if PRAGMA foreign_keys=ON is set in the maintenance session — the app itself appears to run with FKs off, so manual cleanup needs care.

Activity

  1. github-actions commented on Sep 7, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

  2. thdxr commented on Oct 11, 2026

    @thdxr
    Member

    Thanks for the report! OpenCode 2.0 is now out and development is focused on V2, so we're closing issues filed against OpenCode 1. Please upgrade (opencode upgrade --major, details: https://anoma.ly/notes/opencode-2-0), and if this is still relevant on 2.0, reopen this issue or open a new one with your 2.0 version.

    — from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions