2009-12-09 09:32:29 +01:00
|
|
|
#
|
|
|
|
# Bug 42074 concurrent optimize table and
|
|
|
|
# alter table = Assertion failed: thd->is_error()
|
|
|
|
#
|
|
|
|
DROP TABLE IF EXISTS t1;
|
|
|
|
# Create InnoDB table
|
|
|
|
CREATE TABLE t1 (id INT) engine=innodb;
|
|
|
|
# Connection 1
|
|
|
|
# Start optimizing table
|
|
|
|
SET DEBUG_SYNC='ha_admin_try_alter SIGNAL optimize_started WAIT_FOR table_altered';
|
|
|
|
OPTIMIZE TABLE t1;
|
|
|
|
# Connection 2
|
|
|
|
# Change table to engine=memory
|
|
|
|
SET DEBUG_SYNC='now WAIT_FOR optimize_started';
|
|
|
|
ALTER TABLE t1 engine=memory;
|
|
|
|
SET DEBUG_SYNC='now SIGNAL table_altered';
|
|
|
|
# Connection 1
|
|
|
|
# Complete optimization
|
|
|
|
Table Op Msg_type Msg_text
|
|
|
|
test.t1 optimize note Table does not support optimize, doing recreate + analyze instead
|
|
|
|
test.t1 optimize error Got error -1 from storage engine
|
|
|
|
test.t1 optimize status Operation failed
|
|
|
|
Warnings:
|
|
|
|
Error 1030 Got error -1 from storage engine
|
|
|
|
DROP TABLE t1;
|
|
|
|
SET DEBUG_SYNC='RESET';
|
2010-04-15 18:53:57 +02:00
|
|
|
#
|
|
|
|
# Bug#47459 Assertion in Diagnostics_area::set_eof_status on
|
|
|
|
# OPTIMIZE TABLE
|
|
|
|
#
|
|
|
|
DROP TABLE IF EXISTS t1;
|
|
|
|
CREATE TABLE t1(a INT) ENGINE= InnoDB;
|
|
|
|
# Connection con1
|
|
|
|
SET DEBUG_SYNC= "ha_admin_open_ltable SIGNAL opening WAIT_FOR dropped";
|
|
|
|
# Sending:
|
|
|
|
OPTIMIZE TABLE t1;
|
|
|
|
# Connection default
|
|
|
|
SET DEBUG_SYNC= "now WAIT_FOR opening";
|
|
|
|
DROP TABLE t1;
|
|
|
|
SET DEBUG_SYNC= "now SIGNAL dropped";
|
|
|
|
# Connection con1
|
|
|
|
# Reaping: OPTIMIZE TABLE t1
|
|
|
|
Table Op Msg_type Msg_text
|
|
|
|
test.t1 optimize note Table does not support optimize, doing recreate + analyze instead
|
|
|
|
test.t1 optimize error Table 'test.t1' doesn't exist
|
|
|
|
test.t1 optimize status Operation failed
|
|
|
|
Warnings:
|
|
|
|
Error 1146 Table 'test.t1' doesn't exist
|
|
|
|
# Connection default
|
|
|
|
SET DEBUG_SYNC= "RESET";
|
2010-06-25 09:07:18 +02:00
|
|
|
#
|
|
|
|
# Bug#53757 assert in mysql_truncate_by_delete
|
|
|
|
#
|
|
|
|
DROP TABLE IF EXISTS t1, t2;
|
|
|
|
CREATE TABLE t1(a INT) Engine=InnoDB;
|
|
|
|
CREATE TABLE t2(id INT);
|
|
|
|
INSERT INTO t1 VALUES (1), (2);
|
|
|
|
INSERT INTO t2 VALUES(connection_id());
|
|
|
|
SET DEBUG_SYNC= "open_and_process_table SIGNAL opening WAIT_FOR killed";
|
|
|
|
# Sending: (not reaped since connection is killed later)
|
|
|
|
TRUNCATE t1;
|
|
|
|
SET DEBUG_SYNC= "now WAIT_FOR opening";
|
|
|
|
SELECT ((@id := id) - id) FROM t2;
|
|
|
|
((@id := id) - id)
|
|
|
|
0
|
|
|
|
KILL @id;
|
|
|
|
SET DEBUG_SYNC= "now SIGNAL killed";
|
|
|
|
DROP TABLE t1, t2;
|
2011-01-10 14:12:23 +01:00
|
|
|
SET DEBUG_SYNC= "RESET";
|
|
|
|
#
|
|
|
|
# Bug#58933 Assertion `thd- >is_error()' fails on shutdown with ongoing
|
|
|
|
# OPTIMIZE TABLE
|
|
|
|
#
|
|
|
|
DROP TABLE IF EXISTS t1;
|
|
|
|
CREATE TABLE t1 (a INT) ENGINE=InnoDB;
|
|
|
|
INSERT INTO t1 VALUES (1), (2);
|
|
|
|
# Connection con1
|
|
|
|
SET DEBUG_SYNC= 'ha_admin_open_ltable SIGNAL waiting WAIT_FOR killed';
|
|
|
|
# Sending:
|
|
|
|
OPTIMIZE TABLE t1;
|
|
|
|
# Connection default
|
|
|
|
SET DEBUG_SYNC= 'now WAIT_FOR waiting';
|
|
|
|
KILL QUERY ID;
|
|
|
|
SET DEBUG_SYNC= 'now SIGNAL killed';
|
|
|
|
# Connection con1
|
|
|
|
# Reaping: OPTIMIZE TABLE t1
|
|
|
|
Table Op Msg_type Msg_text
|
|
|
|
test.t1 optimize note Table does not support optimize, doing recreate + analyze instead
|
|
|
|
test.t1 optimize status Operation failed
|
|
|
|
# Connection default
|
|
|
|
DROP TABLE t1;
|
|
|
|
SET DEBUG_SYNC= 'RESET';
|
Bug #42230 during add index, cannot do queries on storage engines
that implement add_index
The problem was that ALTER TABLE blocked reads on an InnoDB table
while adding a secondary index, even if this was not needed. It is
only needed for the final step where the .frm file is updated.
The reason queries were blocked, was that ALTER TABLE upgraded the
metadata lock from MDL_SHARED_NO_WRITE (which blocks writes) to
MDL_EXCLUSIVE (which blocks all accesses) before index creation.
The way the server handles index creation, is that storage engines
publish their capabilities to the server and the server determines
which of the following three ways this can be handled: 1) build a
new version of the table; 2) change the existing table but with
exclusive metadata lock; 3) change the existing table but without
metadata lock upgrade.
For InnoDB and secondary index creation, option 3) should have been
selected. However this failed for two reasons. First, InnoDB did
not publish this capability properly.
Second, the ALTER TABLE code failed to made proper use of the
information supplied by the storage engine. A variable
need_lock_for_indexes was set accordingly, but was not later used.
This patch fixes this problem by only doing metadata lock upgrade
before index creation/deletion if this variable has been set.
This patch also changes some of the related terminology used
in the code. Specifically the use of "fast" and "online" with
respect to ALTER TABLE. "Fast" was used to indicate that an
ALTER TABLE operation could be done without involving a
temporary table. "Fast" has been renamed "in-place" to more
accurately describe the behavior.
"Online" meant that the operation could be done without taking
a table lock. However, in the current implementation writes
are always prohibited during ALTER TABLE and an exclusive
metadata lock is held while updating the .frm, so ALTER TABLE
is not completely online. This patch replaces "online" with
"in-place", with additional comments indicating if concurrent
reads are allowed during index creation/deletion or not.
An important part of this update of terminology is renaming
of the handler flags used by handlers to indicate if index
creation/deletion can be done in-place and if concurrent reads
are allowed. For example, the HA_ONLINE_ADD_INDEX_NO_WRITES
flag has been renamed to HA_INPLACE_ADD_INDEX_NO_READ_WRITE,
while HA_ONLINE_ADD_INDEX is now HA_INPLACE_ADD_INDEX_NO_WRITE.
Note that this is a rename to clarify current behavior, the
flag values have not changed and no flags have been removed or
added.
Test case added to innodb_mysql_sync.test.
2011-01-26 14:23:29 +01:00
|
|
|
#
|
|
|
|
# Bug#42230 during add index, cannot do queries on storage engines
|
|
|
|
# that implement add_index
|
|
|
|
#
|
2011-06-01 10:06:55 +02:00
|
|
|
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= "alter_table_manage_keys SIGNAL manage WAIT_FOR query";
|
|
|
|
# Sending:
|
|
|
|
ALTER TABLE t1 ADD UNIQUE (b);
|
|
|
|
# Connection con1
|
|
|
|
SET DEBUG_SYNC= "now WAIT_FOR manage";
|
|
|
|
SELECT * FROM t1;
|
|
|
|
a b
|
|
|
|
SET DEBUG_SYNC= "now SIGNAL query";
|
|
|
|
# Connection default
|
|
|
|
# Reaping: ALTER TABLE t1 ADD UNIQUE (b)
|
|
|
|
SET DEBUG_SYNC= "RESET";
|
|
|
|
DROP TABLE t1;
|
2011-06-01 13:52:20 +02:00
|
|
|
#
|
|
|
|
# Bug#11853126 RE-ENABLE CONCURRENT READS WHILE CREATING SECONDARY INDEX
|
|
|
|
# IN INNODB
|
|
|
|
#
|
|
|
|
DROP TABLE IF EXISTS t1;
|
|
|
|
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;
|