elcuy
3 years ago
580
3
Laravel

MySQL has gone away

Posted 3 years ago by elcuy

Hello everyone, I'm having troubles with the artisan queue:work command on Laravel 5.3. Throws this error on a loop:

[2016-10-26 16:23:10] local.ERROR: ErrorException: PDO::beginTransaction(): MySQL server has gone away in /home/vagrant/EasyFlow2/vendor/laravel/framework/src/Illuminate/Database/Connection.php:601
Stack trace:
#0 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(2, 'PDO::beginTrans...', '/home/vagrant/E...', 601, Array)
#1 /home/vagrant/EasyFlow2/vendor/laravel/framework/src/Illuminate/Database/Connection.php(601): PDO->beginTransaction()
#2 /home/vagrant/EasyFlow2/vendor/laravel/framework/src/Illuminate/Queue/DatabaseQueue.php(175): Illuminate\Database\Connection->beginTransaction()
#3 /home/vagrant/EasyFlow2/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(183): Illuminate\Queue\DatabaseQueue->pop('default')
#4 /home/vagrant/EasyFlow2/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(153): Illuminate\Queue\Worker->getNextJob(Object(Illuminate\Queue\DatabaseQueue), 'default')
#5 /home/vagrant/EasyFlow2/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(111): Illuminate\Queue\Worker->runNextJob('database', 'default', Object(Illuminate\Queue\WorkerOptions))
#6 /home/vagrant/EasyFlow2/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(74): Illuminate\Queue\Worker->runNextJobForDaemon('database', 'default', Object(Illuminate\Queue\WorkerOptions))
#7 /home/vagrant/EasyFlow2/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(97): Illuminate\Queue\Worker->daemon('database', 'default', Object(Illuminate\Queue\WorkerOptions))
#8 /home/vagrant/EasyFlow2/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(78): Illuminate\Queue\Console\WorkCommand->runWorker('database', 'default')
#9 [internal function]: Illuminate\Queue\Console\WorkCommand->fire()
#10 /home/vagrant/EasyFlow2/vendor/laravel/framework/src/Illuminate/Container/Container.php(507): call_user_func_array(Array, Array)
#11 /home/vagrant/EasyFlow2/vendor/laravel/framework/src/Illuminate/Console/Command.php(169): Illuminate\Container\Container->call(Array)
#12 /home/vagrant/EasyFlow2/vendor/symfony/console/Command/Command.php(256): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#13 /home/vagrant/EasyFlow2/vendor/laravel/framework/src/Illuminate/Console/Command.php(155): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#14 /home/vagrant/EasyFlow2/vendor/symfony/console/Application.php(818): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#15 /home/vagrant/EasyFlow2/vendor/symfony/console/Application.php(186): Symfony\Component\Console\Application->doRunCommand(Object(Illuminate\Queue\Console\WorkCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#16 /home/vagrant/EasyFlow2/vendor/symfony/console/Application.php(117): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#17 /home/vagrant/EasyFlow2/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(111): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#18 /home/vagrant/EasyFlow2/artisan(35): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#19 {main}  
[2016-10-26 16:23:13] local.ERROR: ErrorException: Error while sending QUERY packet. PID=27835 in /home/vagrant/EasyFlow2/vendor/laravel/framework/src/Illuminate/Database/Connection.php:601
Stack trace:
#0 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(2, 'Error while sen...', '/home/vagrant/E...', 601, Array)
#1 /home/vagrant/EasyFlow2/vendor/laravel/framework/src/Illuminate/Database/Connection.php(601): PDO->beginTransaction()
#2 /home/vagrant/EasyFlow2/vendor/laravel/framework/src/Illuminate/Queue/DatabaseQueue.php(175): Illuminate\Database\Connection->beginTransaction()
#3 /home/vagrant/EasyFlow2/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(183): Illuminate\Queue\DatabaseQueue->pop('default')
#4 /home/vagrant/EasyFlow2/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(153): Illuminate\Queue\Worker->getNextJob(Object(Illuminate\Queue\DatabaseQueue), 'default')
#5 /home/vagrant/EasyFlow2/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(111): Illuminate\Queue\Worker->runNextJob('database', 'default', Object(Illuminate\Queue\WorkerOptions))
#6 /home/vagrant/EasyFlow2/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(74): Illuminate\Queue\Worker->runNextJobForDaemon('database', 'default', Object(Illuminate\Queue\WorkerOptions))
#7 /home/vagrant/EasyFlow2/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(97): Illuminate\Queue\Worker->daemon('database', 'default', Object(Illuminate\Queue\WorkerOptions))
#8 /home/vagrant/EasyFlow2/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(78): Illuminate\Queue\Console\WorkCommand->runWorker('database', 'default')
#9 [internal function]: Illuminate\Queue\Console\WorkCommand->fire()
#10 /home/vagrant/EasyFlow2/vendor/laravel/framework/src/Illuminate/Container/Container.php(507): call_user_func_array(Array, Array)
#11 /home/vagrant/EasyFlow2/vendor/laravel/framework/src/Illuminate/Console/Command.php(169): Illuminate\Container\Container->call(Array)
#12 /home/vagrant/EasyFlow2/vendor/symfony/console/Command/Command.php(256): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#13 /home/vagrant/EasyFlow2/vendor/laravel/framework/src/Illuminate/Console/Command.php(155): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#14 /home/vagrant/EasyFlow2/vendor/symfony/console/Application.php(818): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#15 /home/vagrant/EasyFlow2/vendor/symfony/console/Application.php(186): Symfony\Component\Console\Application->doRunCommand(Object(Illuminate\Queue\Console\WorkCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#16 /home/vagrant/EasyFlow2/vendor/symfony/console/Application.php(117): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#17 /home/vagrant/EasyFlow2/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(111): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#18 /home/vagrant/EasyFlow2/artisan(35): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#19 {main}  

I read that this is caused by MySQL's configuration, but my system variables are as follows:

wait_timeout = 28800
max_allowed_packet = 104857600    // Which is about 100M

If I execute the command with the --once flag it doesn't cause any problems, but without the flag it processes the first element on the queue and then stops, producing those errors in the log. What am I doing wrong?

Please sign in or create an account to participate in this conversation.