GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — storage: no backpressure — disk-full corrupts the DB and silently quarantines all session history · Issue #56829 · anomalyco/opencode

storage: no backpressure — disk-full corrupts the DB and silently quarantines all session history #56829

New issue
Copy link
New issue
Copy link
Closed as not planned
Closed as not planned
storage: no backpressure — disk-full corrupts the DB and silently quarantines all session history#56829
Copy link
Labels
pending closetriaging

Description

@Amperstrand
Amperstrand
opened on Oct 18, 2026
Issue body actions

Environment

opencode v1.19.0, Linux x86_64, ~10 concurrent instances, single shared SQLite storage on a 937 GB root disk.

What happened

There is no storage backpressure: no database size cap, no disk watermark check. In our incident the shared DB (see companion reports on event-table and message-row growth) filled the root filesystem. ENOSPC hit SQLite mid-transaction and corrupted the database.

On the next startup, opencode silently quarantined the entire data directory (~/.local/share/opencode → opencode.corrupt-<date>/) and started an empty database. Every running session's history "vanished" from all 9 live instances (still-running instances kept writing into the quarantined inode, so the space was not even reclaimed).

Ask

  • Refuse-to-write watermark on low disk (fail loudly with a clean error).
  • A clean SQLITE_FULL error path instead of corruption.
  • Per-project or size-bounded storage so one host's growth can't take out every session, and a documented recovery flow that doesn't discard all history silently.

