mirror of
https://github.com/open-webui/open-webui.git
synced 2026-07-11 10:34:13 -05:00
[GH-ISSUE #21410] bug: Memory leak in SESSION_POOL, USAGE_POOL and YdocManager (with and without Redis) #19467
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?
Originally created by @ashm-dev on GitHub (Feb 14, 2026).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/21410
Description
The in-memory data structures
SESSION_POOL,USAGE_POOL, andYdocManager._updatesgrow unboundedly, causing steady RAM increase that only resolves on restart.This affects both modes:
RedisDictuseshsetwithoutexpire— no TTL is ever set on keys. Storing data in Redis without TTL is problematic: it defeats Redis's ability to manage memory via eviction policies, and effectively turns Redis into an ever-growing store.Root Causes
1. USAGE_POOL not cleaned on disconnect
File:
backend/open_webui/socket/main.pyOn disconnect,
SESSION_POOL[sid]is deleted, butUSAGE_POOLentries for thatsidare only cleaned viaperiodic_usage_pool_cleanup()on timeout. If a socket closes without timing out first, entries persist indefinitely.2. YdocManager._updates grows without bound
File:
backend/open_webui/socket/utils.pyEvery document edit appends to a list that is never evicted (neither in-memory nor in Redis):
With Redis,
rpushis used withoutexpire— same problem.clear_document()is only called when all users leave a document. If at least one user stays connected, updates accumulate forever.3. RedisDict stores data without TTL
File:
backend/open_webui/socket/utils.pyRedisDictuseshset/hgetwith no expiration.SESSION_POOL,USAGE_POOL, andMODELSdata persists in Redis indefinitely. This is undesirable — data in Redis should have TTL to allow proper memory management and prevent unbounded growth.Observed Behavior
Expected Behavior
USAGE_POOLentries for asidshould be removed on disconnectYdocManager._updatesshould have a size limit or TTLRedisDictshould set TTL on keys (e.g. session data should expire after disconnect + grace period)SESSION_POOL,USAGE_POOLshould have reasonable expiration times@tjbck commented on GitHub (Feb 16, 2026):
Addressed in dev.