mirror of
https://github.com/open-webui/open-webui.git
synced 2026-10-05 02:41:34 +00:00
fix: chats fail with a 500 error right after Redis restarts
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:
parent
3819dc2793
commit
7552b01b3f
1 changed files with 3 additions and 1 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue