ID: 45590 Updated by: [EMAIL PROTECTED] Reported By: alan dot blotz at students dot uni-mainz dot de -Status: Open +Status: Bogus Bug Type: MySQL related Operating System: Debian Lenny PHP Version: 5.2.6 New Comment:
Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php You must not use the same connection from different processes. The protocol only allows a single query per time so the queries from the different childs end up in a queue and the answers are read by the process which randomly expects some results at the correct time. Previous Comments: ------------------------------------------------------------------------ [2008-07-22 14:48:59] alan dot blotz at students dot uni-mainz dot de Description: ------------ Already a long time ago the bug http://bugs.php.net/bug.php?id=38228 was active, but I experienced some problems with the pcntl_fork() function today. I already fixed the problem with multiple children connecting to the MySQL server by using mysql_connect(..., true) or mysql_pconnect() (the latter I'm using right now). My problem is, that with any of these methods I'm partly getting wrong results to queries (see code). This really NOT happening always, just sometimes when you don't expect it. I can't post the original code due to copyrights, but the example below should give you an idea of what is happening. I'm working with multiple children in my application (executed as CLI), at least five at a time. Is it perhaps a memory problem of PHP and / or MySQL? Alan Reproduce code: --------------- // Queries for five children for ($i = 0; $i < 5; $i++) { // If I am the child if (!pcntl_fork()) { switch ($i) { case 0: $sql = 'SELECT a, b FROM t'; break; case 1: $sql = 'SELECT c FROM s'; break; case 2: $sql = 'SELECT x FROM s'; break; case 3: $sql = 'SELECT a, b, d FROM t'; break; case 4: $sql = 'SELECT d FROM t'; break; } $result = mysql_query($sql); // Get the result from DB with mysql_fetch_array() for example } } Expected result: ---------------- Result of columns a and b from table t in first child Result of column c from table s in second child Result of column x from table s in third child Result of columns a, b and d from table t in fourth child Result of column d from table t in fifth child Actual result: -------------- For example (some worst case): Nothing in first child Result of column x from table s in second child Result of column c from table s in third child Result of columns a and b from table t in fourth child Result of column d from table t in fifth child ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=45590&edit=1
