Fixes task stop commands not working when using Redis Cluster mode.
Problem
When Open WebUI is configured with Redis Cluster (REDIS_CLUSTER=true), the task stop endpoint fails because:
RedisCluster object doesn't have a direct publish method
Even using execute_command('PUBLISH', ...) doesn't work because standard Redis PUBLISH is node-local in cluster mode — messages only reach subscribers connected to that specific node
Solution
Implement sharded pub/sub (SPUBLISH/SSUBSCRIBE) for Redis Cluster mode:
Add helper to detect cluster mode via nodes_manager attribute
Update send command function to use SPUBLISH for cluster, publish for standard
Update task command listener to use ssubscribe for cluster, subscribe for standard
Handle different message types ("smessage" vs "message")
Sharded pub/sub properly routes messages across all cluster nodes based on channel hash slot, ensuring all worker nodes receive task commands.
Standard Redis: No change in behavior, uses regular pub/sub
Redis Cluster: Now uses sharded pub/sub for proper cross-node message delivery
Contributor License Agreement
By submitting this pull request, I confirm that I have read and fully agree to the Contributor License Agreement (CLA), and I am providing my contributions under its terms.
Note
Deleting the CLA section will lead to immediate closure of your PR and it will not be merged in.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.
## 📋 Pull Request Information
**Original PR:** https://github.com/open-webui/open-webui/pull/20246
**Author:** [@Classic298](https://github.com/Classic298)
**Created:** 12/29/2025
**Status:** ❌ Closed
**Base:** `dev` ← **Head:** `redis`
---
### 📝 Commits (2)
- [`5f96004`](https://github.com/open-webui/open-webui/commit/5f96004baf3ee5bfc06ee54f30339326e89e620c) Update tasks.py
- [`17bdfa8`](https://github.com/open-webui/open-webui/commit/17bdfa89836a249008a6acfd3a3d7ddf64af9ca3) Update tasks.py
### 📊 Changes
**1 file changed** (+41 additions, -1 deletions)
<details>
<summary>View changed files</summary>
📝 `backend/open_webui/tasks.py` (+41 -1)
</details>
### 📄 Description
### Summary
Fixes task stop commands not working when using Redis Cluster mode.
### Problem
When Open WebUI is configured with Redis Cluster (`REDIS_CLUSTER=true`), the task stop endpoint fails because:
1. `RedisCluster` object doesn't have a direct `publish` method
2. Even using `execute_command('PUBLISH', ...)` doesn't work because standard Redis PUBLISH is node-local in cluster mode — messages only reach subscribers connected to that specific node
### Solution
Implement sharded pub/sub (`SPUBLISH`/`SSUBSCRIBE`) for Redis Cluster mode:
- Add helper to detect cluster mode via `nodes_manager` attribute
- Update send command function to use `SPUBLISH` for cluster, `publish` for standard
- Update task command listener to use `ssubscribe` for cluster, `subscribe` for standard
- Handle different message types (`"smessage"` vs `"message"`)
Sharded pub/sub properly routes messages across all cluster nodes based on channel hash slot, ensuring all worker nodes receive task commands.
### Related
Fixes #19840
### Testing
- Standard Redis: No change in behavior, uses regular pub/sub
- Redis Cluster: Now uses sharded pub/sub for proper cross-node message delivery
### Contributor License Agreement
By submitting this pull request, I confirm that I have read and fully agree to the [Contributor License Agreement (CLA)](https://github.com/open-webui/open-webui/blob/main/CONTRIBUTOR_LICENSE_AGREEMENT), and I am providing my contributions under its terms.
> [!NOTE]
> Deleting the CLA section will lead to immediate closure of your PR and it will not be merged in.
---
<sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/20246
Author: @Classic298
Created: 12/29/2025
Status: ❌ Closed
Base:
dev← Head:redis📝 Commits (2)
5f96004Update tasks.py17bdfa8Update tasks.py📊 Changes
1 file changed (+41 additions, -1 deletions)
View changed files
📝
backend/open_webui/tasks.py(+41 -1)📄 Description
Summary
Fixes task stop commands not working when using Redis Cluster mode.
Problem
When Open WebUI is configured with Redis Cluster (
REDIS_CLUSTER=true), the task stop endpoint fails because:RedisClusterobject doesn't have a directpublishmethodexecute_command('PUBLISH', ...)doesn't work because standard Redis PUBLISH is node-local in cluster mode — messages only reach subscribers connected to that specific nodeSolution
Implement sharded pub/sub (
SPUBLISH/SSUBSCRIBE) for Redis Cluster mode:nodes_managerattributeSPUBLISHfor cluster,publishfor standardssubscribefor cluster,subscribefor standard"smessage"vs"message")Sharded pub/sub properly routes messages across all cluster nodes based on channel hash slot, ensuring all worker nodes receive task commands.
Related
Fixes #19840
Testing
Contributor License Agreement
By submitting this pull request, I confirm that I have read and fully agree to the Contributor License Agreement (CLA), and I am providing my contributions under its terms.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.