Bug #80107 [Opn->Csd]: mysqli_query() fails for ~16 MB long query when compression is enabled

From: Date: Fri, 18 Sep 2020 11:01:57 +0000
Subject: Bug #80107 [Opn->Csd]: mysqli_query() fails for ~16 MB long query when compression is enabled
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-229068@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=80107&edit=1 ID: 80107 Updated by: nikic@php.net Reported by: kocsismate@php.net Summary: mysqli_query() fails for ~16 MB long query when compression is enabled -Status: Open +Status: Closed Type: Bug Package: MySQLi related PHP Version: Irrelevant Block user comment: N Private report: N New Comment: Automatic comment on behalf of nikita.ppv@gmail.com Revision: http://git.php.net/?p=php-src.git;a=commit;h=ecd9c42f9e54b53ea6917b2a28ae9e5a2c89c2fe Log: Fix bug #80107: Handling of large compressed packets Previous Comments: ------------------------------------------------------------------------ [2020-09-15 17:18:31] kocsismate@php.net The following pull request has been associated: Patch Name: Bug #80107 Add test for mysqli_query() fails for ~16 MB long query when compression is enabled On GitHub: https://github.com/php/php-src/pull/6136 Patch: https://github.com/php/php-src/pull/6136.patch ------------------------------------------------------------------------ [2020-09-15 17:09:01] kocsismate@php.net 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 this bug report at https://bugs.php.net/bug.php?id=80107&edit=1

« previous php.bugs (#229068) next »