laravel / framework

The Laravel Framework.
https://laravel.com
MIT License
32.7k stars 11.06k forks source link

Cache::flexible fails with Redis error "Error processing EXEC across the cluster" #53266

Open BernhardK91 opened 1 month ago

BernhardK91 commented 1 month ago

Laravel Version

11.28.1

PHP Version

8.3

Database Driver & Version

No response

Description

We use a Redis Cluster in AWS. After adding Cache::flexibel it fails with a RedisClusterException Error processing EXEC across the cluster (/var/task/vendor/laravel/framework/src/Illuminate/Redis/Connections/Connection.php:116).

I'm not sure yet, why that is, but I assume it is caused by the usage of putMany method in the RedisStore.php. This uses transactions by calling multi() and later exec(). It seems that is not supported in clusters.

Steps To Reproduce

User a Redis cluster as cache store. Add a Cache::flexible to a controller and execute it.

github-actions[bot] commented 1 month ago

Thank you for reporting this issue!

As Laravel is an open source project, we rely on the community to help us diagnose and fix issues as it is not possible to research and fix every issue reported to us via GitHub.

If possible, please make a pull request fixing the issue you have described, along with corresponding tests. All pull requests are promptly reviewed by the Laravel team.

Thank you!

harrygulliford commented 1 month ago

I'm also hitting this issue on Vapor with a Redis 6.x cache.

Partial stack trace:

RedisClusterException: Error processing EXEC across the cluster
#97 /vendor/laravel/framework/src/Illuminate/Redis/Connections/Connection.php(116): RedisCluster::exec
#96 /vendor/laravel/framework/src/Illuminate/Redis/Connections/Connection.php(116): Illuminate\Redis\Connections\Connection::command
#95 /vendor/laravel/framework/src/Illuminate/Redis/Connections/PhpRedisConnection.php(530): Illuminate\Redis\Connections\PhpRedisConnection::command
#94 /vendor/laravel/framework/src/Illuminate/Redis/Connections/Connection.php(229): Illuminate\Redis\Connections\Connection::__call
#93 /vendor/laravel/framework/src/Illuminate/Redis/Connections/PhpRedisConnection.php(563): Illuminate\Redis\Connections\PhpRedisConnection::__call
#92 /vendor/laravel/framework/src/Illuminate/Cache/RedisStore.php(139): Illuminate\Cache\RedisStore::putMany
#91 /vendor/laravel/framework/src/Illuminate/Cache/Repository.php(278): Illuminate\Cache\Repository::putMany
#90 /vendor/laravel/framework/src/Illuminate/Cache/Repository.php(491): Illuminate\Cache\Repository::Illuminate\Cache\{closure}
#89 /vendor/laravel/framework/src/Illuminate/Support/helpers.php(380): tap
#88 /vendor/laravel/framework/src/Illuminate/Cache/Repository.php(491): Illuminate\Cache\Repository::flexible
#87 /vendor/laravel/framework/src/Illuminate/Cache/CacheManager.php(440): Illuminate\Cache\CacheManager::__call
#86 /vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(358): Illuminate\Support\Facades\Facade::__callStatic
henriksan commented 6 days ago

I get same error running Redis 7.x Serverless on laravel Vapor. I have REDIS_CLUSTER_ENABLED=true in my .env though using laravel version 11.33.2 code executed to cause error Cache::flexible('venue_logos', [60, 300], function () {