Skip to content

SQLiteError: locking protocol - Cannot run multiple opencode processes simultaneously #15188

Closed as not planned

Description

@shoa-lin

Description

Problem

When attempting to run a second opencode process while one is already running, the following error occurs:
SQLiteError: locking protocol
at run (unknown)
at run (bun:sqlite:322:21)
at (src/storage/db.ts:73:12)

Root Cause

OpenCode uses a single global SQLite database (~/.local/share/opencode/opencode.db) to store state for ALL projects. This design prevents multiple opencode instances from running concurrently, as SQLite requires exclusive access for write operations.

~/.local/share/opencode/
├── opencode.db ← 990MB, shared by all processes
├── opencode.db-wal ← WAL mode enabled (but still single-writer)
└── opencode.db-shm

Impact

  • Cannot work on multiple projects simultaneously in separate terminals
  • WSL 1 users are particularly affected due to incomplete file locking protocol support
  • Even on normal systems, SQLite's single-writer limitation blocks concurrent use

Environment

  • OS: WSL 1 (Linux 4.4.0-26100-Microsoft)
  • OpenCode version: latest
  • Database: SQLite with WAL mode enabled

Plugins

oh my opencode

OpenCode version

1.2.14

Steps to reproduce

  1. Open a terminal and start opencode in any project:
cd ~/project-a
opencode

2. Open a second terminal (while first opencode is still running) and start opencode in any directory:
cd ~/another-project  # or even same directory
opencode

3. The second opencode instance will immediately crash with:  SQLiteError: locking protocol
Expected: Both opencode instances should run without conflict
Actual: Second instance fails with locking protocol error

### Screenshot and/or share link

_No response_

### Operating System

WSL 1 on Windows 11  

### Terminal

Windows Terminal(Powershell)

Activity

  1. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Feb 26, 2026
  2. github-actions commented on Feb 26, 2026

    @github-actions
    Contributor

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

    If your issue is distinct or not addressed by the above, please add a comment explaining the difference.

  3. assigned and unassigned on Apr 26, 2026
  4. removed
    bugSomething isn't working
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on May 3, 2026
  5. github-actions commented on Jul 4, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

  6. oldantique commented on Jul 11, 2026

    @oldantique

    For anyone landing here from the SQLiteError: locking protocol message: I posted a workaround in #14970 that has held up under 8-way parallel runs — give each process its own data dir so they stop sharing the global DB:

    d=$(mktemp -d)
    mkdir -p "$d/share/opencode"
    cp ~/.local/share/opencode/auth.json "$d/share/opencode/" 2>/dev/null || true
    XDG_DATA_HOME="$d/share" XDG_STATE_HOME="$d/state" opencode run "your prompt"
    rm -rf "$d"

    Config and the models cache stay shared, so there's no re-auth/re-fetch cost. Only fits parallel one-shot runs (--continue won't see sessions written to the throwaway dir). Details and caveats: #14970 (comment)

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