mariadb/mysql-test/suite/rpl
Brandon Nesterenko 5f51a3a6eb MDEV-36906: RBR crashes upon DML after CONVERT PARTITION
MDEV-33658 part 1’s refactoring ecaedbe299
introduced a new function init_key_info which (in part) aims to
calculate the total key length; however, it doesn’t account for the
key already having been initialized (as happens when called via
ALTER TABLE .. CONVERT PARTITION .. TO TABLE). This leads to crashes
when this key is later iterated over, because the iterator will try
to iterate over additional key parts which don’t exist because the
length reports as longer than the actual memory owned. The crash
reported by MDEV-36906 highlights this in function key_copy.

To explain how the keys already have been initialized, init_key_info
is called multiple times. That is, init_key_info is called from
mysql_prepare_create_table, which prepares a table and its key
structures for table creation, which is in turn called by
mysql_write_frm when using flags MFRM_WRITE_SHADOW and
MFRM_WRITE_CONVERTED_TO. The
ALTER TABLE .. CONVERT PARTITION .. TO TABLE use case (see function
fast_alter_partition_table), calls mysql_write_frm multiple times with
both of these flags set (first with MFRM_WRITE_CONVERTED_TO and then
with MFRM_WRITE_SHADOW).

Raising it up a level, mysql_prepare_create_table doesn't need to be
called again after it has already been invoked when just writing frms.
Init_key_info is the only place in that function which leads to side
effects, but the rest is redundant and can be skipped on the second
call (i.e. when writing the shadow).

The patch fixes this by skipping the call to mysql_prepare_create_table
in mysql_write_frm in the MFRM_WRITE_SHADOW block when it has already
been called previously. To track whether or not it has been previously
called, we add a new flag for the mysql_write_frm function,
MFRM_ALTER_INFO_PREPARED, which is hard-coded into the function call on
the later invocation.

Test case based on work by Elena Stepanova <elenst@mariadb.com>

Reviewed By:
============
Sergei Golubchik <serg@mariadb.org>
Nikita Malyavin <nikita.malyavin@mariadb.com>
2025-07-22 11:30:39 -06:00
..
extension mtr: use env for perl 2020-06-23 03:24:46 +02:00
include Merge 10.6 -> 10.11 2024-12-05 10:11:58 +01:00
r MDEV-36906: RBR crashes upon DML after CONVERT PARTITION 2025-07-22 11:30:39 -06:00
t MDEV-36906: RBR crashes upon DML after CONVERT PARTITION 2025-07-22 11:30:39 -06:00
disabled.def Fix RPL tests post DEBUG_SYNC change 2023-02-10 14:44:45 +02:00
my.cnf Remove duplicated default client include from replication my.cnf 2023-09-14 12:56:41 +02:00
README
rpl_1slave_base.cnf

How to run.
===========

./mysql-test-run.pl --suite=rpl --mysqld=--binlog-format=mixed