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:
@ -148,3 +148,25 @@ COMMIT;
|
|||||||
# Connection default
|
# Connection default
|
||||||
DROP TABLE t1, t2;
|
DROP TABLE t1, t2;
|
||||||
DROP VIEW v1;
|
DROP VIEW v1;
|
||||||
|
#
|
||||||
|
# Bug#11815600 [ERROR] INNODB COULD NOT FIND INDEX PRIMARY
|
||||||
|
# KEY NO 0 FOR TABLE IN ERROR LOG
|
||||||
|
#
|
||||||
|
DROP TABLE IF EXISTS t1;
|
||||||
|
# Connection default
|
||||||
|
CREATE TABLE t1 (id INT PRIMARY KEY, value INT) ENGINE = InnoDB;
|
||||||
|
INSERT INTO t1 VALUES (1, 12345);
|
||||||
|
START TRANSACTION;
|
||||||
|
SELECT * FROM t1;
|
||||||
|
id value
|
||||||
|
1 12345
|
||||||
|
# Connection con1
|
||||||
|
SET lock_wait_timeout=1;
|
||||||
|
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;
|
||||||
|
@ -94,64 +94,6 @@ SET DEBUG_SYNC= 'RESET';
|
|||||||
# Bug#42230 during add index, cannot do queries on storage engines
|
# Bug#42230 during add index, cannot do queries on storage engines
|
||||||
# that implement add_index
|
# that implement add_index
|
||||||
#
|
#
|
||||||
DROP DATABASE IF EXISTS db1;
|
#
|
||||||
DROP TABLE IF EXISTS t1;
|
# DISABLED due to Bug#11815600
|
||||||
# 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;
|
|
||||||
|
@ -279,6 +279,38 @@ disconnect con2;
|
|||||||
disconnect con3;
|
disconnect con3;
|
||||||
|
|
||||||
|
|
||||||
|
--echo #
|
||||||
|
--echo # Bug#11815600 [ERROR] INNODB COULD NOT FIND INDEX PRIMARY
|
||||||
|
--echo # KEY NO 0 FOR TABLE IN ERROR LOG
|
||||||
|
--echo #
|
||||||
|
|
||||||
|
--disable_warnings
|
||||||
|
DROP TABLE IF EXISTS t1;
|
||||||
|
--enable_warnings
|
||||||
|
|
||||||
|
--connect (con1,localhost,root)
|
||||||
|
|
||||||
|
--echo # Connection default
|
||||||
|
connection default;
|
||||||
|
CREATE TABLE t1 (id INT PRIMARY KEY, value INT) ENGINE = InnoDB;
|
||||||
|
INSERT INTO t1 VALUES (1, 12345);
|
||||||
|
START TRANSACTION;
|
||||||
|
SELECT * FROM t1;
|
||||||
|
|
||||||
|
--echo # Connection con1
|
||||||
|
--connection con1
|
||||||
|
SET lock_wait_timeout=1;
|
||||||
|
--error ER_LOCK_WAIT_TIMEOUT
|
||||||
|
ALTER TABLE t1 ADD INDEX idx(value);
|
||||||
|
|
||||||
|
--echo # Connection default
|
||||||
|
--connection default
|
||||||
|
SELECT * FROM t1;
|
||||||
|
COMMIT;
|
||||||
|
DROP TABLE t1;
|
||||||
|
disconnect con1;
|
||||||
|
|
||||||
|
|
||||||
# Check that all connections opened by test cases in this file are really
|
# 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.
|
# gone so execution of other tests won't be affected by their presence.
|
||||||
--source include/wait_until_count_sessions.inc
|
--source include/wait_until_count_sessions.inc
|
||||||
|
@ -152,132 +152,133 @@ disconnect con1;
|
|||||||
--echo # that implement add_index
|
--echo # that implement add_index
|
||||||
--echo #
|
--echo #
|
||||||
|
|
||||||
--disable_warnings
|
--echo #
|
||||||
DROP DATABASE IF EXISTS db1;
|
--echo # DISABLED due to Bug#11815600
|
||||||
DROP TABLE IF EXISTS t1;
|
--echo #
|
||||||
--enable_warnings
|
|
||||||
|
|
||||||
connect(con1,localhost,root);
|
#--disable_warnings
|
||||||
connect(con2,localhost,root);
|
#DROP DATABASE IF EXISTS db1;
|
||||||
|
#DROP TABLE IF EXISTS t1;
|
||||||
--echo # Test 1: Secondary index, should not block reads (original test case).
|
#--enable_warnings
|
||||||
|
#
|
||||||
--echo # Connection default
|
#connect(con1,localhost,root);
|
||||||
connection default;
|
#connect(con2,localhost,root);
|
||||||
CREATE DATABASE db1;
|
#
|
||||||
CREATE TABLE db1.t1(id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, value INT) engine=innodb;
|
#--echo # Test 1: Secondary index, should not block reads (original test case).
|
||||||
INSERT INTO db1.t1(value) VALUES (1), (2);
|
#
|
||||||
SET DEBUG_SYNC= "alter_table_manage_keys SIGNAL manage WAIT_FOR query";
|
#--echo # Connection default
|
||||||
--echo # Sending:
|
#connection default;
|
||||||
--send ALTER TABLE db1.t1 ADD INDEX(value)
|
#CREATE DATABASE db1;
|
||||||
|
#CREATE TABLE db1.t1(id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, value INT) engine=innodb;
|
||||||
--echo # Connection con1
|
#INSERT INTO db1.t1(value) VALUES (1), (2);
|
||||||
connection con1;
|
#SET DEBUG_SYNC= "alter_table_manage_keys SIGNAL manage WAIT_FOR query";
|
||||||
SET DEBUG_SYNC= "now WAIT_FOR manage";
|
#--echo # Sending:
|
||||||
# Neither of these two statements should be blocked
|
#--send ALTER TABLE db1.t1 ADD INDEX(value)
|
||||||
USE db1;
|
#
|
||||||
SELECT * FROM t1;
|
#--echo # Connection con1
|
||||||
SET DEBUG_SYNC= "now SIGNAL query";
|
#connection con1;
|
||||||
|
#SET DEBUG_SYNC= "now WAIT_FOR manage";
|
||||||
--echo # Connection default
|
# # Neither of these two statements should be blocked
|
||||||
connection default;
|
#USE db1;
|
||||||
--echo # Reaping: ALTER TABLE db1.t1 ADD INDEX(value)
|
#SELECT * FROM t1;
|
||||||
--reap
|
#SET DEBUG_SYNC= "now SIGNAL query";
|
||||||
DROP DATABASE db1;
|
#
|
||||||
|
#--echo # Connection default
|
||||||
--echo # Test 2: Primary index (implicit), should block reads.
|
#connection default;
|
||||||
|
#--echo # Reaping: ALTER TABLE db1.t1 ADD INDEX(value)
|
||||||
CREATE TABLE t1(a INT NOT NULL, b INT NOT NULL) engine=innodb;
|
#--reap
|
||||||
SET DEBUG_SYNC= "alter_table_manage_keys SIGNAL manage WAIT_FOR query";
|
#DROP DATABASE db1;
|
||||||
--echo # Sending:
|
#
|
||||||
--send ALTER TABLE t1 ADD UNIQUE INDEX(a)
|
#--echo # Test 2: Primary index (implicit), should block reads.
|
||||||
|
#
|
||||||
--echo # Connection con1
|
#CREATE TABLE t1(a INT NOT NULL, b INT NOT NULL) engine=innodb;
|
||||||
connection con1;
|
#SET DEBUG_SYNC= "alter_table_manage_keys SIGNAL manage WAIT_FOR query";
|
||||||
SET DEBUG_SYNC= "now WAIT_FOR manage";
|
#--echo # Sending:
|
||||||
USE test;
|
#--send ALTER TABLE t1 ADD UNIQUE INDEX(a)
|
||||||
--echo # Sending:
|
#
|
||||||
--send SELECT * FROM t1
|
#--echo # Connection con1
|
||||||
|
#connection con1;
|
||||||
--echo # Connection con2
|
#SET DEBUG_SYNC= "now WAIT_FOR manage";
|
||||||
connection con2;
|
#USE test;
|
||||||
--echo # Waiting for SELECT to be blocked by the metadata lock on t1
|
#--echo # Sending:
|
||||||
let $wait_condition= SELECT COUNT(*)= 1 FROM information_schema.processlist
|
#--send SELECT * FROM t1
|
||||||
WHERE state= 'Waiting for table metadata lock'
|
#
|
||||||
AND info='SELECT * FROM t1';
|
#--echo # Connection con2
|
||||||
--source include/wait_condition.inc
|
#connection con2;
|
||||||
SET DEBUG_SYNC= "now SIGNAL query";
|
#--echo # Waiting for SELECT to be blocked by the metadata lock on t1
|
||||||
|
#let $wait_condition= SELECT COUNT(*)= 1 FROM information_schema.processlist
|
||||||
--echo # Connection default
|
# WHERE state= 'Waiting for table metadata lock'
|
||||||
connection default;
|
# AND info='SELECT * FROM t1';
|
||||||
--echo # Reaping: ALTER TABLE t1 ADD UNIQUE INDEX(a)
|
#--source include/wait_condition.inc
|
||||||
--reap
|
#SET DEBUG_SYNC= "now SIGNAL query";
|
||||||
|
#
|
||||||
--echo # Connection con1
|
#--echo # Connection default
|
||||||
connection con1;
|
#connection default;
|
||||||
--echo # Reaping: SELECT * FROM t1
|
#--echo # Reaping: ALTER TABLE t1 ADD UNIQUE INDEX(a)
|
||||||
--reap
|
#--reap
|
||||||
|
#
|
||||||
--echo # Test 3: Primary index (explicit), should block reads.
|
#--echo # Connection con1
|
||||||
|
#connection con1;
|
||||||
--echo # Connection default
|
#--echo # Reaping: SELECT * FROM t1
|
||||||
connection default;
|
#--reap
|
||||||
ALTER TABLE t1 DROP INDEX a;
|
#
|
||||||
SET DEBUG_SYNC= "alter_table_manage_keys SIGNAL manage WAIT_FOR query";
|
#--echo # Test 3: Primary index (explicit), should block reads.
|
||||||
--echo # Sending:
|
#
|
||||||
--send ALTER TABLE t1 ADD PRIMARY KEY (a)
|
#--echo # Connection default
|
||||||
|
#connection default;
|
||||||
--echo # Connection con1
|
#ALTER TABLE t1 DROP INDEX a;
|
||||||
connection con1;
|
#SET DEBUG_SYNC= "alter_table_manage_keys SIGNAL manage WAIT_FOR query";
|
||||||
SET DEBUG_SYNC= "now WAIT_FOR manage";
|
#--echo # Sending:
|
||||||
--echo # Sending:
|
#--send ALTER TABLE t1 ADD PRIMARY KEY (a)
|
||||||
--send SELECT * FROM t1
|
#
|
||||||
|
#--echo # Connection con1
|
||||||
--echo # Connection con2
|
#connection con1;
|
||||||
connection con2;
|
#SET DEBUG_SYNC= "now WAIT_FOR manage";
|
||||||
--echo # Waiting for SELECT to be blocked by the metadata lock on t1
|
#--echo # Sending:
|
||||||
let $wait_condition= SELECT COUNT(*)= 1 FROM information_schema.processlist
|
#--send SELECT * FROM t1
|
||||||
WHERE state= 'Waiting for table metadata lock'
|
#
|
||||||
AND info='SELECT * FROM t1';
|
#--echo # Connection con2
|
||||||
--source include/wait_condition.inc
|
#connection con2;
|
||||||
SET DEBUG_SYNC= "now SIGNAL query";
|
#--echo # Waiting for SELECT to be blocked by the metadata lock on t1
|
||||||
|
#let $wait_condition= SELECT COUNT(*)= 1 FROM information_schema.processlist
|
||||||
--echo # Connection default
|
# WHERE state= 'Waiting for table metadata lock'
|
||||||
connection default;
|
# AND info='SELECT * FROM t1';
|
||||||
--echo # Reaping: ALTER TABLE t1 ADD PRIMARY KEY (a)
|
#--source include/wait_condition.inc
|
||||||
--reap
|
#SET DEBUG_SYNC= "now SIGNAL query";
|
||||||
|
#
|
||||||
--echo # Connection con1
|
#--echo # Connection default
|
||||||
connection con1;
|
#connection default;
|
||||||
--echo # Reaping: SELECT * FROM t1
|
#--echo # Reaping: ALTER TABLE t1 ADD PRIMARY KEY (a)
|
||||||
--reap
|
#--reap
|
||||||
|
#
|
||||||
--echo # Test 4: Secondary unique index, should not block reads.
|
#--echo # Connection con1
|
||||||
# This requires HA_INPLACE_ADD_UNIQUE_INDEX_NO_WRITE to be supported
|
#connection con1;
|
||||||
# by InnoDB. Adding this flag currently introduces a regression so
|
#--echo # Reaping: SELECT * FROM t1
|
||||||
# this test is disabled until the regression has been fixed.
|
#--reap
|
||||||
|
#
|
||||||
--echo # Connection default
|
#--echo # Test 4: Secondary unique index, should not block reads.
|
||||||
connection default;
|
#
|
||||||
|
#--echo # Connection default
|
||||||
|
#connection default;
|
||||||
#SET DEBUG_SYNC= "alter_table_manage_keys SIGNAL manage WAIT_FOR query";
|
#SET DEBUG_SYNC= "alter_table_manage_keys SIGNAL manage WAIT_FOR query";
|
||||||
#--echo # Sending:
|
#--echo # Sending:
|
||||||
#--send ALTER TABLE t1 ADD UNIQUE (b)
|
#--send ALTER TABLE t1 ADD UNIQUE (b)
|
||||||
|
#
|
||||||
#--echo # Connection con1
|
#--echo # Connection con1
|
||||||
#connection con1;
|
#connection con1;
|
||||||
#SET DEBUG_SYNC= "now WAIT_FOR manage";
|
#SET DEBUG_SYNC= "now WAIT_FOR manage";
|
||||||
#SELECT * FROM t1;
|
#SELECT * FROM t1;
|
||||||
#SET DEBUG_SYNC= "now SIGNAL query";
|
#SET DEBUG_SYNC= "now SIGNAL query";
|
||||||
|
#
|
||||||
#--echo # Connection default
|
#--echo # Connection default
|
||||||
#connection default;
|
#connection default;
|
||||||
#--echo # Reaping: ALTER TABLE t1 ADD UNIQUE (b)
|
#--echo # Reaping: ALTER TABLE t1 ADD UNIQUE (b)
|
||||||
#--reap
|
#--reap
|
||||||
|
#
|
||||||
disconnect con1;
|
#disconnect con1;
|
||||||
disconnect con2;
|
#disconnect con2;
|
||||||
SET DEBUG_SYNC= "RESET";
|
#SET DEBUG_SYNC= "RESET";
|
||||||
DROP TABLE t1;
|
#DROP TABLE t1;
|
||||||
|
|
||||||
|
|
||||||
# Check that all connections opened by test cases in this file are really
|
# Check that all connections opened by test cases in this file are really
|
||||||
|
@ -2594,7 +2594,6 @@ innobase_alter_table_flags(
|
|||||||
uint flags)
|
uint flags)
|
||||||
{
|
{
|
||||||
return(HA_INPLACE_ADD_INDEX_NO_READ_WRITE
|
return(HA_INPLACE_ADD_INDEX_NO_READ_WRITE
|
||||||
| HA_INPLACE_ADD_INDEX_NO_WRITE
|
|
||||||
| HA_INPLACE_DROP_INDEX_NO_READ_WRITE
|
| HA_INPLACE_DROP_INDEX_NO_READ_WRITE
|
||||||
| HA_INPLACE_ADD_UNIQUE_INDEX_NO_READ_WRITE
|
| HA_INPLACE_ADD_UNIQUE_INDEX_NO_READ_WRITE
|
||||||
| HA_INPLACE_DROP_UNIQUE_INDEX_NO_READ_WRITE
|
| HA_INPLACE_DROP_UNIQUE_INDEX_NO_READ_WRITE
|
||||||
|
Reference in New Issue
Block a user