Details
-
Bug
-
Status: Open (View Workflow)
-
Critical
-
Resolution: Unresolved
-
10.11, 11.4, 11.8, 12.3, 13.1, 13.2, 13.3
Description
Likely cause: old code, not a recent change. ha_tina::update_row() has kept the row length in an int since the CSV engine was added in 2004 (commit 89987fa1044438f01c4a2efdf5563ec1c50a2102). MySQL 5.5 to 9.1 lose the row the same way.
SET @save_max_allowed_packet= @@global.max_allowed_packet; |
SET GLOBAL max_allowed_packet= 1073741824; |
--connect (con1,localhost,root)
|
CREATE TABLE t1 (a LONGBLOB NOT NULL, b LONGBLOB NOT NULL) ENGINE=CSV; |
INSERT INTO t1 VALUES ('1','1'),('2','2'),('3','3'); |
--error 0,3
|
UPDATE t1 SET a= REPEAT('a',1073741824), b= REPEAT('b',1073741824) WHERE a= '2'; |
--let $c= query_get_value(SELECT COUNT(*) AS c FROM t1, c, 1)
|
if ($c != 3) |
{
|
--die The failed UPDATE of one row to 2 GB left the CSV table with $c of its 3 rows |
}
|
DROP TABLE t1; |
--disconnect con1
|
--connection default
|
SET GLOBAL max_allowed_packet= @save_max_allowed_packet; |
Leads to:
|
CS 13.3.0 392818112aa1738005b977c21387d272b4287842 (Optimized, Clang 22.1.8-20260622) Build 19/11/2026 |
mysqltest: At line 11: The failed UPDATE of one row to 2 GB left the CSV table with 2 of its 3 rows
|
The same statements in the client:
|
CS 13.3.0 392818112aa1738005b977c21387d272b4287842 (Optimized, Clang 22.1.8-20260622) Build 19/11/2026 |
--------------
|
UPDATE t1 SET a= REPEAT('a',1073741824), b= REPEAT('b',1073741824) WHERE a= '2'
|
--------------
|
 |
ERROR 3 (HY000) at line 3: Error writing file './test/t1.CSN' (Errcode: 14 "Bad address")
|
+---+
|
| a |
|
+---+
|
| 1 |
|
| 3 |
|
+---+
|
+---------+-------+----------+----------+
|
| Table | Op | Msg_type | Msg_text |
|
+---------+-------+----------+----------+
|
| test.t1 | check | error | Corrupt |
|
+---------+-------+----------+----------+
|
The UPDATE fails, and the row it was to change is gone: neither the old row nor the new row is in the table, and CHECK TABLE reports the table as corrupt. REPAIR TABLE then gives OK, but the row does not come back. An INSERT of a 2 GB row gives the same error, and there the table stays intact. A row of this size can be stored in ARCHIVE, InnoDB and Aria tables.
From the code it seems that ha_tina::encode_quote() returns the row length as int, and ha_tina::update_row() and ha_tina::write_row() keep it in int size and pass it to mysql_file_write(). Over 2 GB that value is negative, and the write gets EFAULT. ha_tina::update_row() first marks the old row as deleted with chain_append(), and that mark stays when the write fails, so rnd_end() leaves the row out of the new data file.