mirror of
https://github.com/open-webui/open-webui.git
synced 2026-09-06 08:18:53 +00:00
fix: wrap lock acquire/renew in try/except for Redis fault tolerance
This commit is contained in:
parent
daf107a993
commit
621289d8d8
1 changed files with 12 additions and 2 deletions
|
|
@ -177,13 +177,23 @@ async def run_with_lock(acquire_fn, renew_fn, release_fn, work_fn, interval, loc
|
|||
If lock renewal fails, releases and re-acquires before continuing.
|
||||
"""
|
||||
while True:
|
||||
if not acquire_fn():
|
||||
try:
|
||||
acquired = acquire_fn()
|
||||
except Exception:
|
||||
log.exception('Lock acquisition error; will retry')
|
||||
acquired = False
|
||||
if not acquired:
|
||||
await asyncio.sleep(random.uniform(lock_timeout / 2, lock_timeout))
|
||||
continue
|
||||
|
||||
try:
|
||||
while True:
|
||||
if not renew_fn():
|
||||
try:
|
||||
renewed = renew_fn()
|
||||
except Exception:
|
||||
log.exception('Lock renewal error; will re-acquire')
|
||||
renewed = False
|
||||
if not renewed:
|
||||
log.info('Lock renewal failed. Will re-acquire.')
|
||||
break
|
||||
try:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue