Skip to content

db: server serves before schema migration completes ("table session_inbox has no column named type") #60724

Closed as not planned

Description

@carlsuburbmates

Summary

The opencode data directory (~/.local/share/opencode) accumulates two kinds of junk that are never cleaned up: 30,370 orphaned zero-byte temp files named .!<pid>!<name> (leftovers of interrupted temp-then-rename bulk writes), and 874 MB of opencode.db.*backup* copies written directly into the live data directory alongside the active database. Together they took the data directory to 1.7 GB — over 3× the live DB.

Environment

  • opencode version: 2.2.4 (desktop app + bundled CLI cli/2.2.4-arm64/opencode-cli)
  • OS: Darwin 25.6.0 arm64 (macOS, Apple Silicon)
  • Shell: /bin/zsh
  • Terminal: TERM=xterm-256color, TERM_PROGRAM unset, COLORTERM unset
  • Install/channel: release (desktop app)
  • Active plugins: none at time of writing (an opencode-antigravity-auth@beta plugin had been configured)

Reproduction

Best-effort; the temp files come from an interrupted bulk write, which I could not trigger on demand.

  1. Have opencode manage a data dir containing a large tool/LSP package tree (e.g. ~/.local/share/opencode/bin/vscode-eslint/, ~18k files).
  2. Interrupt opencode (crash / kill) while it is bulk-writing files (install / update / extract).
  3. Restart. Observe ~18k — and ~30k in total across bin/, storage/, snapshot/, shell/, log/, tool-output/ — zero-byte .!<pid>!<original-name> files that persist across subsequent starts.

Expected Behavior

  1. A temp file whose real counterpart already exists should be pruned on startup (or the write should be crash-atomic and clean up after itself).
  2. Large DB copies produced during recovery/migration should go to a dedicated backups subdirectory — not the live data directory — and be subject to retention/pruning.

Actual Behavior

30,370 zero-byte .!<pid>!<name> files left behind:

Path Count Example
bin/ 18,273 bin/vscode-eslint/.!44435!.vscodeignore
storage/ 11,933 storage/.!74700!migration
snapshot/ 120 snapshot/<id>/objects/info/.!44312!packs
shell/ 26
log/ 12 log/.!74738!opencode.log
tool-output/ 5
data dir root 1 .!74749!auth.json

All are 0 bytes, and every one has its real counterpart intact — none are lost data, purely orphaned litter. Created around 06:28 local and still present hours later; nothing pruned them.

874 MB of DB copies inside the live data directory:

File Size
opencode.db.corrupted-backup-20261031064413 528 MB
opencode.db.pre-v2migration-backup-20261031075456 346 MB
opencode.db (live) 557 MB
data dir total (before cleanup) 1.7 GB (891 MB after removing the copies + temp files)

The copies sit next to the live opencode.db, with only a filename suffix distinguishing them, and there is no visible retention or pruning.

Additional Context

  • Background: immediately before these copies were created, the server logged 16× SQLiteError: table session_inbox has no column named type, later cleared by database schema bootstrap started ... migrations=59.
  • Workaround applied locally: moved both opencode.db.*backup* files to ~/opencode-db-backups/ and deleted all 30,370 .! temp files (find ~/.local/share/opencode -name '.!*!*' -type f -size 0 -delete).
  • Possibly related: an older v1 CLI (1.18.31) shared the same data directory as the 2.2.4 desktop app.

