Skip to content

phpredis serialization and compression error #1113

@it-can

Description

@it-can

@TheLevti I tested this quickly with Laravel Horizon, but when adding jobs I get this error. When not using compression/serializer it works perfect...
So it seems Horizon is not completely compatible with Redis serializer/compression (I see the values in Redis being serialized though).

database.php

'options' => [
            'cluster' => env('REDIS_CLUSTER', 'redis'),
            'serializer'  => Redis::SERIALIZER_MSGPACK,
            'compression' => Redis::COMPRESSION_LZ4,
        ],

horizon/src/JobPayload.php:48

ErrorException · Trying to access array offset on value of type null
ErrorException Trying to access array offset on value of type null 
    vendor/laravel/horizon/src/JobPayload.php:48 Illuminate\Foundation\Bootstrap\HandleExceptions::handleError
    vendor/laravel/horizon/src/JobPayload.php:48 Laravel\Horizon\JobPayload::id
    vendor/laravel/horizon/src/Repositories/RedisJobRepository.php:428 Laravel\Horizon\Repositories\RedisJobRepository::Laravel\Horizon\Repositories\{closure}
    vendor/laravel/framework/src/Illuminate/Support/helpers.php:263 tap
    vendor/laravel/framework/src/Illuminate/Redis/Connections/PhpRedisConnection.php:408 Illuminate\Redis\Connections\PhpRedisConnection::pipeline
    vendor/laravel/horizon/src/Repositories/RedisJobRepository.php:435 Laravel\Horizon\Repositories\RedisJobRepository::migrated
    vendor/laravel/horizon/src/Listeners/MarkJobsAsMigrated.php:36 Laravel\Horizon\Listeners\MarkJobsAsMigrated::handle
    vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php:424 Illuminate\Events\Dispatcher::Illuminate\Events\{closure}
    vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php:249 Illuminate\Events\Dispatcher::dispatch
    vendor/laravel/horizon/src/RedisQueue.php:196 Laravel\Horizon\RedisQueue::event
    vendor/laravel/horizon/src/RedisQueue.php:150 Laravel\Horizon\RedisQueue::Laravel\Horizon\{closure}
    vendor/laravel/framework/src/Illuminate/Support/helpers.php:263 tap
    vendor/laravel/horizon/src/RedisQueue.php:151 Laravel\Horizon\RedisQueue::migrateExpiredJobs
    vendor/laravel/framework/src/Illuminate/Queue/RedisQueue.php:230 Illuminate\Queue\RedisQueue::migrate
    vendor/laravel/framework/src/Illuminate/Queue/RedisQueue.php:210 Illuminate\Queue\RedisQueue::pop
    vendor/laravel/horizon/src/RedisQueue.php:133 Laravel\Horizon\RedisQueue::pop
    vendor/laravel/framework/src/Illuminate/Queue/Worker.php:345 Illuminate\Queue\Worker::Illuminate\Queue\{closure}
    vendor/laravel/framework/src/Illuminate/Queue/Worker.php:354 Illuminate\Queue\Worker::getNextJob
    vendor/laravel/framework/src/Illuminate/Queue/Worker.php:159 Illuminate\Queue\Worker::daemon
    vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php:117 Illuminate\Queue\Console\WorkCommand::runWorker
    vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php:101 Illuminate\Queue\Console\WorkCommand::handle
    vendor/laravel/horizon/src/Console/WorkCommand.php:51 Laravel\Horizon\Console\WorkCommand::handle
    vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:36 Illuminate\Container\BoundMethod::Illuminate\Container\{closure}
    vendor/laravel/framework/src/Illuminate/Container/Util.php:40 Illuminate\Container\Util::unwrapIfClosure
    vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:93 Illuminate\Container\BoundMethod::callBoundMethod
    vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:37 Illuminate\Container\BoundMethod::call
    vendor/laravel/framework/src/Illuminate/Container/Container.php:653 Illuminate\Container\Container::call
    vendor/laravel/framework/src/Illuminate/Console/Command.php:136 Illuminate\Console\Command::execute
    vendor/symfony/console/Command/Command.php:298 Symfony\Component\Console\Command\Command::run
    vendor/laravel/framework/src/Illuminate/Console/Command.php:121 Illuminate\Console\Command::run
    vendor/symfony/console/Application.php:1005 Symfony\Component\Console\Application::doRunCommand
    vendor/symfony/console/Application.php:299 Symfony\Component\Console\Application::doRun
    vendor/symfony/console/Application.php:171 Symfony\Component\Console\Application::run
    vendor/laravel/framework/src/Illuminate/Console/Application.php:94 Illuminate\Console\Application::run
    vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:129 Illuminate\Foundation\Console\Kernel::handle
    artisan:37 [main]

Originally posted by @it-can in laravel/framework#40282 (comment)

Comments by @TheLevti

--
Well I don't know what Horizon is doing, maybe same as the redlock algorithm it is using some eval calls, which need to be packed. Can you point me to some classes where it fails?

It looks like Horizon is creating it's own connection by picking some params from the config: https://github.com/laravel/horizon/blob/5.x/src/Connectors/RedisConnector.php

--
Also https://github.com/laravel/horizon/blob/5.x/src/LuaScripts.php those script calls need to pack their arguments for commands where phpredis packs them.

Some connection adjustments and additional tests with different serializer/compression setups should solve the issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions