mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Bug#11853126 RE-ENABLE CONCURRENT READS WHILE CREATING
SECONDARY INDEX IN INNODB The patches for Bug#11751388 and Bug#11784056 enabled concurrent reads while creating secondary indexes in InnoDB. However, they introduced a regression. This regression occured if ALTER TABLE failed after the index had been added, for example during the lock upgrade needed to update .FRM. If this happened, InnoDB and the server got out of sync with regards to which indexes actually existed. Therefore the patch for Bug#11815600 again disabled concurrent reads. This patch re-enables concurrent reads. The original regression is fixed by splitting the ADD INDEX operation into two parts. First the new index is created but not made active. This is done while concurrent reads are allowed. The second part of the operation makes the index active (or reverts the change). This is done after lock upgrade, which prevents the original regression. In order to implement this change, the patch changes the storage API for in-place index creation. handler::add_index() is split into two functions, handler_add_index() and handler::final_add_index(). The former for creating indexes without making them visible and the latter for commiting (i.e. making visible) new indexes or reverting the changes. Large parts of this patch were written by Marko Mäkelä. Test case added to innodb_mysql_lock.test.
This commit is contained in:
@ -153,6 +153,7 @@ DROP VIEW v1;
|
||||
# KEY NO 0 FOR TABLE IN ERROR LOG
|
||||
#
|
||||
DROP TABLE IF EXISTS t1;
|
||||
# Test 1: Secondary index
|
||||
# Connection default
|
||||
CREATE TABLE t1 (id INT PRIMARY KEY, value INT) ENGINE = InnoDB;
|
||||
INSERT INTO t1 VALUES (1, 12345);
|
||||
@ -164,9 +165,28 @@ id value
|
||||
SET lock_wait_timeout=1;
|
||||
ALTER TABLE t1 ADD INDEX idx(value);
|
||||
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
|
||||
ALTER TABLE t1 ADD INDEX idx(value);
|
||||
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
|
||||
# Connection default
|
||||
SELECT * FROM t1;
|
||||
id value
|
||||
1 12345
|
||||
COMMIT;
|
||||
DROP TABLE t1;
|
||||
# Test 2: Primary index
|
||||
CREATE TABLE t1(a INT NOT NULL, b INT NOT NULL) engine=innodb;
|
||||
INSERT INTO t1 VALUES (1, 12345), (2, 23456);
|
||||
# Connection con1
|
||||
SET SESSION debug= "+d,alter_table_rollback_new_index";
|
||||
ALTER TABLE t1 ADD PRIMARY KEY(a);
|
||||
ERROR HY000: Unknown error
|
||||
SELECT * FROM t1;
|
||||
a b
|
||||
1 12345
|
||||
2 23456
|
||||
# Connection default
|
||||
SELECT * FROM t1;
|
||||
a b
|
||||
1 12345
|
||||
2 23456
|
||||
DROP TABLE t1;
|
||||
|
Reference in New Issue
Block a user