Log the delay when retrying a transaction

Max Brunsfeld created

Change summary

crates/collab/Cargo.toml | 2 +-
crates/collab/src/db.rs  | 4 ++++
2 files changed, 5 insertions(+), 1 deletion(-)

Detailed changes

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"] }

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;