From: Jon Olav Hauglid Date: March 7 2011 1:58pm Subject: bzr push into mysql-5.5 branch (jon.hauglid:3374 to 3375) Bug#11784056 List-Archive: http://lists.mysql.com/commits/132543 X-Bug: 11784056 Message-Id: <201103071359.p27A3hU0027755@acsinet15.oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 3375 Jon Olav Hauglid 2011-03-07 Bug #11784056 ENABLE CONCURRENT READS WHILE CREATING NON-PRIMARY UNIQUE INDEX USING INNODB This patch adds the HA_INPLACE_ADD_UNIQUE_INDEX_NO_WRITE capability flag to InnoDB, indicating that concurrent reads can be allowed while non-primary unique indexes are created. This is an follow-up to Bug #11751388 which enabled concurrent reads when creating non-primary non-unique indexes. Test case added to innodb_mysql_sync.test. modified: mysql-test/r/innodb_mysql_sync.result mysql-test/t/innodb_mysql_sync.test storage/innobase/handler/ha_innodb.cc 3374 Jon Olav Hauglid 2011-03-07 Bug #11764779 (former 57649) FLUSH TABLES under FLUSH TABLES WITH READ LOCK leads to assert failure. This assert was triggered if a statement tried up upgrade a metadata lock with an active FLUSH TABLE WITH READ LOCK. The assert checks that the connection already holds a global intention exclusive metadata lock. However, FLUSH TABLE WITH READ LOCK does not acquire this lock in order to be compatible with FLUSH TABLES WITH READ LOCK. Therefore any metadata lock upgrade caused the assert to be triggered. This patch fixes the problem by preventing metadata lock upgrade if the connection has an active FLUSH TABLE WITH READ LOCK. ER_TABLE_NOT_LOCKED_FOR_WRITE will instead be reported to the client. Test case added to flush.test. modified: mysql-test/r/flush.result mysql-test/t/flush.test sql/sql_base.cc sql/sql_base.h sql/sql_reload.cc sql/sql_table.cc sql/sql_trigger.cc sql/sql_truncate.cc === modified file 'mysql-test/r/innodb_mysql_sync.result' --- a/mysql-test/r/innodb_mysql_sync.result 2011-01-26 13:23:29 +0000 +++ b/mysql-test/r/innodb_mysql_sync.result 2011-03-07 13:30:49 +0000 @@ -153,5 +153,15 @@ SET DEBUG_SYNC= "now SIGNAL query"; a b # Test 4: Secondary unique index, should not block reads. # Connection default +SET DEBUG_SYNC= "alter_table_manage_keys SIGNAL manage WAIT_FOR query"; +# Sending: +ALTER TABLE t1 ADD UNIQUE (b); +# Connection con1 +SET DEBUG_SYNC= "now WAIT_FOR manage"; +SELECT * FROM t1; +a b +SET DEBUG_SYNC= "now SIGNAL query"; +# Connection default +# Reaping: ALTER TABLE t1 ADD UNIQUE (b) SET DEBUG_SYNC= "RESET"; DROP TABLE t1; === modified file 'mysql-test/t/innodb_mysql_sync.test' --- a/mysql-test/t/innodb_mysql_sync.test 2011-01-26 13:23:29 +0000 +++ b/mysql-test/t/innodb_mysql_sync.test 2011-03-07 13:30:49 +0000 @@ -253,26 +253,23 @@ connection con1; --reap --echo # Test 4: Secondary unique index, should not block reads. -# This requires HA_INPLACE_ADD_UNIQUE_INDEX_NO_WRITE to be supported -# by InnoDB. Adding this flag currently introduces a regression so -# this test is disabled until the regression has been fixed. --echo # Connection default connection default; -#SET DEBUG_SYNC= "alter_table_manage_keys SIGNAL manage WAIT_FOR query"; -#--echo # Sending: -#--send ALTER TABLE t1 ADD UNIQUE (b) +SET DEBUG_SYNC= "alter_table_manage_keys SIGNAL manage WAIT_FOR query"; +--echo # Sending: +--send ALTER TABLE t1 ADD UNIQUE (b) -#--echo # Connection con1 -#connection con1; -#SET DEBUG_SYNC= "now WAIT_FOR manage"; -#SELECT * FROM t1; -#SET DEBUG_SYNC= "now SIGNAL query"; +--echo # Connection con1 +connection con1; +SET DEBUG_SYNC= "now WAIT_FOR manage"; +SELECT * FROM t1; +SET DEBUG_SYNC= "now SIGNAL query"; -#--echo # Connection default -#connection default; -#--echo # Reaping: ALTER TABLE t1 ADD UNIQUE (b) -#--reap +--echo # Connection default +connection default; +--echo # Reaping: ALTER TABLE t1 ADD UNIQUE (b) +--reap disconnect con1; disconnect con2; === modified file 'storage/innobase/handler/ha_innodb.cc' --- a/storage/innobase/handler/ha_innodb.cc 2011-03-01 14:42:37 +0000 +++ b/storage/innobase/handler/ha_innodb.cc 2011-03-07 13:30:49 +0000 @@ -2597,6 +2597,7 @@ innobase_alter_table_flags( | HA_INPLACE_ADD_INDEX_NO_WRITE | HA_INPLACE_DROP_INDEX_NO_READ_WRITE | HA_INPLACE_ADD_UNIQUE_INDEX_NO_READ_WRITE + | HA_INPLACE_ADD_UNIQUE_INDEX_NO_WRITE | HA_INPLACE_DROP_UNIQUE_INDEX_NO_READ_WRITE | HA_INPLACE_ADD_PK_INDEX_NO_READ_WRITE); } No bundle (reason: useless for push emails).