Commit 4783494a authored by Aleksey Midenkov's avatar Aleksey Midenkov

MDEV-22283 Server crashes in key_copy or unexpected error 156

(The table already existed in the storage engine)

Wrong algorithm of closing partitions on error doesn't close last
partition.
parent d74e3a56
...@@ -658,6 +658,23 @@ pk f ...@@ -658,6 +658,23 @@ pk f
update t1 set f=pk; update t1 set f=pk;
delete from t1; delete from t1;
drop table t1; drop table t1;
# Test cleanup #
drop database test; # MDEV-22283 Server crashes in key_copy or unexpected error 156: The table already existed in the storage engine
create database test; #
create table t1 (a int primary key) engine=aria page_checksum=0
with system versioning
partition by system_time (partition p1 history, partition pn current);
alter table t1 add partition (partition p2 history);
Warnings:
Warning 4115 Maybe missing parameters: no rotation condition for multiple HISTORY partitions.
show table status;
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
t1 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL Got error 174 "Fatal error during initialization of handler" from storage engine Aria NULL NULL
Warnings:
Warning 1030 Got error 174 "Fatal error during initialization of handler" from storage engine Aria
drop table t1;
create table t1 (b int) engine=aria row_format=dynamic with system versioning
partition by system_time (partition p1 history, partition pn current);
insert into t1 values (1);
replace into t1 values (1);
drop table t1;
...@@ -574,7 +574,6 @@ update t1 left join t2 on a > b set b= 2 order by b; ...@@ -574,7 +574,6 @@ update t1 left join t2 on a > b set b= 2 order by b;
# cleanup # cleanup
drop table t1, t2; drop table t1, t2;
--source suite/versioning/common_finish.inc
--echo # --echo #
--echo # MDEV-17091 Assertion `old_part_id == m_last_part' failed in --echo # MDEV-17091 Assertion `old_part_id == m_last_part' failed in
--echo # ha_partition::update_row or `part_id == m_last_part' in --echo # ha_partition::update_row or `part_id == m_last_part' in
...@@ -596,6 +595,23 @@ update t1 set f=pk; ...@@ -596,6 +595,23 @@ update t1 set f=pk;
delete from t1; delete from t1;
drop table t1; drop table t1;
--echo # Test cleanup --echo #
drop database test; --echo # MDEV-22283 Server crashes in key_copy or unexpected error 156: The table already existed in the storage engine
create database test; --echo #
create table t1 (a int primary key) engine=aria page_checksum=0
with system versioning
partition by system_time (partition p1 history, partition pn current);
alter table t1 add partition (partition p2 history);
show table status;
drop table t1;
create table t1 (b int) engine=aria row_format=dynamic with system versioning
partition by system_time (partition p1 history, partition pn current);
insert into t1 values (1);
replace into t1 values (1);
# cleanup
drop table t1;
--source suite/versioning/common_finish.inc
...@@ -3657,11 +3657,13 @@ int ha_partition::open(const char *name, int mode, uint test_if_locked) ...@@ -3657,11 +3657,13 @@ int ha_partition::open(const char *name, int mode, uint test_if_locked)
err_handler: err_handler:
DEBUG_SYNC(ha_thd(), "partition_open_error"); DEBUG_SYNC(ha_thd(), "partition_open_error");
file= &m_file[m_tot_parts - 1]; DBUG_ASSERT(m_tot_parts > 0);
while (file-- != m_file) for (uint i= m_tot_parts - 1; ; --i)
{ {
if (bitmap_is_set(&m_opened_partitions, (uint)(file - m_file))) if (bitmap_is_set(&m_opened_partitions, i))
(*file)->ha_close(); m_file[i]->ha_close();
if (!i)
break;
} }
err_alloc: err_alloc:
free_partition_bitmaps(); free_partition_bitmaps();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment