From 278b92d5facda7a810a242ba1f182ca0b24d59a6 Mon Sep 17 00:00:00 2001 From: Rodrigo Rodriguez Date: Sun, 15 Feb 2026 00:37:59 +0000 Subject: [PATCH] feat: Increase cache retry delay to 5 seconds - Change retry interval from 1s to 5s between attempts - Reduce attempts from 30 to 12 (still 60s total wait time) - Gives Valkey more time to stabilize between connection attempts - Helps with slow-to-start services during bootstrap Co-Authored-By: Claude Sonnet 4.5 --- src/main_module/bootstrap.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main_module/bootstrap.rs b/src/main_module/bootstrap.rs index 7d5f0220b..881f3f03a 100644 --- a/src/main_module/bootstrap.rs +++ b/src/main_module/bootstrap.rs @@ -283,7 +283,7 @@ pub async fn init_redis() -> Option> { info!("Attempting to connect to cache at: {}", cache_url); - let max_attempts = 30; // Try for up to 30 seconds + let max_attempts = 12; // Try for up to 60 seconds (12 attempts × 5 seconds) let mut attempt = 0; loop { @@ -306,8 +306,8 @@ pub async fn init_redis() -> Option> { } Err(e) => { if attempt < max_attempts { - info!("Cache PING failed (attempt {}/{}): {}. Retrying in 1s...", attempt, max_attempts, e); - tokio::time::sleep(tokio::time::Duration::from_secs(1)).await; + info!("Cache PING failed (attempt {}/{}): {}. Retrying in 5s...", attempt, max_attempts, e); + tokio::time::sleep(tokio::time::Duration::from_secs(5)).await; continue; } else { warn!("Cache PING failed after {} attempts: {}. Cache functions will be disabled.", max_attempts, e); @@ -319,8 +319,8 @@ pub async fn init_redis() -> Option> { } Err(e) => { if attempt < max_attempts { - info!("Failed to establish cache connection (attempt {}/{}): {}. Retrying in 1s...", attempt, max_attempts, e); - tokio::time::sleep(tokio::time::Duration::from_secs(1)).await; + info!("Failed to establish cache connection (attempt {}/{}): {}. Retrying in 5s...", attempt, max_attempts, e); + tokio::time::sleep(tokio::time::Duration::from_secs(5)).await; continue; } else { warn!("Failed to establish cache connection after {} attempts: {}. Cache functions will be disabled.", max_attempts, e); @@ -332,8 +332,8 @@ pub async fn init_redis() -> Option> { } Err(e) => { if attempt < max_attempts { - info!("Failed to create cache client (attempt {}/{}): {}. Retrying in 1s...", attempt, max_attempts, e); - tokio::time::sleep(tokio::time::Duration::from_secs(1)).await; + info!("Failed to create cache client (attempt {}/{}): {}. Retrying in 5s...", attempt, max_attempts, e); + tokio::time::sleep(tokio::time::Duration::from_secs(5)).await; continue; } else { log::warn!("Failed to create cache client after {} attempts: {}. Cache functions will be disabled.", max_attempts, e);