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 in maria_create() and _ma_read_rnd_dynamic_record(), not a recent change. CS 10.11 and ES 10.6 have it too.
SET @save_max_allowed_packet= @@global.max_allowed_packet; |
SET GLOBAL max_allowed_packet= 1073741824; |
--connect (con1,localhost,root)
|
CREATE TABLE t1 (a LONGBLOB, b LONGBLOB) ENGINE=Aria ROW_FORMAT=DYNAMIC; |
INSERT INTO t1 VALUES (REPEAT('a',1073741824), REPEAT('b',1073741824)); |
--disable_result_log
|
--error 0,127
|
SELECT LENGTH(a), LENGTH(b) FROM t1; |
--enable_result_log
|
--let $err= $mysql_errno
|
DROP TABLE t1; |
if ($err) |
{
|
--die The INSERT of a 2 GB row into an Aria DYNAMIC table succeeded, but the table now reads as corrupted |
}
|
CREATE TABLE t1 (a LONGBLOB, b LONGBLOB) ENGINE=Aria; |
INSERT INTO t1 VALUES (REPEAT('a',1073741824), REPEAT('b',1073741824)), ('c','d'); |
--disable_result_log
|
--error 0,127
|
SELECT LENGTH(a), LENGTH(b) FROM (SELECT DISTINCT a, b FROM t1) dt; |
--enable_result_log
|
--let $err= $mysql_errno
|
DROP TABLE t1; |
if ($err) |
{
|
--die A DISTINCT query over a 2 GB row failed, the internal temporary table reads as corrupted |
}
|
--disconnect con1
|
--connection default
|
SET GLOBAL max_allowed_packet= @save_max_allowed_packet; |
Leads to:
|
CS 13.1.2 87e62ca17270e163a6d41b3fc8d6f4d440f1bb88 (Optimized, Clang 22.1.8-20260622) Build 05/10/2026 |
mysqltest: At line 14: The INSERT of a 2 GB row into an Aria DYNAMIC table succeeded, but the table now reads as corrupted
|
The same statements in the client:
|
CS 13.1.2 87e62ca17270e163a6d41b3fc8d6f4d440f1bb88 (Optimized, Clang 22.1.8-20260622) Build 05/10/2026 |
ERROR 127 (HY000) at line 3: Got error '127 "Table file is corrupted"' for './test/t1.MAI'
|
|
CS 13.1.2 87e62ca17270e163a6d41b3fc8d6f4d440f1bb88 (Optimized, Clang 22.1.8-20260622) Build 05/10/2026 |
2026-10-07 7:59:23 4 [ERROR] mariadbd: Got error '127 "Table file is corrupted"' for './test/t1.MAI'
|
2026-10-07 7:59:23 4 [ERROR] Got error 127 when reading table './test/t1'
|
2026-10-07 7:59:23 4 [ERROR] mariadbd: Table 't1' is marked as crashed and should be repaired
|
REPAIR TABLE on that table:
|
CS 13.1.2 87e62ca17270e163a6d41b3fc8d6f4d440f1bb88 (Optimized, Clang 22.1.8-20260622) Build 05/10/2026 |
Table Op Msg_type Msg_text
|
test.t1 repair info Wrong bytesec: 13-128- 0 at 0; Skipped
|
test.t1 repair info Found link that points at 7016996765293437281 (outside data file) at 83886068
|
test.t1 repair info Found link that points at 7016996765293437281 (outside data file) at 100663280
|
test.t1 repair warning Number of rows changed from 1 to 0
|
test.t1 repair Error Got error '127 "Table file is corrupted"' for './test/t1.MAI'
|
test.t1 repair status Operation failed
|
In the default PAGE row format the same row is stored and read back in full.
The second half of the testcase reaches the same limit through the internal temporary table of a DISTINCT. Run on its own in the client, it gives:
|
CS 13.1.2 87e62ca17270e163a6d41b3fc8d6f4d440f1bb88 (Optimized, Clang 22.1.8-20260622) Build 05/10/2026 |
ERROR 127 (HY000) at line 3: Got error '127 "Table file is corrupted"' for '#sql-temptable-25efa-4-1.MAI'
|
|
CS 13.1.2 87e62ca17270e163a6d41b3fc8d6f4d440f1bb88 (Optimized, Clang 22.1.8-20260622) Build 05/10/2026 |
2026-10-07 7:33:46 4 [ERROR] mariadbd: Got error '127 "Table file is corrupted"' for '#sql-temptable-25efa-4-1.MAI'
|
2026-10-07 7:33:46 4 [ERROR] mariadbd: Table '(temporary)' is marked as crashed and should be repaired
|
With t1 on InnoDB the error is the same.
From the code it seems that maria_create() caps pack_reclength at INT_MAX32 for a blob with a four byte length, and keeps it as share.base.max_pack_length. The row is written without a check against that value. A table scan then reads the row in _ma_read_rnd_dynamic_record(), which sends a record longer than max_pack_length to panic, and that gives error 127. create_internal_tmp_table() creates a temporary table used for duplicate elimination with DYNAMIC_RECORD, so the DISTINCT takes the same path.
Attachments
Issue Links
- relates to
-
MDEV-41410 A 2 GB row is written to a MyISAM table but reads back as a crashed table with error 127
-
- Open
-