yiigearman

PHP GearmanClient::doBackground just hangs


Mehod doBackground of GearmanClient and its descendants such as doLowBackground and doHighBackground sometimes hang. I cannot figure out why.

php 5.4

Gearman server version 1.1.18

Gearman php lib version 1.1.2

At some point of time user clicks the button, and tasks (more than 700) go to the gearman. DoBackground freezes randomly, it can hang after 20 task put into gearman, or can hang after 200-300, maybe 500 tasks.

I don't see errors in gearman/php logs nor see in direct link (when I directly start debugging)

When I try to debug, I just minimize tasks count to 50, and issue request directly from browser. If everything goes well, browser's circle (loading action) dissapears, and I see my var_dumps. But if at some task doBackground didnt return control, browser request goes to infinite loop, waiting server response

My code is simple. I collect data, put into array, and one by one send to queue

for($i = 0; $i < count($itemsToProcess); $i++) {var_dump($i);
    $method = array_shift($itemsToProcess[$i]['methodsAfter']);
    Yii::app()->gearman->client()->doBackground($method, json_encode($itemsToProcess[$i]));
}

As additional information, I have another server with

php 7.1

installed,

server version is 1.1.12

, and

libgearman for php was auto installed with yum

. There seems to be same problem, but!!! it appears very very rarely.

Of course it's crucial and very critical problem, if you issue A count and B count goes into queue.

P.S: The reason of different enviroments is that we cannot still migrate to php7. Php5.4 is prod and php7 is dev


Solution

  • It's not gearmand, nor php extension problem

    https://github.com/gearman/gearmand/issues/241