* Dmitry Shulga <Dmitry.Shulga@stripped> [10/10/27 14:42]:
> 3547 Dmitry Shulga 2010-10-27
> Fixed bug#56619 - Assertion failed during
> ALTER TABLE RENAME, DISABLE KEYS.
Hi,
Please describe how the fix solves the problem:
The code of ALTER TABLE RENAME, DISABLE KEYS could
issue a commit while holding LOCK_open mutex.
This is a regression introduced by the fix for
Bug 54453.
This failed an assert guarding us against a potential
deadlock with connections trying to execute
FLUSH TABLES WITH READ LOCK.
The fix is to move acquisition of LOCK_open outside
the section that issues ha_autocommit_or_rollback().
LOCK_open is taken to protect against concurrent
operations with .frms and the table definition
cache, and doesn't need to cover the call to commit.
A test case added to innodb_mysql.test.
The patch is to be null-merged to 5.5, which
already has 54453 null-merged to it.
> @ mysql-test/suite/innodb/r/innodb_mysql.result
> Added test results for test for bug#56619.
> @ mysql-test/suite/innodb/t/innodb_mysql.test
> Added test for bug#56619.
> @ sql/sql_table.cc
> mysql_alter_table() modified: moved acquisition of LOCK_open
> after call to ha_autocommit_or_rollback.
>
> modified:
> mysql-test/suite/innodb/r/innodb_mysql.result
> mysql-test/suite/innodb/t/innodb_mysql.test
> sql/sql_table.cc
> === modified file 'mysql-test/suite/innodb/r/innodb_mysql.result'
> --- a/mysql-test/suite/innodb/r/innodb_mysql.result 2010-10-05 08:11:56 +0000
> +++ b/mysql-test/suite/innodb/r/innodb_mysql.result 2010-10-27 09:37:22 +0000
> @@ -2620,3 +2620,10 @@ t2 CREATE TABLE `t2` (
> CONSTRAINT `x` FOREIGN KEY (`fk`) REFERENCES `t1` (`pk`)
> ) ENGINE=InnoDB DEFAULT CHARSET=latin1
> drop table t2, t1;
> +#
> +# Test for bug #56619 - Assertion failed during ALTER TABLE RENAME, DISABLE KEYS
> +#
> +DROP TABLE IF EXISTS t1, t2;
> +CREATE TABLE t1 (a INT, INDEX(a)) engine=innodb;
> +ALTER TABLE t1 RENAME TO t2, DISABLE KEYS;
> +DROP TABLE IF EXISTS t1, t2;
>
> === modified file 'mysql-test/suite/innodb/t/innodb_mysql.test'
> --- a/mysql-test/suite/innodb/t/innodb_mysql.test 2010-10-05 08:11:56 +0000
> +++ b/mysql-test/suite/innodb/t/innodb_mysql.test 2010-10-27 09:37:22 +0000
> @@ -845,3 +845,15 @@ create table t2 (fk int, key x (fk),
> constraint x foreign key (FK) references t1 (PK)) engine=InnoDB;
> show create table t2;
> drop table t2, t1;
> +
> +--echo #
> +--echo # Test for bug #56619 - Assertion failed during ALTER TABLE RENAME, DISABLE
> KEYS
> +--echo #
Please make sure this fits 80 columns.
> +--disable_warnings
> +DROP TABLE IF EXISTS t1, t2;
> +--enable_warnings
> +CREATE TABLE t1 (a INT, INDEX(a)) engine=innodb;
> +--disable_warnings
> +ALTER TABLE t1 RENAME TO t2, DISABLE KEYS;
> +DROP TABLE IF EXISTS t1, t2;
> +--enable_warnings
>
> === modified file 'sql/sql_table.cc'
> --- a/sql/sql_table.cc 2010-10-19 10:27:09 +0000
> +++ b/sql/sql_table.cc 2010-10-27 09:37:22 +0000
> @@ -6832,7 +6832,6 @@ view_err:
> table->alias);
> }
>
> - VOID(pthread_mutex_lock(&LOCK_open));
> /*
> Unlike to the above case close_cached_table() below will remove ALL
> instances of TABLE from table cache (it will also remove table lock
> @@ -6853,6 +6852,7 @@ view_err:
> */
> ha_autocommit_or_rollback(thd, 0);
>
> + VOID(pthread_mutex_lock(&LOCK_open));
> /*
> Then do a 'simple' rename of the table. First we need to close all
> instances of 'source' table.
> @@ -6884,7 +6884,8 @@ view_err:
> error= -1;
> }
> }
> - }
> + } else
Coding style: else deserves its own line.
> + VOID(pthread_mutex_lock(&LOCK_open));
>
> if (error == HA_ERR_WRONG_COMMAND)
> {
>
--