diff --git a/crates/sqlez/src/connection.rs b/crates/sqlez/src/connection.rs index fb3194aaf42..a756436b55b 100644 --- a/crates/sqlez/src/connection.rs +++ b/crates/sqlez/src/connection.rs @@ -37,6 +37,15 @@ impl Connection { // Turn on extended error codes sqlite3_extended_result_codes(connection.sqlite3, 1); + // Wait for the database lock to be released instead of failing + // immediately with SQLITE_BUSY. Some databases (e.g. the agent + // threads database) are shared between Zed instances, so transient + // lock contention is expected; failing fast turns it into a + // storm of dropped saves and retry churn. + if !connection.sqlite3.is_null() { + sqlite3_busy_timeout(connection.sqlite3, 5000); + } + connection.last_error()?; }