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 — Daily "Failed to execute statement" on macOS with concurrent opencode processes (1.18.30, busy_timeout=0, 21 GB DB) · Issue #48416 · anomalyco/opencode

Daily "Failed to execute statement" on macOS with concurrent opencode processes (1.18.30, busy_timeout=0, 21 GB DB) #48416

New issue
Copy link
New issue
Copy link
Closed as not planned
Closed as not planned
Daily "Failed to execute statement" on macOS with concurrent opencode processes (1.18.30, busy_timeout=0, 21 GB DB)#48416
Copy link
Assignees
rekram1-node

Description

@SmallNew2003
SmallNew2003
opened on Sep 11, 2026
Issue body actions

Description

Local opencode CLI/Desktop sessions intermittently fail with Failed to execute statement (and the UI surfaces it as error: UnknownError). On my machine this happens "every day now", most often right after a bash tool subprocess returns — which is exactly the moment opencode writes the tool-result part back into the SQLite session store.

Reproduction setup (just one machine, no virtualization):

  • macOS 15.5 arm64
  • opencode 1.18.30
  • single user account, default data directory ~/.local/share/opencode/
  • several opencode processes run against the same opencode.db: a long-lived TUI/Desktop session from a few days ago, a couple of overnight opencode run workers, and the foreground session I am trying to use
  • PRAGMA busy_timeout on the live DB returns 0, journal_mode=wal, integrity_check=ok

What the user actually sees:

  1. The agent's response for that turn finishes with finish: tool-calls, error: { name: "UnknownError", data: { message: "Failed to execute statement" } }.
  2. The corresponding tool part inside that message already has state.status = "completed" with the real stdout — so the tool result is not lost, only the wrapper message write to SQLite failed.
  3. The next prompt in the same session usually goes through; the failure is non-deterministic and not tied to a particular tool or prompt.

OpenCode log excerpt (timestamp preserved from the same day):

timestamp=2026-09-11T01:58:23.969Z level=ERROR run=a2a9e52e message=process \
  session.id=ses_f71dab2b7ffe2qdxk7y9xkt85d messageID=msg_08e2e9604001lLC96eHJdN3tR8 \
  error="Failed to execute statement" stack="Error
    at <anonymous> (/$bunfs/root/chunk-szxn2m7h.js:54:29098)
    at runLoop (/$bunfs/root/chunk-awr5yyef.js:25:2045)
    at evaluate (/$bunfs/root/chunk-awr5yyef.js:25:1435)
    at <anonymous> (/$bunfs/root/chunk-awr5yyef.js:25:5664)
    at <anonymous> (/$bunfs/root/chunk-awr5yyef.js:25:22490)
    at evaluate (/$bunfs/root/chunk-awr5yyef.js:25:1691)
    at <anonymous> (/$bunfs/root/chunk-awr5yyef.js:25:5664)
    at Y7 (/$bunfs/root/chunk-awr5yyef.js:25:39080)
    at <anonymous> (/$bunfs/root/chunk-szxn2m7h.js:80:23438)
    at emit (node:events:98:22)
    at #maybeClose (node:child_process:766:16)
    at #handleOnExit (node:child_process:520:72)
    at processTicksAndRejections (native:7:39)"

Key thing in this stack: the failure is being raised inside the node:child_process handleOnExit handler that fires right after the bash subprocess closes. So the write that loses the race is the post-tool message/part write triggered by handleOnExit, not the tool's own call site.

I see the same stack pattern 4 times in a 17-minute window, all under the same DB. Four concurrent opencode processes have that DB open (lsof ~/.local/share/opencode/opencode.db):

opencode. 38499 ... 13u ... /Users/jelvin/.local/share/opencode/opencode.db   # running ~2d16h
opencode. 87705 ... 13u ... /Users/jelvin/.local/share/opencode/opencode.db   # running ~1d16h
opencode. 96583 ... 13u ... /Users/jelvin/.local/share/opencode/opencode.db   # running ~1d18h
opencode. 82411 ... 13u ... /Users/jelvin/.local/share/opencode/opencode.db   # ~17 min
opencode. 80097 ... 12u ... /Users/jelvin/.local/share/opencode/opencode.db   # foreground session, ~17 min

DB facts:

  • ~/.local/share/opencode/opencode.db is 21 GB with a 700 KB WAL
  • busy_timeout = 0, journal_mode = wal, integrity_check = ok
  • disk free: 407 GB on the data volume, so SQLITE_FULL is not the cause

