fix: chats fail with a 500 error right after Redis restarts (#31619)

After Redis restarted or closed Open WebUI's connections, the first few requests that needed Redis failed. Chat requests answered with a 500 error, and a browser tab connecting at that moment got no live updates, such as streamed replies, until it was reloaded. Open WebUI now reconnects and retries the failed Redis call once when Redis has closed the connection, so requests go through as soon as Redis is back. While Redis is down, requests still fail as before.
This commit is contained in:
Classic298 2026-10-08 19:04:20 +02:00 • committed by GitHub
parent b687225123
commit 7778d7036b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -334,7 +334,9 @@ def get_redis_connection(
)
elif redis_url:
factory = getattr(redis_mod, 'from_url', None) or redis_mod.Redis.from_url
connection = factory(redis_url, decode_responses=decode_responses, **extra)
# reconnect once when Redis has closed a pooled connection, e.g. after a restart
retry = redis_mod.retry.Retry(_redis_sync.backoff.NoBackoff(), 1, supported_errors=(redis_mod.ConnectionError,))
connection = factory(redis_url, decode_responses=decode_responses, retry=retry, **extra)
_CONNECTION_POOL[cache_key] = connection
return connection