-
Notifications
You must be signed in to change notification settings - Fork 11.2k
Open
Labels
coreAnything pertaining to core functionality of the application (opencode server stuff)Anything pertaining to core functionality of the application (opencode server stuff)
Description
Bug Report
OpenCode version: latest (as of 2026-02-24)
OS: Linux 6.6.105+ (NFS-mounted home directory)
Runtime: Bun
Description
Opening multiple opencode sessions in the same repository corrupts the shared SQLite database (~/.local/share/opencode/opencode.db), making opencode unable to start until the database is manually deleted.
Error
{
"name": "UnknownError",
"data": {
"message": "SQLiteError: database disk image is malformed\n at values (unknown)\n at get (../../node_modules/.bun/drizzle-orm@1.0.0-beta.12-a5629fb+1f516382cd87cd66/node_modules/drizzle-orm/bun-sqlite/session.js:91:25)\n at run (node:async_hooks:62:22)\n at use (src/storage/db.ts:111:28)\n at fromDirectory (src/project/project.ts:193:26)\n at async <anonymous> (src/project/instance.ts:27:52)\n at async provide (src/project/instance.ts:40:23)\n at processTicksAndRejections (native:7:39)"
}
}
Steps to Reproduce
- Have opencode installed with home directory on NFS
- Open an opencode session in a repository
- Open a second opencode session in the same (or different) repository
- Send a message in either session
- SQLite database corrupts almost immediately — opencode crashes with the above error
- All subsequent attempts to start opencode also crash until the database is manually deleted
Root Cause (Suspected)
All opencode sessions share a single SQLite database (~/.local/share/opencode/opencode.db) using WAL mode. Concurrent writers likely cause corruption due to:
- NFS + SQLite locking: SQLite relies on POSIX
fcntl()advisory locking, which is notoriously unreliable on NFS. The WAL-shmfile uses shared memory mappings that don't work correctly over network filesystems. - bun-sqlite concurrency: Even on local filesystems, multiple processes writing to the same bun-sqlite database without explicit coordination (e.g.,
PRAGMA busy_timeout, retry logic, or a single-writer architecture) can corrupt the database.
Evidence of NFS involvement: stale .nfs* handle files were present alongside the corrupted database in ~/.local/share/opencode/.
Workaround
Delete the corrupted database and let opencode recreate it (loses all session history):
rm ~/.local/share/opencode/opencode.db ~/.local/share/opencode/opencode.db-shm ~/.local/share/opencode/opencode.db-walSuggested Fixes
- Set
PRAGMA busy_timeoutto handle concurrent access gracefully instead of corrupting - Use
PRAGMA journal_mode=DELETEinstead of WAL when on a network filesystem (or detect NFS and warn) - Consider per-project databases instead of a single global one
- Add integrity checks on startup with a graceful recovery path instead of crashing
Related Issues
- Concurrent sessions working on different repos interfer each other #4251 — Concurrent sessions interfere with each other (session isolation)
- Sessions are not saving with multi sessions on #5241 — Sessions not saving with multiple sessions open
- OpenCode API Race Condition in Concurrent Session Deletion #5517 — Race condition in concurrent session deletion
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
coreAnything pertaining to core functionality of the application (opencode server stuff)Anything pertaining to core functionality of the application (opencode server stuff)