From 3b346a29cf55749a49a5c4e09632fb3d539caad2 Mon Sep 17 00:00:00 2001 From: Alex Snaps Date: Mon, 22 Apr 2024 10:17:04 -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 71f255bc..3f9e3da6 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 an additional 2 RTTs to Redis, adding some headroom as well + (response_timeout * 3) + Duration::from_millis(50), ) .await?;