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 — [FEATURE]: V2 offline SQLite inspection, verified backups and vacuum · Issue #54618 · anomalyco/opencode

[FEATURE]: V2 offline SQLite inspection, verified backups and vacuum #54618

New issue
Copy link
New issue
Copy link
Closed as not planned
Closed as not planned
[FEATURE]: V2 offline SQLite inspection, verified backups and vacuum#54618
Copy link

Description

@romanilyin
romanilyin
opened on Oct 11, 2026
Issue body actions

Feature hasn't been suggested before.

  • Checked open storage proposals. This requests the v2 filesystem-maintenance subset of closed PR feat(storage): add safe database maintenance controls #41711; broader lifecycle/retention discussions remain in [FEATURE]: Session Lifecycle Management — unified storage reclamation, auto-archival, and child session cleanup #16101 and Unbounded growth of the event table: opencode.db reaches 13GB+, mostly message.updated.1 snapshots (no retention/compaction) #33356.

Describe the enhancement you want to request

Users need to inspect an existing SQLite database, create a verified recovery copy, and reclaim free pages without starting OpenCode migrations or deleting sessions.

I have prepared a filesystem-only v2 CLI prototype:

  • opencode db inspect <path>: read-only allocation/WAL/SHM and event-byte overview.
  • opencode db backup <path> <target>: a committed-WAL snapshot with integrity/FK checks; existing targets and aliases are rejected.
  • opencode db vacuum <path> <target> --apply: verified backup first, exclusive ownership, physical VACUUM and WAL truncate; logical rows are preserved.

Local v2 defaults to events.persist=false; that still preserves session projections. The v1 message.updated.1 growth reported in #33356 does not establish the same problem on current v2. Old event-compaction logic needs a separate v2 retention/replay design. Workerd uses Durable Object SQLite and needs its own storage-compatible approach.

The CLI prototype is prepared and tested on WSL. Next, I can verify native Windows/Node and provide measurements from anonymized copies of v2/migrated databases. Later cleanup of legacy tables needs migration parity and recovery tests; API/UI maintenance needs an admission/recovery design.

Before opening an upstream implementation PR, I would like feedback on whether this offline CLI belongs in core and on the command/capability interface. Storage API/UI and durable retention can be discussed separately.

The prototype preserves Chris Huber's attribution from #41711.

The v2 prototype is available in romanilyin#1 (draft).

Reacted by Emre Şafak

Activity

  1. opencode-agent commented on Oct 11, 2026

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

    Thanks for the detailed proposal and for keeping the attribution from #41711! As I understand it, you'd like v2 to have offline opencode db inspect, opencode db backup and opencode db vacuum commands. They would let users look at a SQLite database, make a checked recovery copy and reclaim free pages, without running migrations or deleting sessions. Maintainers will look at whether this belongs in core and give feedback on the command interface.

    Related issues and PRs:

    • feat(storage): add safe database maintenance controls #41711: the closed maintenance PR this request takes a subset of (it carried forward fix(core): bound event log compaction #36710)
    • [FEATURE]: Session Lifecycle Management — unified storage reclamation, auto-archival, and child session cleanup #16101: session lifecycle and storage reclamation
    • Unbounded growth of the event table: opencode.db reaches 13GB+, mostly message.updated.1 snapshots (no retention/compaction) #33356: unbounded growth of the event table (v1 message.updated.1)
    • EventV2 cold history duplicates large snapshot payloads and amplifies SQLite storage/reads #47854: EventV2 cold history duplicating large snapshot payloads
    • Excessive storage: event table stores full message snapshots per streaming update — community tool available #41175 / event table dominates the database: 9.03 GB of event log for 1.09 GB of message content #53760: earlier reports of event table storage overhead
    • SQLite auto_vacuum is disabled, database files grow indefinitely #31526: SQLite auto_vacuum being disabled (closed)
    • feat(core): add replay-safe event log retention #50287: replay-safe event log retention (closed PR)
    • [FEATURE]: Project-scoped stores — split the global session DB into a system DB + per-project DBs #47429: proposal to split the global database into per-project stores
  2. GladSI commented on Oct 25, 2026

    @GladSI
    GladSI
    on Oct 25, 2026
    More actions

    Data point for db vacuum --apply: the expensive half can run online

    From a 17 GiB store on 2.1.4: VACUUM INTO '/tmp/copy.db' against the live database, over a read-only connection with the daemon still running, produced a consistent compact copy in 5.9 s — 17 203 MiB → 780 MiB, quick_check ok, row counts identical (133 sessions, 8 570 messages, 124 309 parts, 9 credentials), no exclusive lock needed.

    So --apply could keep the exclusive window down to the cheap part: build and verify the copy online, then take ownership only to rename it into place and truncate the WAL. That also means the slow-looking step (rewriting ~780 MiB) does not have to be what forces a daemon stop on a store that is several GB of mostly free pages.

  3. romanilyin commented on Oct 26, 2026

    @romanilyin
    romanilyin
    on Oct 26, 2026
    Author
    More actions

    Thanks @GladSI — this is a useful measurement, especially the time needed to produce the compact copy. I agree that VACUUM INTO is worth considering for online compact backups.

    For --apply, there is an extra correctness requirement: SQLite documents the output as a consistent snapshot. Writes committed after that snapshot would not be included. Taking ownership only for the final rename would therefore need a reliable way to detect and handle those writes, plus coordinated connection shutdown, WAL handling and crash recovery. Integrity checks and matching row counts alone would not establish that no newer data is lost.

    I would keep the first implementation scoped to offline maintenance, and treat an online preparation/short cutover mode as a follow-up with concurrent-write and recovery tests. The prototype is in romanilyin#1. Maintainer feedback on whether the offline commands belong in core, and on their interface, would help me decide the next upstream step.

  4. neriousy commented on Nov 12, 2026

    @neriousy
    neriousy
    on Nov 12, 2026
    Member
    More actions

    Thanks for the suggestion. This isn't something we plan to build, so closing to keep the tracker focused.

  5. neriousy
    closed this as not plannedon Nov 12, 2026
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

    No labels
    No labels

    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.