mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-06 19:08:59 -05:00
[GH-ISSUE #19840] issue: Bug: RedisCluster publish Fails on POST /api/tasks/stop/{task_id} #57681
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 @Salamastik on GitHub (Dec 9, 2025).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/19840
Check Existing Issues
Installation Method
Docker
Open WebUI Version
v0.6.40
Ollama Version (if applicable)
No response
Operating System
debiangnu/linux 12
Browser (if applicable)
chrome 111.0.5563.65
Confirmation
README.md.Expected Behavior
The POST /api/tasks/stop/{task_id} endpoint should reliably stop the task, which requires the control message to reach all potential worker nodes in the cluster.
When using Redis Cluster for Pub/Sub, the message should be broadcast to all master nodes in the cluster to ensure that all consumers (subscribers) receive the command, regardless of which node they are connected to.
Actual Behavior
When Open WebUI is configured to use a Redis Cluster, executing a request to the task-stopping API endpoint results in a fatal AttributeError because the underlying Redis client is a RedisCluster instance which lacks a direct publish method.
The issue is triggered specifically when calling:
POST /api/tasks/stop/{task_id}
This request leads to the following code being executed in /backend/open_webui/tasks.py:
async def redis_send_command(redis: Redis, command: dict):
await redis.publish(REDIS_PUBSUB_CHANNEL, json.dumps(command))
Even if a custom implementation allowed publish on the cluster object, standard Redis Cluster architecture dictates that PUBLISH commands are node-local and do not broadcast across the cluster. Therefore, a single publish call would only reach subscribers on the single, randomly selected node, leading to inconsistent application state across workers/nodes.
Steps to Reproduce
The RedisCluster client object does not implement publish directly; instead, it requires iterating through its nodes and calling publish on each node's client.
The Redis publishing function should be robust against both standard Redis connections and RedisCluster connections. When a RedisCluster is detected, the message must be manually broadcast to every master node in the cluster to ensure all subscribers (workers) receive the command.
Logs & Screenshots
AttributeError: 'RedisCluster' object has no attribute 'publish'
Additional Information
No response
@owui-terminator[bot] commented on GitHub (Dec 9, 2025):
🔍 Similar Issues Found
I found some existing issues that might be related to this one. Please check if any of these are duplicates or contain helpful solutions:
#19480 issue: v0.6.40 cannot start anymore with TLS redis configured (ValueError: Unsupported Redis URL schema: rediss)
by nick-hicx • Nov 25, 2025 •
bug#19496 issue: 500 internal server error appears in v0.6.40
by cloudtuotuo • Nov 26, 2025 •
bug#19777 issue:
by Yaute7 • Dec 05, 2025 •
bug#16157 issue: Backend cannot connect to Redis in cluster mode
by erhhung • Jul 30, 2025 •
bug#16236 issue: Tasks don't work on large context prompts (Renaming chat, etc)
by frenzybiscuit • Aug 02, 2025 •
bugShow 5 more related issues
#18073 issue: Redis ReadOnlyError with new Open WebUI Version
by koflerm • Oct 06, 2025 •
bug#19563 issue:
by naruto7g • Nov 28, 2025 •
bug#14068 issue: database is locked error on a multi-node cluster
by JTHesse • May 20, 2025 •
bug#15074 issue: Redis in Cluster Mode - Keys in request don't hash to the same slot
by taylorwilsdon • Jun 17, 2025 •
bug#19211 issue:
by Byrnes9 • Nov 16, 2025 •
bug💡 Tips:
This comment was generated automatically by a bot. Please react with a 👍 if this comment was helpful, or a 👎 if it was not.
@Salamastik commented on GitHub (Dec 10, 2025):
I checked the existing issues and they are not related to this specific problem. They describe different scenarios and do not contain a solution.
@Classic298 commented on GitHub (Dec 10, 2025):
@Ithanil do you know anything here?
@Ithanil commented on GitHub (Dec 10, 2025):
No, I have no experience with a Redis cluster setup.
But I think the path to a solution is outlined in the issue:
@rgaricano commented on GitHub (Dec 10, 2025):
@Salamastik,
Could you try with this fix:
98f5f683a6?@Salamastik commented on GitHub (Dec 10, 2025):
I tried the suggested fix: rgaricano@98f5f68
Unfortunately, it failed with the following error:
File "/app/backendopen_webui/tasks.py", line 80, in redis_send_command
for node in redis.get_master_nodes():
AttributeError: 'RedisCluster' object has no attribute 'get_master_nodes'
@rgaricano commented on GitHub (Dec 10, 2025):
@Salamastik,
Sorry, for the mistake. I revised and it's easiars as I did, just doing a share publising of the message
(https://redis.io/docs/latest/commands/spublish/ )
But also I can't test it now (not using cluster)
(I think that in the referenced commit I lost the last parenthesis )
@Salamastik commented on GitHub (Dec 11, 2025):
@rgaricano
Thank you for the suggestion!
When attempting to execute the suggested code, it failed with the following error:
AttributeError: 'RedisCluster' object has no attribute 'spublish'
1. Environment Details
redis(version 7.1.0)redis.cluster.RedisCluster.from_url(...)RedisClusterobject does not seem to expose thespublishmethod directly in this version of the client library.2. Workarounds Attempted and Results
I subsequently tried two different common methods for publishing messages via a
RedisClusterinstance, which led to mixed results:redis.pubsub_publish(REDIS_PUBSUB_CHANNEL, command_json)
Failed: AttributeError: 'RedisCluster' object has no attribute 'pubsub_publish'
redis.execute_command('PUBLISH', REDIS_PUBSUB_CHANNEL, command_json)
This command executed successfully without raising an exception. However, the intended functionality (the task was not stopping) is still not working as intended.
@koflerm commented on GitHub (Dec 22, 2025):
+1 for this issue. We see the same behavior with our setup, as well using Redis Cluster.
@rgaricano commented on GitHub (Dec 22, 2025):
@Salamastik,
yes, the redis-py library's RedisCluster object doesn't have an spublish method. In Redis cluster mode, sharded pub/sub commands (SPUBLISH, SSUBSCRIBE) are server-side commands, but the Python client library doesn't expose them as methods on the cluster client object.
This is why you get the AttributeError.
The cluster client requires using execute_command for commands that aren't directly exposed as methods.
workaround:
@Salamastik commented on GitHub (Dec 29, 2025):
@rgaricano
Thanks for the comment! I tried it, but it behaves the same as: redis.execute_command('PUBLISH', REDIS_PUBSUB_CHANNEL, command_json)
The code executes successfully without any exceptions, but the task is still not stopping. It’s still not working as intended.
@koflerm, maybe you can try it too and see if you get the same result?
@Classic298 commented on GitHub (Dec 29, 2025):
@Salamastik
please test this
https://github.com/open-webui/open-webui/pull/20246
@Salamastik commented on GitHub (Dec 31, 2025):
@Classic298
Thanks for the suggestion! Unfortunately, it doesn't seem to work. There are no error messages in the console, but the response never stops.
@Classic298 commented on GitHub (Dec 31, 2025):
@Salamastik can you give it another shot please?
@Salamastik commented on GitHub (Jan 4, 2026):
@Classic298
It is still not working, and there are no errors in the console...
@Salamastik commented on GitHub (Jan 21, 2026):
Confirmed! This is working perfectly now. Thanks @HANIHALILI for the fix, much appreciated! 🙌
@tjbck commented on GitHub (Feb 12, 2026):
@Salamastik could you confirm if this issue has been addressed in the latest dev?
@Salamastik commented on GitHub (Feb 13, 2026):
Hi @tjbck,
I tested this exact approach (redis.execute_command('PUBLISH', ...)) about a month ago. As mentioned in the issue, while the command executes without errors, it does not reliably stop tasks in a RedisCluster setup — the cancellation message does not consistently propagate across nodes.
In my testing, the state-based approach introduced in this PR by @HANIHALILI behaves consistently in a clustered environment and successfully stops tasks across nodes.
If there were additional changes beyond this specific modification, I’d be happy to review them in case they impact the behavior. However, based on my current testing, this particular change alone does not resolve the issue
@luke-wren commented on GitHub (Mar 6, 2026):
I'm experiencing the same issues on my instance. I can confirm the fix in https://github.com/open-webui/open-webui/pull/20803 resolves the problem.
@nwon910 commented on GitHub (Apr 21, 2026):
I'm experiencing the same issues, using Redis Cluster as well, on the most current version of v0.9.1