Skip to content

Concurrent opencode processes on one database fail prompts with "Failed to execute statement" (SQLITE_BUSY) #47566

Closed as not planned

Description

@woodsonl

Description

Running several opencode processes against the same shared data directory makes them contend for the single SQLite write lock. Statements that wait longer than busy_timeout (5s) fail with database is locked and the error propagates as "Failed to execute statement" / "Unexpected server error", killing the whole prompt even though the statement itself is fine and would succeed on retry.

Observed on a busy VM with ~10 concurrent sessions sharing one opencode.db: 43 lock failures in one day, at Session.updateMessage, createUserMessage, and cleanup paths.

Steps to reproduce

  1. Start multiple long-running opencode sessions writing to the same opencode.db (WAL mode)
  2. Prompt them concurrently under enough IO/CPU load that some writes exceed 5s
  3. Watch server log for SqlError/LockTimeoutError: database is locked and failed prompts

OpenCode version

1.18.29

Activity

  1. github-actions commented on Sep 6, 2026

    @github-actions
    Contributor

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

  2. woodsonl commented on Sep 6, 2026

    @woodsonl
    Author

    Opened #47567 for the mid-session write path (retry SQLITE_BUSY with backoff in both drivers). Complements #44558, which covers init/migrations — that PR explicitly leaves these runtime failures open. Happy to close or rework #47567 if the fix is being handled differently.

  3. 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