1

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:

<?php
namespace Craft;

class JobHandler
{
    public function perform ()
    {
        $criteria          = craft()->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?

5
  • 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
    Commented Nov 10, 2016 at 23:37
  • Yep, all verified. jmp.sh/E3RAbKc Commented Nov 11, 2016 at 8:33
  • Forgot to mention that I tried to look at the MySQL logs, but didn't see any related errors. Any debugging ideas? Commented Nov 11, 2016 at 10:35
  • Did you solve this problem? If yes, how?
    – Jeet Kumar
    Commented Apr 25, 2017 at 15:55
  • @JeetKumar Nope. I gave up. Going to revisit it for Craft 3. Commented Apr 25, 2017 at 16:17

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.