The wrapped Drizzle/Kysely SQL error is being flattened to the string "Failed to execute statement" before it reaches the session error envelope (per #36578). Because the SQLite cause is dropped, I cannot tell from the session log whether each occurrence is SQLITE_BUSY, SQLITE_LOCKED, or SQLITE_BUSY_SNAPSHOT. Given that busy_timeout=0, multiple writers, and the failure points to writes triggered right after a child process exit, SQLITE_BUSY is the most likely root cause.

Expected behavior

A failure to grab the SQLite write lock should not kill the surrounding prompt. The user-visible behavior should be one of:

  • transparently retry the statement (with backoff) so the prompt completes
  • surface the underlying SQLite cause (SQLITE_BUSY: database is locked or similar) instead of "Failed to execute statement"
  • if the write truly cannot make progress, retry long enough to give the other process a chance to release the lock instead of immediately failing the message

Steps to reproduce

  1. Run opencode 1.18.30 on macOS arm64.
  2. Have several opencode processes (TUI, Desktop, opencode run worker, etc.) open the same ~/.local/share/opencode/opencode.db concurrently.
  3. Let at least one of them stay alive for hours/days while issuing prompts.
  4. Issue prompts that involve the bash tool — the failure shows up almost immediately after a bash subprocess returns and opencode tries to persist the tool result / message.
  5. Inspect the session's message and part rows; the tool part row is already written and state.status = completed, but the surrounding message row carries error.name = "UnknownError", error.data.message = "Failed to execute statement".

Mitigation tried / observed locally

Killing the long-lived opencode processes (the two that had been running 1–2 days) makes the failure stop, until the next time one of them runs long enough to coexist with a new writer. The DB is healthy (integrity_check = ok); the failure is contention, not corruption.

OpenCode version

1.18.30

Operating System

macOS 15.5 (24F74), Darwin 24.5.0 arm64 (MacBook Pro 16, M-series)

Additional context

This looks like the same root cause as #47566, #38849, #33320, and #21215 — busy_timeout = 0 in the bun-sqlite / node-sqlite connection, combined with concurrent opencode processes, and Effect.orDie on the SQL adapter turning lock timeouts into fatal message failures. The two companion PRs that would actually fix it are already open:

  • fix(core): retry sqlite statements on lock timeout #47567 — retry SQLite statements on lock timeout in both bun and node drivers
  • fix(db): serialize database init and migrations across processes #44558 — serialize database init and migrations across processes

Reporting this separately because the symptom on the user side (a single failing assistant message with a successful tool part already written) is consistent enough across several local days to be worth a dedicated reproduction, and the WAL file growth + 21 GB main DB on a single-user laptop suggests the contention window is also creating the WAL grows unbounded pattern from #37495.

Reacted by Nathan Clonts and Marcin Kołodziej

Activity

  1. SmallNew2003 commented on Sep 11, 2026

    @SmallNew2003
    SmallNew2003
    on Sep 11, 2026
    Author
    More actions

    Cross-linking the related reports so maintainers can find them in one place:

    • Concurrent opencode processes on one database fail prompts with "Failed to execute statement" (SQLITE_BUSY) #47566 — exact same error string in a busy VM (the closest match)
    • Concurrent VS Code instances still silently crash — busy_timeout=0 still present #38849 — busy_timeout=0 still present in 1.17.15, references the 5000ms sst/opencode stopgap
    • Concurrent opencode run workers can fail at startup with database is locked #33320 — database is locked at startup on 1.17.8 opencode run workers
    • opencode run: concurrent sessions crash with SQLITE_BUSY (busy_timeout=0) #21215 — original report, now closed for inactivity
    • [BUG] SQLite WAL grows unbounded (10–15 GB) while Desktop is running — disk fills to 0, recovers only on full quit #37495 — WAL grows unbounded while Desktop is running (likely amplified by the same contention)
    • SQLite failures hide actionable error details #36578 — closed; this issue's "Failed to execute statement" string is the same one that PR sanitized

    Companion PRs that would actually fix the user-visible failure:

    • fix(core): retry sqlite statements on lock timeout #47567 — retry SQLite statements on lock timeout (bun + node drivers)
    • fix(db): serialize database init and migrations across processes #44558 — serialize database init and migrations across processes
  2. github-actions
    assigned
    rekram1-node
    on Sep 11, 2026
  3. github-actions commented on Sep 11, 2026

    @github-actions
    github-actionsBot
    on Sep 11, 2026 – with GitHub Actions
    Contributor
    More actions

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

    • Concurrent opencode processes on one database fail prompts with "Failed to execute statement" (SQLITE_BUSY) #47566: Same root cause — concurrent opencode processes on one database failing with "Failed to execute statement" (SQLITE_BUSY, busy_timeout=0)
    • Concurrent VS Code instances still silently crash — busy_timeout=0 still present #38849: Concurrent instances silently crashing due to busy_timeout=0 still present
    • Concurrent opencode run workers can fail at startup with database is locked #33320: Concurrent opencode run workers failing at startup with "database is locked"

    You've already referenced these in your report, which is great. Consider closing this in favor of #47566 if the symptoms match, or a maintainer may link them.

  4. thdxr commented on Oct 11, 2026

    @thdxr
    thdxr
    on Oct 11, 2026
    Member
    More actions

    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 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊

  5. thdxr
    closed this as not plannedon Oct 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @rekram1-node
    rekram1-node

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.