Bug #121898 InnoDB assertion crash (SIGABRT) on INPLACE ALTER rebuild to ROW_FORMAT=COMPRESSED with wide table (~1016 cols) and CHAR

Submitted: 24 Nov 6:06
Reporter: fei yang Email Updates:
Status: Open Impact on me:
None 
Category:MySQL Server: DDL Severity:S3 (Non-critical)
Version:8.0.41 (debug), 9.0.1 (debug),9.7.0 (deb OS:Any
Assigned to: CPU Architecture:Any

[24 Nov 6:06] fei yang
Description:
A DROP COLUMN ... ALGORITHM=INPLACE, ROW_FORMAT=COMPRESSED on a wide InnoDB table crashes the server with an InnoDB assertion failure (SIGABRT) in the debug build. The crash happens during index validation of the rebuilt COMPRESSED pages.
The crash window is narrow: it only triggers when the table has exactly 1016 or 1017 columns (5 CHAR(10) NOT NULL prefix PRIMARY KEY columns + 1011/1012 INT NULL columns). It does NOT crash at <=1015 or >=1018 columns. A single-column INT PK with the same total column count does not crash — the 5 multi-byte CHAR(10) prefix PK columns are required. At least one row must be inserted (an empty table does not crash).

How to repeat:
DROP DATABASE IF EXISTS bug_repro;
CREATE DATABASE bug_repro;
USE bug_repro;

SET SESSION group_concat_max_len = 1000000;
SET @cols = (
  SELECT GROUP_CONCAT(CONCAT('c', num, ' INT NULL') ORDER BY num SEPARATOR ',')
  FROM (SELECT 5 + ROW_NUMBER() OVER () AS num
        FROM information_schema.columns LIMIT 1011) x
);
SET @ddl = CONCAT(
  'CREATE TABLE t (',
  'c1 CHAR(10) NOT NULL, c2 CHAR(10) NOT NULL, c3 CHAR(10) NOT NULL, ',
  'c4 CHAR(10) NOT NULL, c5 CHAR(10) NOT NULL, ',
  @cols,
  ', PRIMARY KEY (c1(5),c2(5),c3(5),c4(5),c5(5))) ENGINE=InnoDB'
);
PREPARE s FROM @ddl;
EXECUTE s;
DEALLOCATE PREPARE s;

INSERT INTO t (c1,c2,c3,c4,c5)
VALUES ('aaaaa','bbbbb','ccccc','ddddd','eeeee');

-- crash point
ALTER TABLE t
  DROP COLUMN c50,
  ALGORITHM=INPLACE,
  LOCK=DEFAULT,
  ROW_FORMAT=COMPRESSED;

Stack (debug build):
#4  dict_index_t::add_field  (dict0mem.h:1474)        # magic_n assertion
#5  dict_index_add_col       (dict.cc)
#6  page_zip_fields_decode   (zipdecompress.cc)
#7  page_zip_decompress_low  (zipdecompress.cc)
#8  page_zip_decompress      (page0zip.cc)
#9  buf_zip_decompress
#10..#18 buf_page_get -> btr_root_get -> btr_validate_index
#19 ddl::Loader::validate_indexes   (ddl0loader.cc)
#20 ddl::Context::build             (ddl0ctx.cc)
#22 ha_innobase::inplace_alter_table (handler0alter.cc)
#24 mysql_inplace_alter_table
#25 mysql_alter_table

Suggested fix:
The crash occurs in page_zip_fields_decode() while decompressing a rebuilt COMPRESSED page during Loader::validate_indexes(). Instrumentation shows the field metadata decoded from the compressed page header does not match what page_zip_fields_encode() wrote: the decoded field descriptors become misaligned, so the scan pointer reads past the real field descriptors and interprets garbage bytes as a column mtype. This invalid mtype hits the default: ut_error in dtype_get_fixed_size_low() (data0type.ic:476), and the runaway allocation corrupts the in-memory index object (magic_n check at dict0mem.h:1474) plus the mem heap (no-man's-land check). The 5 CHAR(10) columns are stored as mtype=DATA_MYSQL with fixed_len=0 (variable-length under a multibyte charset), which interacts with the fixed-field coalescing logic in page_zip_fields_encode() at this specific column count to produce the misalignment.

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.053 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.