mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
MDEV-23248 Server crashes in mi_extra / ha_partition::loop_extra_alter upon REORGANIZE
This also fixes some issues with MDEV-23730 s3.replication_partition 'innodb,mix' segv The problem was that mysql_change_partitions() closes all handler files in case of error, which was not properly reflected in fast_alter_partition_table(). This caused handle_alter_part_error() to try to close already closed tables, which caused the crash. Fixed fast_alter_partion_table() to reflect when tables are opened. I also fixed that ha_partition::change_partitions() resets m_new_file in case of errors. Either of the above changes fixes the issue, but both are needed to ensure that the code works as expected.
This commit is contained in:
13
mysql-test/suite/parts/r/reorganize.result
Normal file
13
mysql-test/suite/parts/r/reorganize.result
Normal file
@ -0,0 +1,13 @@
|
||||
#
|
||||
# MDEV-23248 Server crashes in mi_extra /
|
||||
# ha_partition::loop_extra_alter upon REORGANIZE
|
||||
#
|
||||
CREATE TABLE t1 (a INT, b INT) ENGINE=MyISAM PARTITION BY RANGE (a) SUBPARTITION BY HASH (a) SUBPARTITIONS 70 (PARTITION p1 VALUES LESS THAN (100), PARTITION p2 VALUES LESS THAN MAXVALUE);
|
||||
INSERT INTO t1 SELECT 4, 6 FROM seq_1_to_131072;
|
||||
UPDATE t1 SET a = 7;
|
||||
set @org_debug=@@debug_dbug;
|
||||
set @@debug_dbug="+d,debug_abort_copy_partitions";
|
||||
ALTER TABLE t1 REORGANIZE PARTITION p1,p2 INTO (PARTITION p1 VALUES LESS THAN (5), PARTITION p2 VALUES LESS THAN MAXVALUE);
|
||||
ERROR 42000: Table 't1' uses an extension that doesn't exist in this MariaDB version
|
||||
set @@debug_dbug=@org_debug;
|
||||
DROP TABLE t1;
|
20
mysql-test/suite/parts/t/reorganize.test
Normal file
20
mysql-test/suite/parts/t/reorganize.test
Normal file
@ -0,0 +1,20 @@
|
||||
--source include/have_sequence.inc
|
||||
--source include/have_partition.inc
|
||||
--source include/have_debug.inc
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-23248 Server crashes in mi_extra /
|
||||
--echo # ha_partition::loop_extra_alter upon REORGANIZE
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t1 (a INT, b INT) ENGINE=MyISAM PARTITION BY RANGE (a) SUBPARTITION BY HASH (a) SUBPARTITIONS 70 (PARTITION p1 VALUES LESS THAN (100), PARTITION p2 VALUES LESS THAN MAXVALUE);
|
||||
INSERT INTO t1 SELECT 4, 6 FROM seq_1_to_131072;
|
||||
UPDATE t1 SET a = 7;
|
||||
|
||||
set @org_debug=@@debug_dbug;
|
||||
set @@debug_dbug="+d,debug_abort_copy_partitions";
|
||||
--error ER_UNSUPPORTED_EXTENSION
|
||||
ALTER TABLE t1 REORGANIZE PARTITION p1,p2 INTO (PARTITION p1 VALUES LESS THAN (5), PARTITION p2 VALUES LESS THAN MAXVALUE);
|
||||
set @@debug_dbug=@org_debug;
|
||||
|
||||
DROP TABLE t1;
|
@ -2025,6 +2025,7 @@ int ha_partition::change_partitions(HA_CREATE_INFO *create_info,
|
||||
DBUG_ASSERT(part_elem->part_state == PART_TO_BE_REORGED);
|
||||
part_elem->part_state= PART_TO_BE_DROPPED;
|
||||
}
|
||||
DBUG_ASSERT(m_new_file == 0);
|
||||
m_new_file= new_file_array;
|
||||
if (unlikely((error= copy_partitions(copied, deleted))))
|
||||
{
|
||||
@ -2033,6 +2034,7 @@ int ha_partition::change_partitions(HA_CREATE_INFO *create_info,
|
||||
They will later be deleted through the ddl-log.
|
||||
*/
|
||||
cleanup_new_partition(part_count);
|
||||
m_new_file= 0;
|
||||
}
|
||||
DBUG_RETURN(error);
|
||||
}
|
||||
@ -2124,6 +2126,8 @@ int ha_partition::copy_partitions(ulonglong * const copied,
|
||||
file->ha_rnd_end();
|
||||
reorg_part++;
|
||||
}
|
||||
DBUG_EXECUTE_IF("debug_abort_copy_partitions",
|
||||
DBUG_RETURN(HA_ERR_UNSUPPORTED); );
|
||||
DBUG_RETURN(FALSE);
|
||||
error:
|
||||
m_reorged_file[reorg_part]->ha_rnd_end();
|
||||
|
@ -7487,11 +7487,11 @@ uint fast_alter_partition_table(THD *thd, TABLE *table,
|
||||
mysql_write_frm(lpt, WFRM_WRITE_SHADOW) ||
|
||||
ERROR_INJECT_CRASH("crash_change_partition_2") ||
|
||||
ERROR_INJECT_ERROR("fail_change_partition_2") ||
|
||||
(close_table_on_failure= TRUE, FALSE) ||
|
||||
write_log_add_change_partition(lpt) ||
|
||||
ERROR_INJECT_CRASH("crash_change_partition_3") ||
|
||||
ERROR_INJECT_ERROR("fail_change_partition_3") ||
|
||||
mysql_change_partitions(lpt) ||
|
||||
(close_table_on_failure= TRUE, FALSE) ||
|
||||
ERROR_INJECT_CRASH("crash_change_partition_4") ||
|
||||
ERROR_INJECT_ERROR("fail_change_partition_4") ||
|
||||
wait_while_table_is_used(thd, table, HA_EXTRA_NOT_USED) ||
|
||||
|
Reference in New Issue
Block a user