mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Bug#11815600 [ERROR] INNODB COULD NOT FIND INDEX PRIMARY
KEY NO 0 FOR TABLE IN ERROR LOG With the changes made by the patches for Bug#11751388 and Bug#11784056, concurrent reads are allowed while secondary indexes are created in InnoDB. This means that the metadata lock on the affected table is not upgraded to exclusive until the .FRM is updated at the end of ALTER TABLE processing. The problem was that if this lock upgrade failed for some reason (e.g. timeout), the index information in the server and inside InnoDB would be out of sync. This would happen since the add index operation already was committed inside InnoDB but the table metadata inside the server had not been updated yet. This patch fixes the problem by (for now) reverting the effects of the patches for Bug#11751388 and Bug#11784056. Concurrent reads will now again be blocked during creation of secondary indexes in InnoDB. Test case added to innodb_mysql_lock.test.
This commit is contained in:
@ -94,64 +94,6 @@ SET DEBUG_SYNC= 'RESET';
|
||||
# Bug#42230 during add index, cannot do queries on storage engines
|
||||
# that implement add_index
|
||||
#
|
||||
DROP DATABASE IF EXISTS db1;
|
||||
DROP TABLE IF EXISTS t1;
|
||||
# Test 1: Secondary index, should not block reads (original test case).
|
||||
# Connection default
|
||||
CREATE DATABASE db1;
|
||||
CREATE TABLE db1.t1(id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, value INT) engine=innodb;
|
||||
INSERT INTO db1.t1(value) VALUES (1), (2);
|
||||
SET DEBUG_SYNC= "alter_table_manage_keys SIGNAL manage WAIT_FOR query";
|
||||
# Sending:
|
||||
ALTER TABLE db1.t1 ADD INDEX(value);
|
||||
# Connection con1
|
||||
SET DEBUG_SYNC= "now WAIT_FOR manage";
|
||||
USE db1;
|
||||
SELECT * FROM t1;
|
||||
id value
|
||||
1 1
|
||||
2 2
|
||||
SET DEBUG_SYNC= "now SIGNAL query";
|
||||
# Connection default
|
||||
# Reaping: ALTER TABLE db1.t1 ADD INDEX(value)
|
||||
DROP DATABASE db1;
|
||||
# Test 2: Primary index (implicit), should block reads.
|
||||
CREATE TABLE t1(a INT NOT NULL, b INT NOT NULL) engine=innodb;
|
||||
SET DEBUG_SYNC= "alter_table_manage_keys SIGNAL manage WAIT_FOR query";
|
||||
# Sending:
|
||||
ALTER TABLE t1 ADD UNIQUE INDEX(a);
|
||||
# Connection con1
|
||||
SET DEBUG_SYNC= "now WAIT_FOR manage";
|
||||
USE test;
|
||||
# Sending:
|
||||
SELECT * FROM t1;
|
||||
# Connection con2
|
||||
# Waiting for SELECT to be blocked by the metadata lock on t1
|
||||
SET DEBUG_SYNC= "now SIGNAL query";
|
||||
# Connection default
|
||||
# Reaping: ALTER TABLE t1 ADD UNIQUE INDEX(a)
|
||||
# Connection con1
|
||||
# Reaping: SELECT * FROM t1
|
||||
a b
|
||||
# Test 3: Primary index (explicit), should block reads.
|
||||
# Connection default
|
||||
ALTER TABLE t1 DROP INDEX a;
|
||||
SET DEBUG_SYNC= "alter_table_manage_keys SIGNAL manage WAIT_FOR query";
|
||||
# Sending:
|
||||
ALTER TABLE t1 ADD PRIMARY KEY (a);
|
||||
# Connection con1
|
||||
SET DEBUG_SYNC= "now WAIT_FOR manage";
|
||||
# Sending:
|
||||
SELECT * FROM t1;
|
||||
# Connection con2
|
||||
# Waiting for SELECT to be blocked by the metadata lock on t1
|
||||
SET DEBUG_SYNC= "now SIGNAL query";
|
||||
# Connection default
|
||||
# Reaping: ALTER TABLE t1 ADD PRIMARY KEY (a)
|
||||
# Connection con1
|
||||
# Reaping: SELECT * FROM t1
|
||||
a b
|
||||
# Test 4: Secondary unique index, should not block reads.
|
||||
# Connection default
|
||||
SET DEBUG_SYNC= "RESET";
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# DISABLED due to Bug#11815600
|
||||
#
|
||||
|
Reference in New Issue
Block a user