diff --git a/mysql-test/suite/innodb/r/innodb-index-online.result b/mysql-test/suite/innodb/r/innodb-index-online.result index 8eebece46b5..ecdf41bca62 100644 --- a/mysql-test/suite/innodb/r/innodb-index-online.result +++ b/mysql-test/suite/innodb/r/innodb-index-online.result @@ -17,7 +17,6 @@ SET DEBUG_SYNC = 'RESET'; SET DEBUG_SYNC = 'write_row_noreplace SIGNAL have_handle WAIT_FOR go_ahead'; INSERT INTO t1 VALUES(1,2,3); connect con1,localhost,root,,; -connection con1; SET DEBUG_SYNC = 'now WAIT_FOR have_handle'; SET lock_wait_timeout = 1; ALTER TABLE t1 ADD UNIQUE INDEX(c2); @@ -524,6 +523,26 @@ CREATE TABLE t2 (c VARCHAR(64)) ENGINE=InnoDB; ALTER TABLE t2 ADD FOREIGN KEY (c) REFERENCES t1 (c); ERROR HY000: Can't create table `test`.`t2` (errno: 150 "Foreign key constraint is incorrectly formed") DROP TABLE t2,t1; +CREATE TABLE t1 (a INT PRIMARY KEY, b INT) ENGINE=InnoDB; +connect con1,localhost,root,,; +SET DEBUG_SYNC = 'row_log_apply_before SIGNAL created WAIT_FOR inserted'; +ALTER TABLE t1 ADD INDEX(b); +connection default; +SET DEBUG_SYNC = 'now WAIT_FOR created'; +BEGIN; +INSERT INTO t1 VALUES(1,1); +ROLLBACK; +SET DEBUG_SYNC = 'now SIGNAL inserted'; +connection con1; +disconnect con1; +connection default; +SELECT * FROM t1; +a b +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +DROP TABLE t1; +SET DEBUG_SYNC = 'RESET'; SET GLOBAL innodb_file_per_table = @global_innodb_file_per_table_orig; SET GLOBAL innodb_monitor_enable = default; SET GLOBAL innodb_monitor_disable = default; diff --git a/mysql-test/suite/innodb/t/innodb-index-online.test b/mysql-test/suite/innodb/t/innodb-index-online.test index 5e21fa896a4..08711aa1a5d 100644 --- a/mysql-test/suite/innodb/t/innodb-index-online.test +++ b/mysql-test/suite/innodb/t/innodb-index-online.test @@ -28,7 +28,6 @@ SET DEBUG_SYNC = 'write_row_noreplace SIGNAL have_handle WAIT_FOR go_ahead'; INSERT INTO t1 VALUES(1,2,3); connect (con1,localhost,root,,); -connection con1; # This should block at the end because of the INSERT in connection default # is holding a metadata lock. @@ -434,7 +433,6 @@ connection con1; SET DEBUG_SYNC = 'now WAIT_FOR c2g_created'; connect (con2,localhost,root,,); -connection con2; # This will conflict with the ALTER in connection default, above. SET lock_wait_timeout = 10; @@ -492,11 +490,35 @@ reap; SET DEBUG_SYNC = 'RESET'; disconnect con1; + CREATE TABLE t2 (c VARCHAR(64)) ENGINE=InnoDB; --error ER_CANT_CREATE_TABLE ALTER TABLE t2 ADD FOREIGN KEY (c) REFERENCES t1 (c); DROP TABLE t2,t1; +CREATE TABLE t1 (a INT PRIMARY KEY, b INT) ENGINE=InnoDB; + +connect (con1,localhost,root,,); +SET DEBUG_SYNC = 'row_log_apply_before SIGNAL created WAIT_FOR inserted'; +send ALTER TABLE t1 ADD INDEX(b); + +connection default; +SET DEBUG_SYNC = 'now WAIT_FOR created'; +BEGIN; +INSERT INTO t1 VALUES(1,1); +ROLLBACK; +SET DEBUG_SYNC = 'now SIGNAL inserted'; + +connection con1; +reap; +disconnect con1; + +connection default; +SELECT * FROM t1; +CHECK TABLE t1; +DROP TABLE t1; +SET DEBUG_SYNC = 'RESET'; + # Check that all connections opened by test cases in this file are really # gone so execution of other tests won't be affected by their presence. --source include/wait_until_count_sessions.inc diff --git a/storage/innobase/row/row0log.cc b/storage/innobase/row/row0log.cc index 64d5dce09fd..03c3b11e9c6 100644 --- a/storage/innobase/row/row0log.cc +++ b/storage/innobase/row/row0log.cc @@ -4063,7 +4063,7 @@ row_log_apply( @param index clustered index */ static void row_log_table_empty(dict_index_t *index) { - ut_ad(index->lock.have_any()); + ut_ad(index->lock.have_s()); row_log_t* log= index->online_log; ulint avail_size; if (byte *b= row_log_table_open(log, 1, &avail_size)) @@ -4091,7 +4091,7 @@ void dict_table_t::clear(que_thr_t *thr) break; case ONLINE_INDEX_CREATION: - index->lock.u_lock(SRW_LOCK_CALL); + index->lock.s_lock(SRW_LOCK_CALL); if (dict_index_get_online_status(index) == ONLINE_INDEX_CREATION) { if (index->is_clust()) @@ -4103,7 +4103,7 @@ void dict_table_t::clear(que_thr_t *thr) row_log_online_op(index, nullptr, 0); } - index->lock.u_unlock(); + index->lock.s_unlock(); } index->clear(thr);