Bug #80107 [PATCH]: mysqli_query() fails for ~16 MB long query when compression is enabled
Edit report at https://bugs.php.net/bug.php?id=80107&edit=1
ID: 80107
Patch added by: kocsismate@php.net
Reported by: kocsismate@php.net
Summary: mysqli_query() fails for ~16 MB long query when
compression is enabled
Status: Open
Type: Bug
Package: MySQLi related
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
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
Previous Comments:
------------------------------------------------------------------------
[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
Thread (3 messages)