php-resque
php-resque copied to clipboard
Cannot use 'KEYS' with redis-cluster.
Hi, i'm using predis, but when i start the workers i'm getting this message:
** [12:21:53 2019-10-25] Starting worker
[Predis\NotSupportedException]
Cannot use 'KEYS' with redis-cluster.
Config file:
predis:
namespace: namespace
config:
- "tcp://server1:9991"
- "tcp://server1:9992"
- "tcp://server1:9993"
options:
cluster: "redis"
Can anyone help me please? thanks
is there a stacktrace too?
Sure
** [12:21:53 2019-10-25] Starting worker
[Predis\NotSupportedException]
Cannot use 'KEYS' with redis-cluster.
Exception trace:
() at WORK_DIR/composer/vendor/predis/predis/src/Connection/Aggregate/RedisCluster.php:380
Predis\Connection\Aggregate\RedisCluster->getConnection() at WORK_DIR/composer/vendor/predis/predis/src/Connection/Aggregate/RedisCluster.php:550
Predis\Connection\Aggregate\RedisCluster->retryCommandOnFailure() at WORK_DIR/composer/vendor/predis/predis/src/Connection/Aggregate/RedisCluster.php:593
Predis\Connection\Aggregate\RedisCluster->executeCommand() at WORK_DIR/composer/vendor/predis/predis/src/Client.php:331
Predis\Client->executeCommand() at WORK_DIR/composer/vendor/predis/predis/src/Client.php:314
Predis\Client->__call() at n/a:n/a
call_user_func_array() at WORK_DIR/composer/vendor/mjphaynes/php-resque/src/Resque/Redis.php:340
Resque\Redis->__call() at WORK_DIR/composer/vendor/mjphaynes/php-resque/src/Resque/Worker.php:846
Resque\Worker->cleanup() at WORK_DIR/composer/vendor/mjphaynes/php-resque/src/Resque/Worker.php:402
Resque\Worker->startup() at WORK_DIR/composer/vendor/mjphaynes/php-resque/src/Resque/Worker.php:235
Resque\Worker->work() at WORK_DIR/composer/vendor/mjphaynes/php-resque/src/Resque/Commands/Worker/Start.php:73
Resque\Commands\Worker\Start->execute() at WORK_DIR/composer/vendor/symfony/console/Command/Command.php:264
Symfony\Component\Console\Command\Command->run() at WORK_DIR/composer/vendor/symfony/console/Application.php:841
Symfony\Component\Console\Application->doRunCommand() at WORK_DIR/composer/vendor/symfony/console/Application.php:206
Symfony\Component\Console\Application->doRun() at WORK_DIR/composer/vendor/symfony/console/Application.php:125
Thanks for reporting this issue, @fredams and for the quick response, @scones!
Apparently, KEYS should not be used according to the Redis-Docs[1], so the Predis Library used by php-resque does not support it for clustered configurations[2].
The best solution would be to refactor the related code to use SCAN or Redis sets instead of KEYS. PRs are welcome for that :smile:
[1] https://redis.io/commands/keys [2] https://github.com/nrk/predis/issues/172