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.

Log the delay when retrying a transaction

Max Brunsfeldb9bc66aa9bfa
diff --git a/crates/collab/Cargo.toml b/crates/collab/Cargo.toml
index cb404cd2b33..499334c3a3d 100644
--- a/crates/collab/Cargo.toml
+++ b/crates/collab/Cargo.toml
@@ -31,6 +31,7 @@ futures = "0.3"
hyper = "0.14"
lazy_static = "1.4"
lipsum = { version = "0.8", optional = true }
+log = { version = "0.4.16", features = ["kv_unstable_serde"] }
nanoid = "0.4"
parking_lot = "0.11.1"
prometheus = "0.13"
@@ -74,7 +75,6 @@ workspace = { path = "../workspace", features = ["test-support"] }
ctor = "0.1"
env_logger = "0.9"
-log = { version = "0.4.16", features = ["kv_unstable_serde"] }
util = { path = "../util" }
lazy_static = "1.4"
sea-orm = { git = "https://github.com/zed-industries/sea-orm", rev = "18f4c691085712ad014a51792af75a9044bacee6", features = ["sqlx-sqlite"] }
diff --git a/crates/collab/src/db.rs b/crates/collab/src/db.rs
index 9abbf96219d..e8374f4acd5 100644
--- a/crates/collab/src/db.rs
+++ b/crates/collab/src/db.rs
@@ -2970,6 +2970,10 @@ impl Database {
if is_serialization_error(error) {
let base_delay = 4_u64 << prev_attempt_count.min(16);
let randomized_delay = base_delay as f32 * self.rng.lock().await.gen_range(0.5..=2.0);
+ log::info!(
+ "retrying transaction after serialization error. delay: {} ms.",
+ randomized_delay
+ );
self.executor
.sleep(Duration::from_millis(randomized_delay as u64))
.await;