From 01e711e96ff710abfb502818cb1910556e30e8af Mon Sep 17 00:00:00 2001 From: Alex Snaps Date: Thu, 18 Apr 2024 14:16:11 -0400 Subject: [PATCH] Consider a connection issue a transient one --- limitador/src/storage/redis/mod.rs | 5 ++++- limitador/src/storage/redis/redis_cached.rs | 5 +++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/limitador/src/storage/redis/mod.rs b/limitador/src/storage/redis/mod.rs index 487b5cb9..a60ab99a 100644 --- a/limitador/src/storage/redis/mod.rs +++ b/limitador/src/storage/redis/mod.rs @@ -24,7 +24,10 @@ impl From for StorageErr { fn from(e: RedisError) -> Self { Self { msg: e.to_string(), - transient: e.is_timeout() || e.is_connection_dropped() || e.is_cluster_error(), + transient: e.is_timeout() + || e.is_connection_dropped() + || e.is_cluster_error() + || e.is_connection_refusal(), } } } diff --git a/limitador/src/storage/redis/redis_cached.rs b/limitador/src/storage/redis/redis_cached.rs index bbf5f060..5482ef29 100644 --- a/limitador/src/storage/redis/redis_cached.rs +++ b/limitador/src/storage/redis/redis_cached.rs @@ -220,9 +220,10 @@ impl CachedRedisStorage { .expect("This couldn't fail in the past, yet now it did somehow!"), 2, 100, - 6, + 1, response_timeout, - Duration::from_secs(5), + // TLS handshake might result in 2 RTTs to Redis, adding some headroom as well + (response_timeout * 2) + Duration::from_millis(50), ) .await?;