From 8ff134ae22985d52527d5d730912c0422985a91a Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Wed, 4 Mar 2026 12:27:15 -0500 Subject: [PATCH] agent: Set WAL mode and busy_timeout on threads database The threads SQLite database was opened without setting journal_mode or busy_timeout. Without WAL mode, readers block writers and vice versa. Without busy_timeout, SQLite returns SQLITE_BUSY immediately instead of retrying when it encounters a lock. This caused a flood of "database is locked" errors in the logs, especially when save_thread and list_threads (triggered by reload) overlapped, or when multiple Zed windows shared the same threads.db file. Set journal_mode=WAL so readers and writers can proceed concurrently, and busy_timeout=1000 so SQLite retries for up to one second before giving up. --- crates/agent/src/db.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/crates/agent/src/db.rs b/crates/agent/src/db.rs index 10ecb643b9a17dd6b02b47a416c526a662d12632..999c1d7f7a07298d19207425cbad87bb0f553849 100644 --- a/crates/agent/src/db.rs +++ b/crates/agent/src/db.rs @@ -382,6 +382,9 @@ impl ThreadsDatabase { Connection::open_file(&sqlite_path.to_string_lossy()) }; + connection.exec("PRAGMA journal_mode=WAL;")?()?; + connection.exec("PRAGMA busy_timeout=1000;")?()?; + connection.exec(indoc! {" CREATE TABLE IF NOT EXISTS threads ( id TEXT PRIMARY KEY,