From 26cc22f3fe95cfd535d61540101fe89cd10c9026 Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Wed, 16 May 2012 22:04:48 +0300 Subject: [PATCH] Fixed LP:990187 Assertion `share->reopen == 1' failed at maria_extra on ADD PARTITION mysql-test/suite/maria/maria-partitioning.result: New test case mysql-test/suite/maria/maria-partitioning.test: New test case sql/sql_base.cc: Ignore HA_EXTRA_NORMAL for wait_while_table_is_used() More DBUG sql/sql_partition.cc: Don't use HA_EXTRA_FORCE_REOPEN for wait_while_table_is_used() as the table is opened multiple times (in prep_alter_part_table) This fixes the assert in Aria where we check if table is opened multiple times if HA_EXTRA_FORCE_REOPEN is issued --- mysql-test/suite/maria/maria-partitioning.result | 4 ++++ mysql-test/suite/maria/maria-partitioning.test | 9 +++++++++ sql/sql_base.cc | 6 +++++- sql/sql_partition.cc | 6 +++--- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/mysql-test/suite/maria/maria-partitioning.result b/mysql-test/suite/maria/maria-partitioning.result index 840c7c0b3b4..bcb88626ff7 100644 --- a/mysql-test/suite/maria/maria-partitioning.result +++ b/mysql-test/suite/maria/maria-partitioning.result @@ -28,3 +28,7 @@ insert into t1 values (2); select * from t2 left join t1 on (t2.a=t1.a) where t2.a='bbb'; a a drop table t1,t2; +CREATE TABLE t1 ( i INT ) ENGINE=Aria +PARTITION BY HASH(i) PARTITIONS 2; +ALTER TABLE t1 ADD PARTITION PARTITIONS 2; +drop table t1; diff --git a/mysql-test/suite/maria/maria-partitioning.test b/mysql-test/suite/maria/maria-partitioning.test index 612c44be57e..446cfed770b 100644 --- a/mysql-test/suite/maria/maria-partitioning.test +++ b/mysql-test/suite/maria/maria-partitioning.test @@ -34,6 +34,15 @@ insert into t1 values (2); select * from t2 left join t1 on (t2.a=t1.a) where t2.a='bbb'; drop table t1,t2; +# +# LP:990187 +# Assertion `share->reopen == 1' failed at maria_extra on ADD PARTITION +# +CREATE TABLE t1 ( i INT ) ENGINE=Aria + PARTITION BY HASH(i) PARTITIONS 2; +ALTER TABLE t1 ADD PARTITION PARTITIONS 2; +drop table t1; + # Set defaults back --disable_result_log --disable_query_log diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 446019ac420..88f7484b52f 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -2312,6 +2312,7 @@ bool rename_temporary_table(THD* thd, TABLE *table, const char *db, @param function HA_EXTRA_PREPARE_FOR_DROP if table is to be deleted HA_EXTRA_FORCE_REOPEN if table is not be used HA_EXTRA_PREPARE_FOR_RENAME if table is to be renamed + HA_EXTRA_NORMAL Don't call extra() @note When returning, the table will be unusable for other threads until metadata lock is downgraded. @@ -2336,7 +2337,8 @@ bool wait_while_table_is_used(THD *thd, TABLE *table, table->s->db.str, table->s->table_name.str, FALSE); /* extra() call must come only after all instances above are closed */ - (void) table->file->extra(function); + if (function != HA_EXTRA_NORMAL) + (void) table->file->extra(function); DBUG_RETURN(FALSE); } @@ -9240,6 +9242,7 @@ void tdc_remove_table(THD *thd, enum_tdc_remove_table_type remove_type, uint key_length; TABLE *table; TABLE_SHARE *share; + DBUG_ENTER("tdc_remove_table"); if (! has_lock) mysql_mutex_lock(&LOCK_open); @@ -9297,6 +9300,7 @@ void tdc_remove_table(THD *thd, enum_tdc_remove_table_type remove_type, if (! has_lock) mysql_mutex_unlock(&LOCK_open); + DBUG_VOID_RETURN; } diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index 00c70c5f973..00fba5f331a 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -6640,7 +6640,7 @@ uint fast_alter_partition_table(THD *thd, TABLE *table, mysql_write_frm(lpt, WFRM_WRITE_SHADOW) || ERROR_INJECT_CRASH("crash_drop_partition_2") || ERROR_INJECT_ERROR("fail_drop_partition_2") || - wait_while_table_is_used(thd, table, HA_EXTRA_FORCE_REOPEN) || + wait_while_table_is_used(thd, table, HA_EXTRA_NORMAL) || ERROR_INJECT_CRASH("crash_drop_partition_3") || ERROR_INJECT_ERROR("fail_drop_partition_3") || (close_table_on_failure= TRUE, FALSE) || @@ -6714,7 +6714,7 @@ uint fast_alter_partition_table(THD *thd, TABLE *table, mysql_write_frm(lpt, WFRM_WRITE_SHADOW) || ERROR_INJECT_CRASH("crash_add_partition_2") || ERROR_INJECT_ERROR("fail_add_partition_2") || - wait_while_table_is_used(thd, table, HA_EXTRA_FORCE_REOPEN) || + wait_while_table_is_used(thd, table, HA_EXTRA_NORMAL) || ERROR_INJECT_CRASH("crash_add_partition_3") || ERROR_INJECT_ERROR("fail_add_partition_3") || (close_table_on_failure= TRUE, FALSE) || @@ -6820,7 +6820,7 @@ uint fast_alter_partition_table(THD *thd, TABLE *table, mysql_change_partitions(lpt) || ERROR_INJECT_CRASH("crash_change_partition_4") || ERROR_INJECT_ERROR("fail_change_partition_4") || - wait_while_table_is_used(thd, table, HA_EXTRA_FORCE_REOPEN) || + wait_while_table_is_used(thd, table, HA_EXTRA_NORMAL) || ERROR_INJECT_CRASH("crash_change_partition_5") || ERROR_INJECT_ERROR("fail_change_partition_5") || write_log_final_change_partition(lpt) ||