We've been using Horizon for a while now with no issues whatsoever. However, we've just released a new feature that puts a high throughput through Horizon and we're now running into the issue below:
Command 'OFFSETGET' is not a registered Redis command.
I can't seem to find anything related to this.
We'll need some code to reproduce this.
@driesvints Please see code below. It's a pretty simple job that uses a repository to insert or update daily metrics per user for our application.
public function __construct(int $userId, string $metricName, int $value = 1, Carbon $date = null)
{
$this->userId = $userId;
$this->metricName = $metricName;
$this->value = $value;
$this->date = $date;
$this->onQueue('metrics');
}
public function handle(UserDailyMetricRepository $repository)
{
$repository->record(
$this->userId,
$this->metricName,
$this->value,
$this->date
);
}
Why do you place the $this->onQueue('metrics'); in the constructer? I don't think you can use it like that. Can you show the code how you dispatch the job and try to place it outside of it?
I always want this job to dispatch to the metrics queue but I didn't want to have to declare it every time I dispatched a job. We simply dispatch them like below:
RecordMetric::dispatch(1234, 'login')
I should have also added that this issue occurs sporadically, so I don't believe that this is an issue with the job or how we dispatch it. From the stacktrace it seems to be an issue with the way Laravel or Horizon is interacting with Predis.
Can you try to Add ->onQueue('metrics'); to RecordMetric::dispatch(1234, 'login')->onQueue('metrics'); instead and remove it from the constructor to see if that solves the problem?
Yeah sure, I'll make that change and get back to you on this. Cheers
Hey @driesvints, made this change but unfortunately, we're still seeing the same error.
I still wonder if we're missing something here. OFFSETGET indicates that you're somewhere trying to access something on the Redis connection as an array while this isn't supported. Can you provide the full stacktrace?
Predis\ClientException Command 'OFFSETGET' is not a registered Redis command.
/home/forge/hegartymaths.com/releases/20191210093602/vendor/predis/predis/src/Profile/RedisProfile.php:88 Predis\Profile\RedisProfile::createCommand
/home/forge/hegartymaths.com/releases/20191210093602/vendor/predis/predis/src/Client.php:323 Predis\Client::createCommand
/home/forge/hegartymaths.com/releases/20191210093602/vendor/predis/predis/src/Pipeline/Pipeline.php:59 Predis\Pipeline\Pipeline::__call
/home/forge/hegartymaths.com/releases/20191210093602/vendor/predis/predis/src/Pipeline/Pipeline.php:165 Predis\Pipeline\Pipeline::flushPipeline
/home/forge/hegartymaths.com/releases/20191210093602/vendor/predis/predis/src/Pipeline/Pipeline.php:214 Predis\Pipeline\Pipeline::execute
/home/forge/hegartymaths.com/releases/20191210093602/vendor/predis/predis/src/Client.php:445 Predis\Client::createPipeline
/home/forge/hegartymaths.com/releases/20191210093602/vendor/predis/predis/src/Client.php:396 Predis\Client::sharedContextFactory
/home/forge/hegartymaths.com/releases/20191210093602/vendor/predis/predis/src/Client.php:418 Predis\Client::pipeline
/home/forge/hegartymaths.com/releases/20191210093602/vendor/laravel/framework/src/Illuminate/Redis/Connections/Connection.php:114 Illuminate\Redis\Connections\Connection::command
/home/forge/hegartymaths.com/releases/20191210093602/vendor/laravel/framework/src/Illuminate/Redis/Connections/Connection.php:214 Illuminate\Redis\Connections\Connection::__call
/home/forge/hegartymaths.com/releases/20191210093602/vendor/laravel/horizon/src/Repositories/RedisJobRepository.php:391 Laravel\Horizon\Repositories\RedisJobRepository::completed
/home/forge/hegartymaths.com/releases/20191210093602/vendor/laravel/horizon/src/Listeners/MarkJobAsComplete.php:46 Laravel\Horizon\Listeners\MarkJobAsComplete::handle
[internal] call_user_func_array
/home/forge/hegartymaths.com/releases/20191210093602/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php:366 Illuminate\Events\Dispatcher::Illuminate\Events\{closure}
/home/forge/hegartymaths.com/releases/20191210093602/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php:196 Illuminate\Events\Dispatcher::dispatch
/home/forge/hegartymaths.com/releases/20191210093602/vendor/laravel/horizon/src/RedisQueue.php:155 Laravel\Horizon\RedisQueue::event
/home/forge/hegartymaths.com/releases/20191210093602/vendor/laravel/horizon/src/RedisQueue.php:124 Laravel\Horizon\RedisQueue::deleteReserved
/home/forge/hegartymaths.com/releases/20191210093602/vendor/laravel/framework/src/Illuminate/Queue/Jobs/RedisJob.php:84 Illuminate\Queue\Jobs\RedisJob::delete
/home/forge/hegartymaths.com/releases/20191210093602/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php:57 Illuminate\Queue\CallQueuedHandler::call
/home/forge/hegartymaths.com/releases/20191210093602/vendor/laravel/framework/src/Illuminate/Queue/Jobs/Job.php:88 Illuminate\Queue\Jobs\Job::fire
/home/forge/hegartymaths.com/releases/20191210093602/vendor/laravel/framework/src/Illuminate/Queue/Worker.php:337 Illuminate\Queue\Worker::process
/home/forge/hegartymaths.com/releases/20191210093602/vendor/laravel/framework/src/Illuminate/Queue/Worker.php:283 Illuminate\Queue\Worker::runJob
/home/forge/hegartymaths.com/releases/20191210093602/vendor/laravel/framework/src/Illuminate/Queue/Worker.php:118 Illuminate\Queue\Worker::daemon
/home/forge/hegartymaths.com/releases/20191210093602/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php:102 Illuminate\Queue\Console\WorkCommand::runWorker
/home/forge/hegartymaths.com/releases/20191210093602/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php:86 Illuminate\Queue\Console\WorkCommand::handle
/home/forge/hegartymaths.com/releases/20191210093602/vendor/laravel/horizon/src/Console/WorkCommand.php:46 Laravel\Horizon\Console\WorkCommand::handle
[internal] call_user_func_array
/home/forge/hegartymaths.com/releases/20191210093602/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:32 Illuminate\Container\BoundMethod::Illuminate\Container\{closure}
/home/forge/hegartymaths.com/releases/20191210093602/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:90 Illuminate\Container\BoundMethod::callBoundMethod
/home/forge/hegartymaths.com/releases/20191210093602/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:34 Illuminate\Container\BoundMethod::call
/home/forge/hegartymaths.com/releases/20191210093602/vendor/laravel/framework/src/Illuminate/Container/Container.php:576 Illuminate\Container\Container::call
/home/forge/hegartymaths.com/releases/20191210093602/vendor/laravel/framework/src/Illuminate/Console/Command.php:183 Illuminate\Console\Command::execute
/home/forge/hegartymaths.com/releases/20191210093602/vendor/symfony/console/Command/Command.php:255 Symfony\Component\Console\Command\Command::run
/home/forge/hegartymaths.com/releases/20191210093602/vendor/laravel/framework/src/Illuminate/Console/Command.php:170 Illuminate\Console\Command::run
/home/forge/hegartymaths.com/releases/20191210093602/vendor/symfony/console/Application.php:921 Symfony\Component\Console\Application::doRunCommand
/home/forge/hegartymaths.com/releases/20191210093602/vendor/symfony/console/Application.php:273 Symfony\Component\Console\Application::doRun
/home/forge/hegartymaths.com/releases/20191210093602/vendor/symfony/console/Application.php:149 Symfony\Component\Console\Application::run
/home/forge/hegartymaths.com/releases/20191210093602/vendor/laravel/framework/src/Illuminate/Console/Application.php:90 Illuminate\Console\Application::run
/home/forge/hegartymaths.com/releases/20191210093602/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:133 Illuminate\Foundation\Console\Kernel::handle
/home/forge/hegartymaths.com/releases/20191210093602/artisan:37 [main]
What are you using as a Redis store? Which Redis version is it using?
From the stacktrace above, I suspect the problem lies with Predis as I can't see anything going wrong on a Horizon line.
Are you using Redis clusters? I found this issue: https://github.com/nrk/predis/issues/547
So we're just using Redis from a server provisioned via Forge.
Looks like we're running Redis 4.0.11.
Nope not using clusters, literally just a server provisioned on Forge. Our Laravel app is configured to use the Redis host from that IP.
Cheers for your help so far Dries.
I note that PHPRedis is recommended now, is it advisable to switch over?
I note that PHPRedis is recommended now, is it advisable to switch over?
@DanielKeeble yes definitely because Predis has been unmaintained for over two years now.
@DanielKeeble you might have to manually install phpredis as we're only recently rolled out the automatic installation of that in Forge.
Okay, cheers for the heads up on that. I think I'll spend some time looking into getting us switched over.
@DanielKeeble I just recently switched over from predis to PhpRedis, and it's relatively easy.
SSH into your server. sudo apt install php-redis. This should install and activate it, but if it doesn't, run sudo phpenmod redis. Then just make the appropriate updates in your config files.
@DanielKeeble I just recently switched over from predis to PhpRedis, and it's relatively easy.
SSH into your server.
sudo apt install php-redis. This should install and activate it, but if it doesn't, runsudo phpenmod redis. Then just make the appropriate updates in your config files.
Brilliant, cheers for this Andrew 馃憤馃徎
Hey @driesvints, we released the change to use PHPRedis this morning and I haven't seen any instances of this error occurring 馃帀 I'll update this issue if we do.
Most helpful comment
Hey @driesvints, we released the change to use PHPRedis this morning and I haven't seen any instances of this error occurring 馃帀 I'll update this issue if we do.