Bug #79661 [NEW]: 2 Connections with different buffer stats cant run

From: Date: Mon, 01 Jun 2020 15:13:07 +0000
Subject: Bug #79661 [NEW]: 2 Connections with different buffer stats cant run
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-227262@lists.php.net to get a copy of this message
From: thebluewalrus at gmail dot com Operating system: Amazon Linux release 2 (Karoo) PHP version: 7.3.18 Package: PDO MySQL Bug Type: Bug Bug description:2 Connections with different buffer stats cant run Description: ------------ If 2 PDO connections are opened they seem to be merged. If the first is using unbuffered and second using buffered the first results in a buffered return. If both connections are using unbuffered and the first connection is running the second connection returns: Cannot execute queries while other unbuffered queries are active. Consider using PDOStatement::fetchAll(). Alternatively, if your code is only ever going to run against mysql, you may enable query buffering by setting the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute. on the first call. Issue produces on machines running 7.3.17 (OS Amazon Linux release 2 (Karoo)) and 7.1.33 (OS Red Hat Enterprise Linux Server release 7.3 (Maipo)). Test script: --------------- Case 1: $db = new PDO("mysql:host=".$dbhost.";dbname=".$dbname, $dbuser, $dbpass, array(PDO::ATTR_PERSISTENT => true, PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => false)); $db_ub = new PDO("mysql:host=".$dbhost.";dbname=".$dbname, $dbuser, $dbpass, array(PDO::ATTR_PERSISTENT => true, PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true)); $stmt = $db->prepare('A QUERY THAT WILL EXCEED MEMORY LIMIT IF ALL ROWS RETURNED'); $stmt->execute(); while($row = $stmt->fetch(PDO::FETCH_ASSOC)) { //should run out of memory } Case 2: $db = new PDO("mysql:host=".$dbhost.";dbname=".$dbname, $dbuser, $dbpass, array(PDO::ATTR_PERSISTENT => true, PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => false)); $db_ub = new PDO("mysql:host=".$dbhost.";dbname=".$dbname, $dbuser, $dbpass, array(PDO::ATTR_PERSISTENT => true, PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => false)); $stmt = $db->prepare('A QUERY THAT WILL EXCEED MEMORY LIMIT IF ALL ROWS RETURNED'); $stmt->execute(); while($row = $stmt->fetch(PDO::FETCH_ASSOC)) { $stmt = $db_ub->prepare('select now()'); $stmt->execute(); } Expected result: ---------------- $stmt should only have 1 row at a time and memory usage should be low Actual result: -------------- Usually results in PHP Fatal error: Allowed memory size ... ini_set('memory_limit', can be used to get the script to run. -- Edit bug report at https://bugs.php.net/bug.php?id=79661&edit=1 -- Fix committed: https://bugs.php.net/fix.php?id=79661&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=79661&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=79661&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=79661&r=needscript Try newer version: https://bugs.php.net/fix.php?id=79661&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=79661&r=support Expected behavior: https://bugs.php.net/fix.php?id=79661&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=79661&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=79661&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=79661&r=globals PHP version support discontinued: https://bugs.php.net/fix.php?id=79661&r=phptooold Daylight Savings: https://bugs.php.net/fix.php?id=79661&r=dst IIS Stability: https://bugs.php.net/fix.php?id=79661&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=79661&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=79661&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=79661&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=79661&r=mysqlcfg

« previous php.bugs (#227262) next »