Skip to content

Add busy_timeout to the local libSQL connection#1003

Merged
RhysSullivan merged 1 commit into
mainfrom
daemon/busy-timeout
Jun 14, 2026
Merged

Add busy_timeout to the local libSQL connection#1003
RhysSullivan merged 1 commit into
mainfrom
daemon/busy-timeout

Conversation

@RhysSullivan

@RhysSullivan RhysSullivan commented Jun 13, 2026

Copy link
Copy Markdown
Owner

Adds a per-connection PRAGMA busy_timeout = 5000 to the local libSQL open path, matching the self-host configuration.

WAL gives concurrent readers + a single writer, but with the default busy_timeout = 0 a second writer fails immediately with SQLITE_BUSY. A 5s retry window absorbs the brief contention that happens when a second OS process transiently holds the write lock — a CLI tool, the v1→v2 migration reader, or a supervised daemon restart racing the previous pid.

openLocalLibsql is the single open site for the local app (the FumaDB handle and the migration reader both route through it), so the pragma applies everywhere.

Base of a small stack that moves the local MCP gateway onto an OS-supervised daemon.

Stack

  1. Add busy_timeout to the local libSQL connection #1003 👈 current
  2. Add executor service to supervise the local gateway daemon #1004
  3. Desktop: attach to the supervised daemon instead of a private sidecar #1005

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jun 13, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
executor-marketing 0766801 Commit Preview URL

Branch Preview URL
Jun 14 2026, 06:37 AM

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jun 13, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
executor-cloud 0766801 Jun 14 2026, 06:37 AM

@github-actions

github-actions Bot commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Cloudflare preview

Torn down — the PR is closed.

@pkg-pr-new

pkg-pr-new Bot commented Jun 13, 2026

Copy link
Copy Markdown

Open in StackBlitz

@executor-js/cli

npm i https://pkg.pr.new/@executor-js/cli@1003

@executor-js/config

npm i https://pkg.pr.new/@executor-js/config@1003

@executor-js/execution

npm i https://pkg.pr.new/@executor-js/execution@1003

@executor-js/sdk

npm i https://pkg.pr.new/@executor-js/sdk@1003

@executor-js/codemode-core

npm i https://pkg.pr.new/@executor-js/codemode-core@1003

@executor-js/runtime-quickjs

npm i https://pkg.pr.new/@executor-js/runtime-quickjs@1003

@executor-js/plugin-file-secrets

npm i https://pkg.pr.new/@executor-js/plugin-file-secrets@1003

@executor-js/plugin-graphql

npm i https://pkg.pr.new/@executor-js/plugin-graphql@1003

@executor-js/plugin-keychain

npm i https://pkg.pr.new/@executor-js/plugin-keychain@1003

@executor-js/plugin-mcp

npm i https://pkg.pr.new/@executor-js/plugin-mcp@1003

@executor-js/plugin-onepassword

npm i https://pkg.pr.new/@executor-js/plugin-onepassword@1003

@executor-js/plugin-openapi

npm i https://pkg.pr.new/@executor-js/plugin-openapi@1003

executor

npm i https://pkg.pr.new/executor@1003

commit: 0766801

@RhysSullivan RhysSullivan force-pushed the daemon/busy-timeout branch from 6069b98 to ec96a52 Compare June 13, 2026 21:10
@greptile-apps

greptile-apps Bot commented Jun 13, 2026

Copy link
Copy Markdown

Greptile Summary

This PR adds a per-connection PRAGMA busy_timeout = 5000 to the local libSQL open path, matching the existing self-host configuration in self-host-db.ts. The change prevents an immediate SQLITE_BUSY failure when a second OS process transiently holds the write lock, giving writers a 5-second retry window instead.

  • openLocalLibsql in apps/local/src/db/libsql.ts now sets foreign_keys, journal_mode = WAL, and busy_timeout = 5000 on every new connection — the single open site for both the FumaDB handle and the migration reader.
  • The three-PRAGMA sequence now mirrors createSqliteExecutorDb in self-host-db.ts (which already had busy_timeout), creating parity between the two open paths.

Confidence Score: 5/5

Safe to merge — the change is a one-line PRAGMA addition with a well-understood, bounded effect on connection open behaviour.

The change adds a single, well-understood SQLite PRAGMA that is already proven in the self-host code path. It touches no data logic, no schema, and no control flow — only the connection setup sequence in the one open site for the local app.

No files require special attention.

Important Files Changed

Filename Overview
apps/local/src/db/libsql.ts Adds PRAGMA busy_timeout = 5000 to openLocalLibsql, matching the self-host open path; block comment on line 7 and JSDoc on line 21 still list only two PRAGMAs (pre-existing P2 doc drift).

Sequence Diagram

sequenceDiagram
    participant Caller
    participant openLocalLibsql
    participant libsql as libSQL Client

    Caller->>openLocalLibsql: openLocalLibsql(path)
    openLocalLibsql->>libsql: "createClient({ url: file:... })"
    openLocalLibsql->>libsql: "PRAGMA foreign_keys = ON"
    openLocalLibsql->>libsql: "PRAGMA journal_mode = WAL"
    openLocalLibsql->>libsql: "PRAGMA busy_timeout = 5000 (new)"
    openLocalLibsql-->>Caller: Client
Loading

Reviews (3): Last reviewed commit: "Add busy_timeout to the local libSQL con..." | Re-trigger Greptile

@RhysSullivan RhysSullivan force-pushed the daemon/busy-timeout branch from ec96a52 to 34b2c67 Compare June 13, 2026 21:38
Match the self-host open path: a per-connection PRAGMA busy_timeout=5000 gives
writers a 5s retry window instead of an instant SQLITE_BUSY when a second OS
process transiently holds the write lock (a CLI tool, the v1->v2 migration
reader, or a launchd restart racing the old pid).
@RhysSullivan RhysSullivan force-pushed the daemon/busy-timeout branch from 34b2c67 to 0766801 Compare June 14, 2026 06:35
@RhysSullivan RhysSullivan merged commit 554a714 into main Jun 14, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant