Bug #80107 [NEW]: mysqli_query() fails for big query when compression is enabled

From: Date: Tue, 15 Sep 2020 17:09:01 +0000
Subject: Bug #80107 [NEW]: mysqli_query() fails for big query when compression is enabled
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-229016@lists.php.net to get a copy of this message
From: kocsismate Operating system: PHP version: Irrelevant Package: MySQLi related Bug Type: Bug Bug description:mysqli_query() fails for big query when compression is enabled Description: ------------ We noticed that mysqli_query() fails when we want to execute a long query (around 16 MB) with compression enabled, using MYSQLI_CLIENT_CONNECTION. A few details: - mysqli is compiled with mysqlnd - The issue is reproducible both on PHP 7.4 and current master - The issue is reproducible both with MySQL 5.7 and 8.0 - The "max_allowed_packet" MySQL settings don't affect the bug - The query fails when at least 16 777 174 bytes long with "MySQL server has gone away" - The query hangs forever when exactly 16 777 173 bytes long - The query works when less than 16 777 173 bytes long I tried to find some suspicious signs (e.g. by enabling the branch inside "WHEN_WE_NEED_TO_CHECK_WHETHER_COMPRESSION_WORKS_CORRECTLY" in https://github.com/php/php-src/blob/133035951565fcb869f7d0223db6e73adc7e2aea/ext/mysqlnd/mysqlnd_protocol_frame_codec.c#L118), but decompression was working according to the debug output. Test script: --------------- $mysqli = mysqli_init(); $result = $mysqli->real_connect($host, $user, $passwd, $db, $port, $socket, MYSQLI_CLIENT_COMPRESS); // Create test table $mysqli->query("DROP TABLE IF EXISTS test"); $mysqli->query("CREATE TABLE test (blob LONGBLOB NOT NULL)"); // Insert a long string $data = str_repeat("x", 16 * 1024 * 1024); $mysqli->query("INSERT INTO $db.test(blob) VALUE ('$data')"); var_dump(mysqli_error_list($mysqli)); $mysqli->close(); Expected result: ---------------- The query should finish successfully Actual result: -------------- mysqli_error_list() prints the following: array(1) { [0]=> array(3) { ["errno"]=> int(2006) ["sqlstate"]=> string(5) "HY000" ["error"]=> string(26) "MySQL server has gone away" } } -- Edit bug report at https://bugs.php.net/bug.php?id=80107&edit=1 -- Fix committed: https://bugs.php.net/fix.php?id=80107&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=80107&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=80107&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=80107&r=needscript Try newer version: https://bugs.php.net/fix.php?id=80107&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=80107&r=support Expected behavior: https://bugs.php.net/fix.php?id=80107&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=80107&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=80107&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=80107&r=globals PHP version support discontinued: https://bugs.php.net/fix.php?id=80107&r=phptooold Daylight Savings: https://bugs.php.net/fix.php?id=80107&r=dst IIS Stability: https://bugs.php.net/fix.php?id=80107&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=80107&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=80107&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=80107&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=80107&r=mysqlcfg

« previous php.bugs (#229016) next »