<p>I'm using php-resque + Redis to get queues/workers into Craft, and so far I've managed to get it all running.</p>

<p>My test worker looks something like this:</p>

<pre><code>&lt;?php
namespace Craft;

class JobHandler
{
    public function perform ()
    {
        $criteria          = craft()-&gt;elements-&gt;getCriteria(ElementType::Entry);
        $criteria-&gt;section = 'products';
        $criteria-&gt;limit   = 20;
        $entries           = $criteria-&gt;count();

        if ( $entries ) {
            ElasticSearchPlugin::log("Found! $entries entries", LogLevel::Info, $force = true);
        }
    }
}
</code></pre>

<p>When I add a job to the queue, the worker successfully runs the perform() method, and it shows up in the console and log.</p>

<p>However, all jobs after the first fails consistently, with the following stacktrace:</p>

<pre><code>2016/11/10 10:49:25 [error] [php] Error while sending QUERY packet. PID=80844 (/src/craft/app/framework/db/CDbCommand.php:508)
Stack trace:
#0 /src/craft/app/framework/db/CDbCommand.php(396): Craft\DbCommand-&gt;queryInternal()
#1 /src/craft/app/services/FieldsService.php(251): Craft\DbCommand-&gt;queryAll()
#2 /src/craft/app/elementtypes/BaseElementType.php(445): Craft\FieldsService-&gt;getAllFields()
#3 /src/craft/app/elementtypes/BaseElementType.php(463): Craft\EntryElementType-&gt;getFieldsForElementsQuery()
#4 /src/craft/app/services/ElementsService.php(665): Craft\EntryElementType-&gt;getContentFieldColumnsForElementsQuery()
#5 /src/craft/app/services/ElementsService.php(528): Craft\ElementsService-&gt;buildElementsQuery()
#6 /src/craft/app/models/ElementCriteriaModel.php(385): Craft\ElementsService-&gt;getTotalElements()
#7 /src/craft/app/models/ElementCriteriaModel.php(174): Craft\ElementCriteriaModel-&gt;total()
#8 /src/craft/plugins/queue/handlers/JobHandler.php(23): Craft\ElementCriteriaModel-&gt;count()
#9 /src/craft/plugins/queue/vendor/chrisboulton/php-resque/lib/Resque/Job.php(182): Craft\JobHandler-&gt;perform()
#10 /src/craft/plugins/queue/vendor/chrisboulton/php-resque/lib/Resque/Worker.php(241): Resque_Job-&gt;perform()
#11 /src/craft/plugins/queue/vendor/chrisboulton/php-resque/lib/Resque/Worker.php(203): Resque_Worker-&gt;perform()
#12 /src/craft/plugins/queue/consolecommands/JobCommand.php(85): Resque_Worker-&gt;work()
#13 unknown(0): Craft\JobCommand-&gt;actionWork2()
#14 /src/craft/app/framework/console/CConsoleCommand.php(172): ReflectionMethod-&gt;invokeArgs()
#15 /src/craft/app/framework/console/CConsoleCommandRunner.php(71): Craft\JobCommand-&gt;run()
#16 /src/craft/app/framework/console/CConsoleApplication.php(92): Craft\ConsoleCommandRunner-&gt;run()
#17 /src/craft/app/framework/base/CApplication.php(185): Craft\ConsoleApp-&gt;processRequest()
#18 /src/craft/app/etc/console/yiic.php(81): Craft\ConsoleApp-&gt;run()
#19 /src/craft/app/etc/console/yiic(4): require_once()

in /src/craft/app/etc/console/ConsoleApp.php (265)
in /src/craft/app/services/FieldsService.php (251)
in /src/craft/app/elementtypes/BaseElementType.php (445)
</code></pre>

<p>After googling, most suggestions hover around adjusting max_allowed_packet and/or wait_timeout. This doesn't make sense to me. I've set max_allowed_packet to 512M, and wait_timeout defaults to 8 hours.</p>

<p>Any ideas?</p>

<p>Is CDbCommand not cleaning up after it self because the process runs forever?</p>

CC BY-SA 3.0
2016-11-10T23:37:16.877Z
Have you verified that the values you changed actually have stuck at runtime? My understanding is that those are two common settings that cause the error, but there's plenty of others.  It's just MySQL's way of saying "something is wrong, I give up".
Brad Bell
CC BY-SA 3.0
2016-11-11T08:33:23.100Z
Yep, all verified. http://jmp.sh/E3RAbKc
Fred Carlsen
CC BY-SA 3.0
2016-11-11T10:35:27.553Z
Forgot to mention that I tried to look at the MySQL logs, but didn't see any related errors. Any debugging ideas?
Fred Carlsen
CC BY-SA 3.0
2017-04-25T15:55:06.850Z
Did you solve this problem? If yes, how?
Jeet Kumar
CC BY-SA 3.0
2017-04-25T16:17:01.433Z
@JeetKumar Nope. I gave up. Going to revisit it for Craft 3.
Fred Carlsen
<plugin-development><php><mysql>
Error while sending QUERY packet in continuously running process
# Error while sending QUERY packet in continuously running process

