diff --git a/mysql-test/suite/versioning/r/partition.result b/mysql-test/suite/versioning/r/partition.result index 4c1486d0738..fb9244c223c 100644 --- a/mysql-test/suite/versioning/r/partition.result +++ b/mysql-test/suite/versioning/r/partition.result @@ -3447,4 +3447,22 @@ ERROR HY000: Maybe missing parameters: no rotation condition for multiple HISTOR # # End of 10.5 tests # +# +# MDEV-31903 Server crashes in _ma_reset_history upon UNLOCK table with auto-create history partitions +# +set timestamp= unix_timestamp('2000-01-01 00:00:00'); +create table t1 (x int) engine=aria with system versioning partition by system_time interval 1 hour auto partitions 3; +insert into t1 values (1); +create table t2 (x int) engine=aria; +create trigger tr after insert on t2 for each row update t1 set x= x + 11; +lock tables t1 write, t2 write; +update t1 set x= x + 1; +set timestamp= unix_timestamp('2000-01-01 13:00:00'); +insert into t2 values (5); +unlock tables; +drop table t1, t2; +set timestamp= default; +# +# End of 10.9 tests +# set global innodb_stats_persistent= @save_persistent; diff --git a/mysql-test/suite/versioning/t/partition.test b/mysql-test/suite/versioning/t/partition.test index 3699ac286c8..280b45c5328 100644 --- a/mysql-test/suite/versioning/t/partition.test +++ b/mysql-test/suite/versioning/t/partition.test @@ -2673,5 +2673,26 @@ create table t (a int) with system versioning partition by system_time partition --echo # End of 10.5 tests --echo # +--echo # +--echo # MDEV-31903 Server crashes in _ma_reset_history upon UNLOCK table with auto-create history partitions +--echo # +set timestamp= unix_timestamp('2000-01-01 00:00:00'); +create table t1 (x int) engine=aria with system versioning partition by system_time interval 1 hour auto partitions 3; +insert into t1 values (1); + +create table t2 (x int) engine=aria; +create trigger tr after insert on t2 for each row update t1 set x= x + 11; +lock tables t1 write, t2 write; +update t1 set x= x + 1; +set timestamp= unix_timestamp('2000-01-01 13:00:00'); +insert into t2 values (5); +unlock tables; +drop table t1, t2; +set timestamp= default; + +--echo # +--echo # End of 10.9 tests +--echo # + set global innodb_stats_persistent= @save_persistent; --source suite/versioning/common_finish.inc diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index 483ea1566c5..590c2a508f4 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -7753,7 +7753,7 @@ uint fast_alter_partition_table(THD *thd, TABLE *table, ERROR_INJECT("add_partition_1") || mysql_write_frm(lpt, WFRM_WRITE_SHADOW) || ERROR_INJECT("add_partition_2") || - wait_while_table_is_used(thd, table, HA_EXTRA_NOT_USED) || + wait_while_table_is_used(thd, table, HA_EXTRA_PREPARE_FOR_RENAME) || ERROR_INJECT("add_partition_3") || write_log_add_change_partition(lpt) || ERROR_INJECT("add_partition_4") ||