Browse Source

chore: add log for redis.exceptions

Signed-off-by: Sihyeon Jang <sihyeon.jang@navercorp.com>
Sihyeon Jang 2 months ago
parent
commit
9067eac4ca
1 changed files with 26 additions and 0 deletions
  1. 26 0
      backend/open_webui/utils/redis.py

+ 26 - 0
backend/open_webui/utils/redis.py

@@ -1,10 +1,14 @@
 import inspect
 from urllib.parse import urlparse
 
+import logging
+
 import redis
 
 from open_webui.env import REDIS_SENTINEL_MAX_RETRY_COUNT
 
+log = logging.getLogger(__name__)
+
 
 class SentinelRedisProxy:
     def __init__(self, sentinel, service, *, async_mode: bool = True, **kw):
@@ -42,7 +46,18 @@ class SentinelRedisProxy:
                         redis.exceptions.ReadOnlyError,
                     ) as e:
                         if i < REDIS_SENTINEL_MAX_RETRY_COUNT - 1:
+                            log.debug(
+                                "Redis sentinel fail-over (%s). Retry %s/%s",
+                                type(e).__name__,
+                                i + 1,
+                                REDIS_SENTINEL_MAX_RETRY_COUNT,
+                            )
                             continue
+                        log.error(
+                            "Redis operation failed after %s retries: %s",
+                            REDIS_SENTINEL_MAX_RETRY_COUNT,
+                            e,
+                        )
                         raise e from e
 
             return _wrapped
@@ -59,7 +74,18 @@ class SentinelRedisProxy:
                         redis.exceptions.ReadOnlyError,
                     ) as e:
                         if i < REDIS_SENTINEL_MAX_RETRY_COUNT - 1:
+                            log.debug(
+                                "Redis sentinel fail-over (%s). Retry %s/%s",
+                                type(e).__name__,
+                                i + 1,
+                                REDIS_SENTINEL_MAX_RETRY_COUNT,
+                            )
                             continue
+                        log.error(
+                            "Redis operation failed after %s retries: %s",
+                            REDIS_SENTINEL_MAX_RETRY_COUNT,
+                            e,
+                        )
                         raise e from e
 
             return _wrapped