Activity

  1. opencode-agent commented on Oct 18, 2026

    @opencode-agent
    opencode-agentBot
    on Oct 18, 2026 – with OpenCode Agent
    Contributor
    More actions

    Thanks for the detailed write-up of the incident, and sorry you lost access to your session history.

    This report is about v1 (1.19.0). v1 only gets fixes for critical bugs now, and most of what you're asking for is new behaviour: a low-disk watermark, a size cap, per-project storage and a recovery flow. So this is unlikely to change in v1. Your history should still be in the quarantined opencode.corrupt-<date>/ directory. You can stop all instances and try sqlite3 <old>/opencode.db ".recover" | sqlite3 <new>.db to get the data back out.

    We'd encourage you to try v2 (@opencode/cli, 2.x), where work is happening. Storage is a separate implementation there, and I couldn't find any code in v2 that renames the data directory like this. I haven't checked how v2 handles a full disk while writing, though.

    Related issues:

    • storage: shared event table grows unbounded; retention prune never reclaims disk space #56827 and storage: message rows embed workspace diffs of untracked files (393 MB single rows) #56828: your companion reports on the event table and message-row growth
    • core: tool stuck in pending state when hitting SQLITE full errors #52796 and fix(core): recover sessions and jobs from transient storage failures #53704: handling SQLITE_FULL errors
    • SQLite DB corruption + SQLITE_BUSY lock storm when many agents run concurrently with $HOME on a shared/parallel filesystem #56282: database corruption and lock storms with many concurrent agents
    • Unbounded growth of the event table: opencode.db reaches 13GB+, mostly message.updated.1 snapshots (no retention/compaction) #33356, Excessive storage: event table stores full message snapshots per streaming update — community tool available #41175, Durable event table bloats from repeated turn diff payloads #48641 and EventV2 cold history duplicates large snapshot payloads and amplifies SQLite storage/reads #47854: unbounded event-table growth
    • [FEATURE]: Session Lifecycle Management — unified storage reclamation, auto-archival, and child session cleanup #16101 and [FEATURE]: V2 offline SQLite inspection, verified backups and vacuum #54618: feature requests for storage cleanup, verified backups and vacuum

    If you think this is critical, or you can reproduce the corruption or the silent loss of history on v2, please reply here with the details.

  2. opencode-agent
    added
    pending close
    triaging
    on Oct 18, 2026
  3. John-Rood commented on Oct 18, 2026

    @John-Rood
    John-Rood
    on Oct 18, 2026
    More actions

    Read v1.19.0 before writing this, and two premises in the report do not match that tree. Both change the recovery plan, so they are worth pinning down before anyone writes a fix.

    The hourly cleanup prune=7.days is not database retention

    packages/opencode/src/snapshot/index.ts:23 is const prune = "7.days", and its only consumer is line 305:

    const result = yield* git(args(["gc", `--prune=${prune}`]), { cwd: state.directory })

    That is git gc inside the snapshot git dir. The log line comes from Effect.logInfo("cleanup", { prune }) at line 313, and the schedule at 763-764 is Effect.repeat(Schedule.spaced(Duration.hours(1))) plus Effect.delay(Duration.minutes(1)), so one minute after start and then hourly. That is the line you are reading, and it never touches SQLite.

    Nothing else prunes event. The only delete on that table is per aggregate, packages/core/src/event.ts:514-519, reached from Session.remove at packages/opencode/src/session/session.ts:623, which is what opencode session delete <id> calls. There is no time based retention, and time_archived is only ever used as a query filter.

    So the 9.8 GB event table is not retention failing to reclaim space. There is no retention to fail. That makes your third ask the accurate one, and the other two follow from it: with no delete path, auto_vacuum = 0, and no VACUUM anywhere in the tree, the file can only grow.

    The data dir rename is not in this tree either

    grep -rn corrupt across v1.19.0 gives two hits, both unrelated strings: an image error message in provider/transform.ts and a comment in the server route. No code path renames the data root. Something else on that host moved ~/.local/share/opencode to opencode.corrupt-<date>, and it will do it again, so identify it before pointing anything at the replacement. It also decides the recovery: if the directory was moved, the history is inside it, and if ENOSPC damaged the database mid transaction, the repair is below.

    Recovery

    Stop the instances first, then check the file:

    sqlite3 ~/.local/share/opencode.corrupt-<date>/opencode.db "PRAGMA integrity_check;"
    

    If it prints ok, nothing is lost. Move the empty root aside and put the old one back:

    mv ~/.local/share/opencode ~/.local/share/opencode.empty-$(date +%F)
    mv ~/.local/share/opencode.corrupt-<date> ~/.local/share/opencode
    

    If it reports bad pages, .recover rebuilds what is left. I simulated page damage on a 20.6 MB database of this shape by overwriting 8 KB in the middle, got Tree 4 page 1673 cell 4: invalid page number 4024348094, and the rebuilt file came back ok with all 400 sessions, 2,000 messages and 2,400 events:

    sqlite3 bad.db ".recover" > recover.sql
    sqlite3 new.db < recover.sql
    sqlite3 new.db "PRAGMA integrity_check;"
    

    Rows that existed only in the -wal came through in that test, so copy the -wal beside the database rather than recovering the main file alone. Put the output on a filesystem that has room. That is the "does not discard all history silently" flow you asked for, and it works on the version you are running.

    Reclaiming the space

    VACUUM needs the write lock and temporary space, so against your setup it fails: with a second connection holding a write transaction it returned database is locked (5). On a full disk it has nowhere to write anyway.

    VACUUM INTO is the one that works under pressure. It reads only, so it completed while another connection held a write transaction, and the copy holds live rows only, so it needs the compacted size rather than the current size. Measured on a 74.6 MB database shaped like yours, event at 74 percent:

    • after deleting 80 percent of the events: file still 74.6 MB, 12,801 of 18,213 pages on the freelist
    • VACUUM INTO '/other/disk/compact.db': 20.6 MB, integrity ok, counts intact

    Sequence that works when you have less free space than the database:

    1. opencode session list -n 100, then opencode session delete <id> for the ones you do not need. That path really does remove the aggregate's event and event_sequence rows, so it is the only retention lever that exists in v1.
    2. sqlite3 "$(opencode db path)" "VACUUM INTO '/path/with/space/compact.db';"
    3. Stop the instances, swap the file, restart.

    Before step 1, find out where the bytes are:

    sqlite3 "$(opencode db path)" \
      "SELECT name, SUM(pgsize)/1048576 AS mb FROM dbstat GROUP BY name ORDER BY mb DESC LIMIT 8;"
    

    That needs SQLITE_ENABLE_DBSTAT_VTAB. If your build omits it, this gives the same shape from the payload side:

    SELECT aggregate_id, COUNT(*), SUM(LENGTH(data))/1048576 AS mb
    FROM event GROUP BY aggregate_id ORDER BY mb DESC LIMIT 10;
    

    Which brings in your two companion reports. If event is 76 percent of 12.85 GB, the retention path above is the one that moves the needle; capping message.data diffs helps the other 2 GB and does nothing for the majority table.

    WAL

    The pragmas set at open are journal_mode = WAL, synchronous = NORMAL, busy_timeout = 5000, cache_size = -64000, foreign_keys = ON, then one wal_checkpoint(PASSIVE) at line 32. No journal_size_limit, no periodic checkpoint.

    A passive checkpoint cannot move frames an open reader still needs, which is your 0.8 GB WAL. Measured with one reader holding a snapshot: PRAGMA wal_checkpoint(TRUNCATE) returned 1|1603|3 and the WAL stayed at 6.6 MB. The same command after the reader released returned 0|0|0 and the file went to 0 bytes.

    So run the truncating checkpoint from outside the instances, in a window where few readers are live. It is safe against a live database; worst case it returns busy=1 and tells you how many frames it could not move. journal_size_limit is not a lever from outside, since it is per connection and does not persist: I set 67108864 in one shell and the next connection read 32768.

    Blast radius

    OPENCODE_DB takes an absolute path and wins over the channel naming:

    OPENCODE_DB=/srv/oc/instance-3.db opencode
    

    Verified with opencode db path returning exactly that path. Ten instances on one file is why that ENOSPC took out all ten, and why the still running ones kept writing into a quarantined inode. Per instance files turn the failure into one lost instance. The cost is that history stops being shared between instances, so it is a tradeoff rather than a fix. If you keep the shared file, the guard below is what makes the failure loud.

    Refusing to start on a full disk

    Your first ask, without a code change. Wrap the CLI, exit 75 before startup, pass through otherwise:

    #!/usr/bin/env bash
    set -uo pipefail
    min_free="${OC_GUARD_MIN_FREE_GB:-5}"
    db=$(opencode db path) || exit 1
    avail=$(( $(df -Pk "$(dirname "$db")" | awk 'NR==2{print $4}') / 1024 / 1024 ))
    [ "$avail" -lt "$min_free" ] && { echo "oc-guard: ${avail}GB free, below ${min_free}GB, refusing" >&2; exit 75; }
    exec opencode "$@"

    opencode db path resolves without opening the database, so the check costs nothing. Tested both arms.

    The rest does need code: retention for event with a reclaim step, auto_vacuum = INCREMENTAL from creation since it cannot be turned on later for existing tables, and a clean SQLITE_FULL error path so a full disk is an error instead of a corrupt file.

    The durable point underneath all of this is that the record of what your agents decided should not depend on one SQLite file staying healthy. MemoryRouter is what I built for that half: the agent's memory lives in a store outside the context window and outside that file, so a session on any machine recalls what was decided instead of re-deriving it after the local history is gone. For clients without native support it is proxy or MCP: https://docs.memoryrouter.ai/coding-tools?utm_source=github&utm_medium=issue&utm_campaign=anomalyco-opencode

  4. opencode-agent
    closed this as not plannedon Oct 19, 2026
  5. opencode-agent commented on Oct 19, 2026

    @opencode-agent
    opencode-agentBot
    on Oct 19, 2026 – with OpenCode Agent
    Contributor
    More actions

    We haven't heard back, so I'm closing this as not planned. It's about v1 (1.19.0), which only gets critical fixes, and most of what you asked for here is new behaviour: a low-disk watermark, a size cap and per-project storage. Your history should still be in the quarantined opencode.corrupt-<date>/ directory, and you can try sqlite3 ".recover" on it. If you can reproduce the corruption or the silent loss of history on v2 (@opencode/cli), please open a new issue or reply here with the details. Thanks for the thorough report.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    pending closetriaging

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.