Commit 3f871b33 authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-515 fixup: Cover dict_table_t::clear() during ADD INDEX

parent 3cef4f8f
......@@ -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;
......@@ -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
......
......@@ -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);
......
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