(Asked by: username_0 on 2016-11-10)

I'm using php-resque + Redis to get queues/workers into Craft, and so far I've managed to get it all running.
My test worker looks something like this:
elements->getCriteria(ElementType::Entry);
        $criteria->section = 'products';
        $criteria->limit   = 20;
        $entries           = $criteria->count();

        if ( $entries ) {
            ElasticSearchPlugin::log("Found! $entries entries", LogLevel::Info, $force = true);
        }
    }
}

When I add a job to the queue, the worker successfully runs the perform() method, and it shows up in the console and log.
However, all jobs after the first fails consistently, with the following stacktrace:
2016/11/10 10:49:25 [error] [php] Error while sending QUERY packet. PID=80844 (/src/craft/app/framework/db/CDbCommand.php:508)
Stack trace:
#0 /src/craft/app/framework/db/CDbCommand.php(396): Craft\DbCommand->queryInternal()
#1 /src/craft/app/services/FieldsService.php(251): Craft\DbCommand->queryAll()
#2 /src/craft/app/elementtypes/BaseElementType.php(445): Craft\FieldsService->getAllFields()
#3 /src/craft/app/elementtypes/BaseElementType.php(463): Craft\EntryElementType->getFieldsForElementsQuery()
#4 /src/craft/app/services/ElementsService.php(665): Craft\EntryElementType->getContentFieldColumnsForElementsQuery()
#5 /src/craft/app/services/ElementsService.php(528): Craft\ElementsService->buildElementsQuery()
#6 /src/craft/app/models/ElementCriteriaModel.php(385): Craft\ElementsService->getTotalElements()
#7 /src/craft/app/models/ElementCriteriaModel.php(174): Craft\ElementCriteriaModel->total()
#8 /src/craft/plugins/queue/handlers/JobHandler.php(23): Craft\ElementCriteriaModel->count()
#9 /src/craft/plugins/queue/vendor/chrisboulton/php-resque/lib/Resque/Job.php(182): Craft\JobHandler->perform()
#10 /src/craft/plugins/queue/vendor/chrisboulton/php-resque/lib/Resque/Worker.php(241): Resque_Job->perform()
#11 /src/craft/plugins/queue/vendor/chrisboulton/php-resque/lib/Resque/Worker.php(203): Resque_Worker->perform()
#12 /src/craft/plugins/queue/consolecommands/JobCommand.php(85): Resque_Worker->work()
#13 unknown(0): Craft\JobCommand->actionWork2()
#14 /src/craft/app/framework/console/CConsoleCommand.php(172): ReflectionMethod->invokeArgs()
#15 /src/craft/app/framework/console/CConsoleCommandRunner.php(71): Craft\JobCommand->run()
#16 /src/craft/app/framework/console/CConsoleApplication.php(92): Craft\ConsoleCommandRunner->run()
#17 /src/craft/app/framework/base/CApplication.php(185): Craft\ConsoleApp->processRequest()
#18 /src/craft/app/etc/console/yiic.php(81): Craft\ConsoleApp->run()
#19 /src/craft/app/etc/console/yiic(4): require_once()

in /src/craft/app/etc/console/ConsoleApp.php (265)
in /src/craft/app/services/FieldsService.php (251)
in /src/craft/app/elementtypes/BaseElementType.php (445)

After googling, most suggestions hover around adjusting max_allowed_packet and/or wait_timeout. This doesn't make sense to me. I've set max_allowed_packet to 512M, and wait_timeout defaults to 8 hours.
Any ideas?
Is CDbCommand not cleaning up after it self because the process runs forever?

**Tags:** plugin-development, php, mysql
> **Comments:**
> **username_1**: Have you verified that the values you changed actually have stuck at runtime? My understanding is that those are two common settings that cause the error, but there's plenty of others.  It's just MySQL's way of saying "something is wrong, I give up".  
> **username_0**: Yep, all verified. http://jmp.sh/E3RAbKc  
> **username_0**: Forgot to mention that I tried to look at the MySQL logs, but didn't see any related errors. Any debugging ideas?  
> **username_2**: Did you solve this problem? If yes, how?  
> **username_0**: @JeetKumar Nope. I gave up. Going to revisit it for Craft 3.  

---

## 0 answers

