RQ worker fails to start with KeyError: 'name' when CLIENT LIST contains entries without a name (e.g. Dragonfly admin/HTTP connections)
Issue Summary
RQ workers (manage.py rq worker) crash on startup with KeyError: 'name' when Redash uses Dragonfly as its Redis broker and an HTTP client is connected to Dragonfly's admin port.
File "/app/redash/cli/rq.py", line 46, in worker
w = Worker(queues, log_job_description=False, job_monitoring_interval=5)
File "/usr/local/lib/python3.13/site-packages/rq/worker.py", line 211, in __init__
client_adresses = [client['addr'] for client in connection.client_list() if client['name'] == self.name]
KeyError: 'name'On startup, rq.Worker.__init__ calls CLIENT SETNAME and then scans CLIENT LIST to find its own address. rq 1.16.x reads client['name'] without a fallback. Dragonfly lists HTTP connections to its admin port (e.g. a Prometheus scrape of /metrics or a health check) in CLIENT LIST without a name= field:
id=146366 addr=10.0.0.17:38148 laddr=10.0.0.5:9999 fd=32 http=true tid=0 ... phase=setup lib-name= lib-ver=So while any such connection is open, every worker fails to start and ends up crash-looping.
This is fixed in rq 2.x (client.get('name') == self.name in rq/worker/base.py), but the latest 1.x release (1.16.2), which Redash pins, still has the unguarded lookup.
Steps to Reproduce
- Run Dragonfly with an admin port:
dragonfly --admin_port=9999 --admin_nopass --primary_port_http_enabled=false - Point
REDASH_REDIS_URL/RQ_REDIS_URLat it. - Open a keep-alive HTTP connection to the admin port and leave it open, e.g. send one
GET /metrics HTTP/1.1withConnection: keep-alive(like a Prometheus scrape). A bare idle TCP connection is not enough: Dragonfly only dropsname=once the connection has been identified as HTTP. - Run
./manage.py rq worker. It fails withKeyError: 'name'.
Expected: the worker starts. Not finding its own CLIENT LIST entry shouldn't be fatal; rq already falls back to ip_address = 'unknown' when CLIENT SETNAME/CLIENT LIST aren't supported.
Proposed fix
Upgrading to rq 2.x is a larger change, so a small override in redash/tasks/worker.py could do the worker's IP lookup with client.get('name'), matching rq 2.x behaviour. I'm happy to send a PR.
Technical details:
- Redash Version: 26.09.0-dev (
redash/previewimage), rq 1.16.1, redis-py 4.6.0 - Broker: Dragonfly v1.40.2
- How did you install Redash: Docker image on Kubernetes
Source: getredash/redash