Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERROR: Undefined offset: 1 when run queue:work #23756

Closed
agolovenkin opened this issue Mar 30, 2018 · 1 comment
Closed

ERROR: Undefined offset: 1 when run queue:work #23756

agolovenkin opened this issue Mar 30, 2018 · 1 comment

Comments

@agolovenkin
Copy link

  • Laravel Version: 5.6.15
  • PHP Version: 7.2.3-1
  • QUEUE_DRIVER=redis
  • Redis driver: phpredis
  • Redis: 4.0.7

Description:

After run php artisan queue:work I see the following error every 7 seconds in my log:

[2018-03-30 19:13:53] local.ERROR: Undefined offset: 1 {"exception":"[object] (ErrorException(code: 0): Undefined offset: 1 at /home/workplace/api/vendor/laravel/framework/src/Illuminate/Queue/RedisQueue.php:233)
[stacktrace]
#0 /home/workplace/api/vendor/laravel/framework/src/Illuminate/Queue/RedisQueue.php(233): Illuminate\\Foundation\\Bootstrap\\HandleExceptions->handleError(8, 'Undefined offse...', '/home/...', 233, Array)
#1 /home/workplace/api/vendor/laravel/framework/src/Illuminate/Queue/RedisQueue.php(213): Illuminate\\Queue\\RedisQueue->blockingPop('queues:default')
#2 /home/workplace/api/vendor/laravel/framework/src/Illuminate/Queue/RedisQueue.php(165): Illuminate\\Queue\\RedisQueue->retrieveNextJob('queues:default')
#3 /home/workplace/api/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(246): Illuminate\\Queue\\RedisQueue->pop('default')
#4 /home/workplace/api/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(107): Illuminate\\Queue\\Worker->getNextJob(Object(Illuminate\\Queue\\RedisQueue), 'default')
#5 /home/workplace/api/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(101): Illuminate\\Queue\\Worker->daemon('redis', 'default', Object(Illuminate\\Queue\\WorkerOptions))
#6 /home/workplace/api/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(85): Illuminate\\Queue\\Console\\WorkCommand->runWorker('redis', 'default')
#7 [internal function]: Illuminate\\Queue\\Console\\WorkCommand->handle()
#8 /home/workplace/api/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(29): call_user_func_array(Array, Array)
#9 /home/workplace/api/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(87): Illuminate\\Container\\BoundMethod::Illuminate\\Container\\{closure}()
#10 /home/workplace/api/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(31): Illuminate\\Container\\BoundMethod::callBoundMethod(Object(Illuminate\\Foundation\\Application), Array, Object(Closure))
#11 /home/workplace/api/vendor/laravel/framework/src/Illuminate/Container/Container.php(564): Illuminate\\Container\\BoundMethod::call(Object(Illuminate\\Foundation\\Application), Array, Array, NULL)
#12 /home/workplace/api/vendor/laravel/framework/src/Illuminate/Console/Command.php(183): Illuminate\\Container\\Container->call(Array)
#13 /home/workplace/api/vendor/symfony/console/Command/Command.php(252): Illuminate\\Console\\Command->execute(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Illuminate\\Console\\OutputStyle))
#14 /home/workplace/api/vendor/laravel/framework/src/Illuminate/Console/Command.php(170): Symfony\\Component\\Console\\Command\\Command->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Illuminate\\Console\\Outpu
tStyle))
#15 /home/workplace/api/vendor/symfony/console/Application.php(865): Illuminate\\Console\\Command->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#16 /home/workplace/api/vendor/symfony/console/Application.php(241): Symfony\\Component\\Console\\Application->doRunCommand(Object(Illuminate\\Queue\\Console\\WorkCommand), Object(Symfony\\Component\\Console\\Input\\ArgvInput), O
bject(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#17 /home/workplace/api/vendor/symfony/console/Application.php(143): Symfony\\Component\\Console\\Application->doRun(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput
))
#18 /home/workplace/api/vendor/laravel/framework/src/Illuminate/Console/Application.php(88): Symfony\\Component\\Console\\Application->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\
\Output\\ConsoleOutput))
#19 /home/workplace/api/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(122): Illuminate\\Console\\Application->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\
Output\\ConsoleOutput))
#20 /home/workplace/api/artisan(37): Illuminate\\Foundation\\Console\\Kernel->handle(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#21 {main}
"}

It does not affect worker but looks ugly.

@pdavide
Copy link
Contributor

pdavide commented Mar 30, 2018

Hi, I experienced the same bug.
It does not affect worker but it can pollute you log files.
I think it can be easily fixed changing ! is_null() to ! empty() here.
As you can see in this phpredis test an empty array (not a null value) is returned if no elements are found in the list.
I'll write a simple PR asap.

pdavide added a commit to pdavide/framework that referenced this issue Mar 30, 2018
When using phpredis, `blpop` returns an empty array if no elements are found in the list.
This can be easily deduced looking at [this test](https://github.com/phpredis/phpredis/blob/300c72510c48e210338826b713f260a4eda8abc7/tests/RedisTest.php#L833).

Fix laravel#23756.
taylorotwell pushed a commit that referenced this issue Mar 31, 2018
When using phpredis, `blpop` returns an empty array if no elements are found in the list.
This can be easily deduced looking at [this test](https://github.com/phpredis/phpredis/blob/300c72510c48e210338826b713f260a4eda8abc7/tests/RedisTest.php#L833).

Fix #23756.
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

No branches or pull requests

2 participants