3
votes

I have "randomly" some jobs failing in my beanstalked queue. Two questions:

1/ By looking at the failed job table in the DB how can I interprate what is logged inside? The Data closure means "nothing" when reading it raw. Is there something to do to have more info?

2/ I went through the console logs of Laravel and this is what fails:

[2015-04-29 15:40:51] production.ERROR: exception 'ErrorException' with message 'Trying to get property of non-object' in /home/forge/api.hello.me/vendor/jeremeamia/SuperClosure/src/Jeremeamia/SuperClosure/SerializableClosure.php(99) : eval()'d code:6
Stack trace:...

However I have no clue what exactly is failing... the stacktrace doesn't help and just starts at

    [internal function]: Jeremeamia\SuperClosure\SerializableClosure::{closure}(Object(Illuminate\Queue\Jobs\BeanstalkdJob))
#2 /home/forge/api.hello.me/vendor/jeremeamia/SuperClosure/src/Jeremeamia/SuperClosure/SerializableClosure.php(64): ReflectionFunction->invokeArgs(Array)

and finished a few lines later at

#15 /home/forge/api.hello.me/vendor/symfony/console/Symfony/Component/Console/Application.php(124): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
    #16 /home/forge/api.hello.me/artisan(59): Symfony\Component\Console\Application->run()
    #17 {main} [] []

Any idea on how I could understand / find out what is happening? The queue is not even failing all the time...

ps: full stack trace:

#0 /home/forge/api.hello.me/vendor/jeremeamia/SuperClosure/src/Jeremeamia/SuperClosure/SerializableClosure.php(99) : eval()'d code(6): Illuminate\Exception\Handler->handleError(8, 'Trying to get p...', '/home/forge/api...', 6, Array)
#1 [internal function]: Jeremeamia\SuperClosure\SerializableClosure::{closure}(Object(Illuminate\Queue\Jobs\BeanstalkdJob))
#2 /home/forge/api.hello.me/vendor/jeremeamia/SuperClosure/src/Jeremeamia/SuperClosure/SerializableClosure.php(64): ReflectionFunction->invokeArgs(Array)
#3 /home/forge/api.hello.me/vendor/laravel/framework/src/Illuminate/Queue/IlluminateQueueClosure.php(36): Jeremeamia\SuperClosure\SerializableClosure->__invoke(Object(Illuminate\Queue\Jobs\BeanstalkdJob))
#4 /home/forge/api.hello.me/vendor/laravel/framework/src/Illuminate/Queue/Jobs/Job.php(96): IlluminateQueueClosure->fire(Object(Illuminate\Queue\Jobs\BeanstalkdJob), Array)
#5 /home/forge/api.hello.me/vendor/laravel/framework/src/Illuminate/Queue/Jobs/BeanstalkdJob.php(50): Illuminate\Queue\Jobs\Job->resolveAndFire(Array)
#6 /home/forge/api.hello.me/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(205): Illuminate\Queue\Jobs\BeanstalkdJob->fire()
#7 /home/forge/api.hello.me/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(157): Illuminate\Queue\Worker->process('beanstalkd', Object(Illuminate\Queue\Jobs\BeanstalkdJob), '3', '0')
#8 /home/forge/api.hello.me/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(105): Illuminate\Queue\Worker->pop('beanstalkd', 'default', '0', '10', '3')
#9 /home/forge/api.hello.me/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(67): Illuminate\Queue\Console\WorkCommand->runWorker('beanstalkd', 'default', '0', '128', false)
#10 /home/forge/api.hello.me/vendor/laravel/framework/src/Illuminate/Console/Command.php(112): Illuminate\Queue\Console\WorkCommand->fire()
#11 /home/forge/api.hello.me/vendor/symfony/console/Symfony/Component/Console/Command/Command.php(253): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#12 /home/forge/api.hello.me/vendor/laravel/framework/src/Illuminate/Console/Command.php(100): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#13 /home/forge/api.hello.me/vendor/symfony/console/Symfony/Component/Console/Application.php(889): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#14 /home/forge/api.hello.me/vendor/symfony/console/Symfony/Component/Console/Application.php(193): Symfony\Component\Console\Application->doRunCommand(Object(Illuminate\Queue\Console\WorkCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#15 /home/forge/api.hello.me/vendor/symfony/console/Symfony/Component/Console/Application.php(124): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#16 /home/forge/api.hello.me/artisan(59): Symfony\Component\Console\Application->run()
#17 {main} [] []
1
The stacktrace and error log don't seem to be very helpfull in this case. Could you perhaps post the code being pushed onto the queue?Bogdan
by looking at the failed job, you can see the class/function that is being called. print out logs, and find where it crashes... you can repush jobs from the failed queue so you should be able to catch these jobs and reproduce themNiRR
We need to see what you are pushing.Ravan Scafi
Hey @Ravan, NiRR & Bogdan thank you for getting back! Sorry couldn't reply earlier. So even if I repush it in the queue I have no clue which job is being fired (which controller is it going through etc) the app is in production. Any idea how I could find that out?commandantp

1 Answers

0
votes

The way Laravel queues work is to serialize all the data you provide as the payload, and it sticks that in your database. When you process the queue, it will magically unserialize all this data so that you have basically the same object in memory as you did when you popped it into the queue. The problem comes in when you change the class definition of a serialized object, or your object does not quite serialize correct (which seems to be the case here)...

I would suggest that you try not serializing anonymous functions, because Laravel uses SuperClosure to do this, and it's pretty hacky.

[internal function]: Jeremeamia\SuperClosure\SerializableClosure::{closure}(Object(Illuminate\Queue\Jobs\BeanstalkdJob))

Try pushing simpler objects into your Beanstalk queue (i.e. don't send objects to the queue) and you won't have this issue.