[PR #20246] [CLOSED] fix: use sharded pub/sub for Redis Cluster task commands #48567

Closed
opened 2026-04-30 00:35:04 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/20246
Author: @Classic298
Created: 12/29/2025
Status: Closed

Base: devHead: redis


📝 Commits (2)

📊 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:

  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.

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), 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>
GiteaMirror added the pull-request label 2026-04-30 00:35:04 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#48567