redis - After php upgrade pcntl_fork causing "errno=32 Broken pipe" -
i upgraded php 5.4.26 5.4.28 after upgrade getting error
notice: unknown: send of 6 bytes failed errno=32 broken pipe in unknown on line 0
when ever run following code:
<?php $tasks = array( '1' => array(), '2' => array(), ); ini_set('display_errors', true); class redisclass { private $redis; public function __construct() { $this->redis = new redis(); $this->redis->connect('localhost', 6379); } } $redis = new redisclass(); foreach ($tasks $index => $task) { $pid = pcntl_fork(); // child if($pid == 0) { echo "running ".$index." child in ". getmypid() ."\n"; break; } } switch($pid) { case -1 : die('could not fork'); break; case 0: // child code break; default: while (pcntl_waitpid(0, $status) != -1) { $status = pcntl_wexitstatus($status); echo "child completed status $status\n"; } echo "child done (says: ". getmypid() .")"; exit; }
if fork 1 child not php notice. if run more 1 child php notice every child except first child.
does have clues going on here?
i assuming trying close redis connection multiple times code have been running @ least 4 months out issues.
it starting displaying these notices after upgrade 5.4.28.
i have looked @ php change logs cannot see think may explain issue.
should report php bug?
update:
looks "may" redis issue, using phpredis tested same code mysql connection instead of loading redis , not error.
class mysqlclass { private $mysqli; public function __construct() { $this->mysqli = mysqli_init(); //this not droid looking $this->mysqli->real_connect('ip_address', 'user_name', 'password'); } } $mysql = new mysqlclass();
the problem here not reconnect redis in child process. michael had said, not have active connection second child onwards. mysql example should not work if make queries.
i have had exact problematic behaviour "mysql server has gone away" error , redis.
the solution create new connection mysql , redis in child. make sure if have singletone handles mysql/redis connection reset instances ( problem me ).
Comments
Post a Comment