Gearman出现分割错误的工人

问题描述 投票:0回答:1

运行我的工作者时出现错误:

Segmentation fault (core dumped)

尝试通过命令行为Gearman Client运行worker时出现分段错误。

此消息工作者在获得一些正确的响应后得到。

我的工作人员代码:

<?php
require __DIR__ . '/vendor/autoload.php';

use ClickHouseDB\Client;
use ClickHouseDB\Quote\FormatLine;

$config = [
    'host' => '',
    'port' => 0,
    'username' => '',
    'password' => ''
];
$db = new Client($config);
$db->database('mydb');  

$worker= new GearmanWorker();
$worker->addServer('127.0.0.1', '4730');
$worker->addFunction("send_to_clickhouse", "processing", $db);


while (1)
{
  $worker->work();
  if ($worker->returnCode() != GEARMAN_SUCCESS){
      echo "return_code: " . $gmworker->returnCode() . "\n";
      break;
  }
}

function processing($job, $db)
{
    $message =  $job->workload();
    $data = json_decode($message, true);
    $statement = $db->insert($data['table_name'], [array_values($data['columns'])], array_keys($data['columns']));
    $statement->error();
    echo $data['table_name']."\n";
}
?>

运行工人:

php worker.php

工作者输出:

table1
table2
Segmentation fault (core dumped)

我正在使用smi2/phpclickhouse扩展名将数据发送到数据库

PHP版本:

PHP 7.2.15-0ubuntu0.18.04.2 (cli) (built: Mar 22 2019 17:05:14) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.2.15-0ubuntu0.18.04.2, Copyright (c) 1999-2018, by Zend Technologies

命令dmesg返回:

...
[168928.288846] traps: php[29065] general protection ip:5558a2d01be0 sp:7ffc92fc4cf0 error:0 in php7.2[5558a2a87000+419000]
[168963.415479] traps: php[29071] general protection ip:55d203497ad4 sp:7ffeb5813e20 error:0 in php7.2[55d203156000+419000]
[169089.059688] traps: php[29152] general protection ip:55595db0a293 sp:7fff98ce30a0 error:0 in php7.2[55595d853000+419000]
[169280.116888] traps: php[29159] general protection ip:556772007ad4 sp:7ffc1c89b1d0 error:0 in php7.2[556771cc6000+419000]
[169282.114056] traps: php[29161] general protection ip:55ed3ab32be0 sp:7ffca8c53820 error:0 in php7.2[55ed3a8b8000+419000]
[169283.565760] traps: php[29163] general protection ip:55edd7b73ad4 sp:7ffd23dc6a10 error:0 in php7.2[55edd7832000+419000]
[169288.703892] traps: php[29165] general protection ip:558527bc5ad4 sp:7fff41e888a0 error:0 in php7.2[558527884000+419000]
[169331.512869] traps: php[29170] general protection ip:563e00ddfad4 sp:7ffd503eada0 error:0 in php7.2[563e00a9e000+419000]
[169408.724444] traps: php[29187] general protection ip:561e2ed6cbe0 sp:7ffeab26dd00 error:0 in php7.2[561e2eaf2000+419000]
[169462.063710] traps: php[29200] general protection ip:561682a69ad4 sp:7ffe4634d730 error:0 in php7.2[561682728000+419000]

如果我删除代码statement = $db->insert(...,似乎一切正常。

任何想法需要解决的问题吗?

更新:

gdb返回此信息:

(gdb) bt
#0  0x00005555557cebe0 in _emalloc ()
#1  0x00005555557f9d52 in add_assoc_string_ex ()
#2  0x00007ffff254be55 in ?? () from /usr/lib/php/20170718/curl.so
#3  0x00005555558a6a6b in execute_ex ()
#4  0x00005555557e67de in zend_call_function ()
#5  0x00005555557e6c95 in _call_user_function_ex ()
#6  0x00007fffec8aa407 in ?? () from /usr/lib/php/20170718/gearman.so
#7  0x00007fffec680a87 in ?? () from /usr/lib/x86_64-linux-gnu/libgearman.so.8
#8  0x00007fffec689851 in gearman_worker_work () from /usr/lib/x86_64-linux-gnu/libgearman.so.8
#9  0x00007fffec8ab8cd in zif_gearman_worker_work () from /usr/lib/php/20170718/gearman.so
#10 0x00005555558a7298 in execute_ex ()
#11 0x00005555558a83a7 in zend_execute ()
#12 0x00005555557f6d92 in zend_execute_scripts ()
#13 0x00005555557921f0 in php_execute_script ()
#14 0x00005555558aa7bc in ?? ()
#15 0x00005555556405bb in ?? ()
#16 0x00007ffff5ebcb97 in __libc_start_main (main=0x5555556401a0, argc=2, argv=0x7fffffffe588, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, 
    stack_end=0x7fffffffe578) at ../csu/libc-start.c:310
#17 0x000055555564075a in _start ()
php ubuntu gearman
1个回答
0
投票

我在运行PHP 7.2.24的Ubuntu 18.04 LTS中也遇到了这个问题。我发现这是gearman-php扩展中的错误(已为fixed)。

要解决这个问题,您需要下载,编译和安装gearman pecl模块

cd /tmp/
sudo wget https://github.com/wcgallego/pecl-gearman/archive/gearman-2.0.6.zip
unzip gearman-2.0.6.zip
cd pecl-gearman-gearman-2.0.6
sudo phpize
./configure
sudo make
sudo make install

要在Ubuntu上完整安装Gearman for PHP7,请参考此guide

© www.soinside.com 2019 - 2024. All rights reserved.