Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

sqlez: Set a 5s SQLite busy timeout (#63923)

whitecat1331e9d2934edfa5
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()?;
}