Skip to content

[13.x] Make the Redis queue driver cluster-safe (bulk() node-less MULTI; allQueueNames() uses KEYS) - #61198

Open
Orrison wants to merge 1 commit into
laravel:13.xfrom
Orrison:redis-cluster-support
Open

[13.x] Make the Redis queue driver cluster-safe (bulk() node-less MULTI; allQueueNames() uses KEYS)#61198
Orrison wants to merge 1 commit into
laravel:13.xfrom
Orrison:redis-cluster-support

Conversation

@Orrison

@Orrison Orrison commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Fixes two Redis-Cluster issues in the queue driver, both gated to phpredis cluster connections so non-cluster behavior is unchanged:

  1. RedisQueue::bulk() silently drops batched jobs. On a PhpRedisClusterConnection it wraps its pushes in transaction(), which calls RedisCluster::multi() with no node. A cluster transaction must bind to one node, but the pushes route to the queue's {hash tag} slot. So exec() returns false with no exception, the jobs never enqueue, and the connection is poisoned. Bus::batch() therefore reports success and records pending_jobs, but the batch is stuck forever. Only real multi-shard clusters hit it (a single-node cluster hides it). Fix: push each job directly on the cluster branch (the pushes are independent and share one slot) the same "special-case the cluster connection" pattern the framework already uses in Cache\RedisStore::putMany(), RedisTaggedCache::flush(), and RedisBroadcaster.
  2. RedisQueue::allQueueNames() uses KEYS('queues:*'), which is unavailable on managed clusters (e.g. ElastiCache Serverless) and, where available, enumerates per-node (partial on multi-shard). Fix: on a cluster connection, SCAN across all master nodes instead. (Only reached via Queue::all*Jobs(), used by QueueFake in core, latent but worth closing for cluster completeness.)

Non-cluster and Predis paths are untouched. Adds cluster + non-cluster tests for both.

Signed-off-by: Kevin Ullyott <kevin.ullyott@canyongbs.com>
@taylorotwell

Copy link
Copy Markdown
Member

How did you run into this on your app?

@Orrison

Orrison commented Aug 15, 2026

Copy link
Copy Markdown
Contributor Author

How did you run into this on your app?

We use an AWS Redis serverless cache and I recently adopted the https://github.com/cboxdk/laravel-queue-autoscale package to set up an auto scaling queue worker process in ECS.

So ran into this right away when setting that up, as Redis serverless is always a cluster behind a proxy. And we use queues and batches quite heavily.

I've gotten around it and am running well in production by overriding these internal classes to apply these fixes in the interim.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants