gpt4 book ai didi

php - 无法解释的 Gearman 超时之谜

转载 作者:搜寻专家 更新时间:2023-10-31 22:01:32 24 4
gpt4 key购买 nike

Gearman 客户端在添加作业时随机超时。我无法重新创造导致失败的条件。 Gearman 守护进程正在运行!

条件:上传一批文件排队等待Gearman调整大小。我可以毫无错误地上传数百个。但是,偶尔会有一个作业提交失败并出现以下错误:

 gearman_wait(GEARMAN_TIMEOUT) timeout reached,
1 servers were poll(), no servers were available, pipe:false ->
libgearman/universal.cc:328

但是,在失败的作业之前和之后立即提交的作业会通过!我什至可以重新上传相同的图片,并且它会在第二次尝试时通过。 gearman 服务器在那里...这是 gearmand 或 php-pecl-gearman 扩展的某种故障吗??

齿轮配置:

OPTIONS="
--port=4730 \
--verbose=NOTICE \
--log-file=/var/log/gearman/gearmand.log \
--keepalive \
--threads=4 \
--queue-type=MySQL \
--mysql-host=localhost \
--mysql-port=xxx \
--mysql-user=xx \
--mysql-password=xx \
--mysql-db=xxxD \
--mysql-table=gearman_queue \
--job-retries=5"

PHP Gearman 扩展 (PECL)

gearman support => enabled
extension version => 1.1.2
libgearman version => 1.1.8
Default TCP Host => localhost
Default TCP Port => 4730

日志显示所有接受的作业,没有记录失败的作业

NOTICE 2015-02-02 16:25:54.000000 [  proc ] accepted,worker_name,jobidprefix65468823354cfa51234fa09.3540767125336,0 -> libgearman-server/server.cc:314
NOTICE 2015-02-02 16:25:56.000000 [ proc ] accepted,worker_name,jobidprefix40605707054cfa51438b0d0.383048589216,0 -> libgearman-server/server.cc:314
NOTICE 2015-02-02 16:25:56.000000 [ proc ] accepted,worker_name,jobidprefix197198183754cfa51447dac9.5387112932157,0 -> libgearman-server/server.cc:314

在提交作业之前,我什至 ping 了该死的 gearman 服务器以确保它在那里! Ping 结果是真的!!

$gmclient= new GearmanClient();
$gmclient->addServer("127.0.0.1", ((int)$gearmanPort)); # Add default server (localhost).
$gmclient->setTimeout(300);//set timeout to send gearman errors

//assign a unique id for the job (limit the length to prevent db errors)
$uniqueid = substr('jobPrefix'.uniqid (rand (),true).rand(0, 32767), 0, 63);

//add the job to the background
$job_handle = $gmclient->addTaskBackground("worker_name", $jobdata, null, $uniqueid);

//ping gearman to make sure it is working before sending job
//keep trying for 2 seconds (4 times per second) until success or failure
$pingCount = 1;
while (@$gmclient->ping(serialize("Ping Test")) === FALSE && $pingCount <= 8) {
$this->log('Couldnt ping gearman server on pingCount='.$pingCount.'/8');
usleep(250000); //sleep for 0.25 seconds before trying again
$pingCount++;
}

//queue the job
if (@!$gmclient->runTasks()) //supress gearman fatal errors so we can catch them
{
throw new CHttpException(500,"ERROR " . $gmclient->error());
}

if (@$gmclient->returnCode() != GEARMAN_SUCCESS) //supress gearman fatal errors so we can catch them
{
throw new CHttpException(500,'ERROR: Bad return code for brokenlinkcheck '.$gmclient->returnCode());
}

最佳答案


$gmclient->setTimeout(300);

在为 gearman 作业服务器中的工作人员设置超时时,存在一个令人讨厌的错误。您是否也在工作脚本中设置了超时?尝试删除它。

关于php - 无法解释的 Gearman 超时之谜,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28282823/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com