mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-27 04:44:30 +00:00
Log the delay when retrying a transaction
This commit is contained in:
parent
35280f7d80
commit
b9bc66aa9b
2 changed files with 5 additions and 1 deletions
|
@ -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"] }
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue