mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-06 19:08:59 -05:00
[PR #23058] [CLOSED] fix: clear stale Redis tasks on startup #27002
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/23058
Author: @yang1002378395-cmyk
Created: 3/26/2026
Status: ❌ Closed
Base:
main← Head:fix-redis-task-ttl📝 Commits (2)
efb0f9afix: add pagination to chat list endpoints to prevent OOMdb10981fix: clear stale Redis tasks on startup📊 Changes
4 files changed (+68 additions, -15 deletions)
View changed files
📝
backend/open_webui/main.py(+3 -0)📝
backend/open_webui/models/chats.py(+19 -9)📝
backend/open_webui/routers/chats.py(+15 -6)📝
backend/open_webui/tasks.py(+31 -0)📄 Description
Problem
After a server crash or unclean shutdown, Redis task records persist indefinitely, causing the error:
This prevents users from generating titles until the Redis records are manually cleared.
Fixes #22525
Root Cause
active_chat_taskscheck returns true for chats with dead tasksSolution
Startup cleanup: Clear all Redis task records when the application starts (since no tasks can survive a restart)
TTL for item task sets: Add 24-hour TTL to item task sets for automatic cleanup
Logging: Log how many stale tasks were cleaned on startup
Changes
backend/open_webui/tasks.py:clear_all_redis_tasks()functionREDIS_TASK_TTLconstant (24 hours)redis_save_task()backend/open_webui/main.py:clear_all_redis_tasks()in lifespanTesting
Checklist
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.