Bug #62571 [Com]: Postgres PDO connections fail after SIGCHLD called

From: Date: Sat, 10 Dec 2016 04:24:55 +0000
Subject: Bug #62571 [Com]: Postgres PDO connections fail after SIGCHLD called
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-205888@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=62571&edit=1 ID: 62571 Comment by: bartek at bugpoint dot pl Reported by: spiros_ioannou at yahoo dot gr Summary: Postgres PDO connections fail after SIGCHLD called Status: Closed Type: Bug Package: PDO related Operating System: Linux PHP Version: 5.3.14 Assigned To: willfitch Block user comment: N Private report: N New Comment: I confirm the existence of this error in php 7. Here is example code: test1.php: <?php defined('APPLICATION_PATH') || define('APPLICATION_PATH', realpath(__DIR__ . '/application')); defined('APPLICATION_ENV') || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'development')); require_once 'Zend/Application.php'; $application = new Zend_Application( APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini' ); $db = new Zend_Db_Adapter_Pdo_Pgsql(array( 'host' => 'localhost', 'username' => 'test', 'password' => 'hasłodlatest', 'dbname' => 'test' )); echo 'start' . "\n"; $select = $db->select()->from('aaa', '*'); print_r($db->fetchOne($select)); echo "\n"; $pid = pcntl_fork(); if ($pid == -1) { // pcntl_fork() failed echo('could not fork'); } elseif ($pid) { } elseif ($pid == 0) { // you're in the new (child) process exec('/usr/bin/php /home/idea/CLI/test2.php &>/home/idea/CLI/test.log &'); exit; } echo 'After fork' . "\n"; while (true) { sleep(5); $select = $db->select()->from('aaa', '*'); print_r($db->fetchOne($select)); } test2.php: <?php echo 'Forked' . "\n"; Previous Comments: ------------------------------------------------------------------------ [2013-10-30 23:25:49] willfitch@php.net Closing as no feedback has been provided since I asked for it in 2012. ------------------------------------------------------------------------ [2012-12-18 21:23:52] willfitch@php.net Can you provide a test script for your issue? ------------------------------------------------------------------------ [2012-07-21 11:46:39] spiros_ioannou at yahoo dot gr When using persistent connections, even if reopening a new connection *after* forking, the connection fails. The only way to have DB connections is to reopen them after forking, with PDO::ATTR_PERSISTENT => false ------------------------------------------------------------------------ [2012-07-16 00:12:14] spiros_ioannou at yahoo dot gr I revoke the statement of SIGCHLD, it happens even without the handler in some situations, the behaviour seems erratic. Perhaps the database connection is shared with the children, and when the child dies the db variable the connection is closed. I tried closing the DB connection first thing on the child but with no results, the error still appears when the child dies. ------------------------------------------------------------------------ [2012-07-15 23:27:50] spiros_ioannou at yahoo dot gr Description: ------------ When using pcntl_fork to fork children, and *only* the parent uses the Postgres PDO database connection, the connection becomes unusable after the first child exits and the signal handler is called. If SIGCHLD signal handler is omitted PDO works normally for parent. Tested with and without persistent connections. Possible relevant bugs: 48447, 45797 Actual result: -------------- PHP Warning: PDOStatement::execute(): SQLSTATE[HY000]: General error: 7 server closed the connection unexpectedly This probably means the server terminated abnormally ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=62571&edit=1

« previous php.bugs (#205888) next »