Activity

  1. opencodejr commented on Oct 30, 2026

    @opencodejr
    Contributor

    Thanks for the detailed report!

    I looked through the OpenCode v2.2.4 source and couldn't find anything that creates either kind of file:

    • .!<pid>!<name> temp files: OpenCode's temp-then-rename writes use names like <file>.<pid>.<uuid>.tmp or <file>.<pid>.tmp, never .!<pid>!<name>. Some of the files you list are also never written through a temp file by OpenCode, e.g. git's own snapshot/<id>/objects/info/packs, log/opencode.log and the .vscodeignore inside the extracted eslint package. A pattern like this usually comes from an external tool that copied, synced or backed up the whole directory around 06:28.
    • opencode.db.corrupted-backup-* / opencode.db.pre-v2migration-backup-*: v2 has no code that writes DB copies with these names.

    To work out where they came from, could you tell us, briefly and in your own words:

    1. Was anything else touching ~/.local/share/opencode around 06:28 and 06:44–07:54 that morning? For example a backup or sync tool (Time Machine, iCloud/Dropbox, rsync, Carbon Copy Cloner), a manual copy or restore, or an AI agent or script you asked to repair the database after the session_inbox has no column named type errors.
    2. Did you run the v1 CLI (1.18.31) on this data directory around that time?
    3. If you still have the logs from then (~/.local/share/opencode/log/), please share any lines that mention these backup files or a database recovery or migration.

    You can reply here, or edit the issue. If you edit it, please also leave a comment saying you've updated it so we know you're done.

    Related issues, ordered by how closely they relate (none of them reports this exact problem):

  2. carlsuburbmates commented on Oct 30, 2026

    @carlsuburbmates
    Author

    Thanks — you're right, and I verified it rather than assuming.

    1. What touched the directory. Those filenames came from an AI agent session I ran on this machine to recover the database after the session_inbox has no column named type errors — not from OpenCode. I checked directly: the only log lines naming opencode.db.corrupted-backup-* / opencode.db.pre-v2migration-backup-* are from my own du command. There is no OpenCode log entry about a database recovery, corruption, or backup creation, and no code path that emits .!<pid>!<name> — the temp names I saw don't match <file>.<pid>.<uuid>.tmp.

    2. v1 CLI. 1.18.31 was on PATH pointing at the same data dir, but I cannot prove it executed during that window. It's since been quarantined and opencode now resolves to the bundled 2.2.4 CLI.

    3. Relevant server log lines.

    2026-10-30T20:57:44.373Z level=INFO  cause="SQLiteError: table session_inbox has no column named type"   (×16, 20:57–20:59Z)
    2026-10-30T21:00:15.313Z level=INFO  message="database schema bootstrap started"   migrations=59
    2026-10-30T21:00:15.319Z level=INFO  message="database schema bootstrap completed" migrations=59 durationMs=6
    

    No recovery/backup lines.

    Net: I over-claimed in the original report and I'm narrowing it. Two things I still think are OpenCode-side and worth keeping (happy to split into their own issues if you'd rather):

    • The server logged 16 × table session_inbox has no column named type and only became consistent after a later database schema bootstrap (migrations=59) — i.e. requests touching new columns can be served before the schema is migrated. You also gate /api/info on readiness (server/src/process.ts:192), so a hard readiness gate on migration completion looks like the missing piece.
    • GET /api/info returns {version,pid,urls,paths} with no API/schema generation, which is the same gap as Expose an API version in /api/info + publish a v1→v2 migration path (routes, prompt payload, events, sessions) #55705.

    Want me to retitle this to the schema/readiness issue, or close it in favour of #55010 / #55282 / #55705?

  3. changed the title [-]data: orphaned temp files and large database backups left inside the live data directory[/-] [+]db: server serves before schema migration completes ("table session_inbox has no column named type")[/+] on Oct 30, 2026
  4. opencodejr commented on Nov 2, 2026

    @opencodejr
    Contributor

    We're closing this issue as not planned because we haven't heard back.

    OpenCode v2.2.4 has no code that creates .!<pid>!<name> temp files or the opencode.db.corrupted-backup-* / opencode.db.pre-v2migration-backup-* copies. So we need to know which tool, script or process wrote them before we can treat this as an OpenCode bug.

    If you find out, for example from a backup or sync tool, an agent or script that ran a repair, or log lines in ~/.local/share/opencode/log/ that point to OpenCode, please comment with the details and we can reopen this. Thanks for the thorough write-up!

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions