2
# Test of MERGE tables with multisession and many waits.
4
# This test takes rather long time so let us run it only in --big-test mode
5
--source include/big_test.inc
6
# We use some debug-only features in this test
7
--source include/have_debug.inc
8
# We use INFORMATION_SCHEMA.PROCESSLIST in this test
9
--source include/not_embedded.inc
12
drop table if exists t1,t2,t3,t4,t5,t6;
16
--echo # Bug#26379 - Combination of FLUSH TABLE and REPAIR TABLE
17
--echo # corrupts a MERGE table
20
# Two FLUSH TABLES within a LOCK TABLES segment could invalidate the lock.
21
# This did *not* require a MERGE table.
23
# To increase reproducibility it was necessary to enter a sleep of 2
24
# seconds at the end of wait_for_tables() after unlock of LOCK_open. In
25
# 5.0 and 5.1 the sleep must be inserted in open_and_lock_tables() after
26
# open_tables() instead. wait_for_tables() is not used in this case. The
27
# problem was that FLUSH TABLES releases LOCK_open while having unlocked
28
# and closed all tables. When this happened while a thread was in the
29
# loop in mysql_lock_tables() right after wait_for_tables()
30
# (open_tables()) and before retrying to lock, the thread got the lock.
31
# And it did not notice that the table needed a refresh after the
32
# [re-]open. So it executed its statement on the table.
34
# The first FLUSH TABLES kicked the INSERT out of thr_multi_lock() and
35
# let it wait in wait_for_tables() (open_table()). The second FLUSH
36
# TABLES must happen while the INSERT was on its way from
37
# wait_for_tables() (open_table()) to the next call of thr_multi_lock().
38
# This needed to be supported by a sleep to make it repeatable.
40
CREATE TABLE t1 (c1 INT) ENGINE= MyISAM;
43
--echo # connection con1
44
connect (con1,localhost,root,,);
45
let $con1_id= `SELECT CONNECTION_ID()`;
46
SET SESSION debug="+d,sleep_open_and_lock_after_open";
47
send INSERT INTO t1 VALUES (1);
48
--echo # connection default
50
--echo # Let INSERT go into thr_multi_lock().
52
#SELECT ID,STATE,INFO FROM INFORMATION_SCHEMA.PROCESSLIST;
53
let $wait_condition= SELECT 1 FROM INFORMATION_SCHEMA.PROCESSLIST
54
WHERE ID = $con1_id AND STATE = 'Locked';
55
--source include/wait_condition.inc
57
--echo # Kick INSERT out of thr_multi_lock().
60
--echo # Let INSERT go through open_tables() where it sleeps.
62
#SELECT ID,STATE,INFO FROM INFORMATION_SCHEMA.PROCESSLIST;
63
let $wait_condition= SELECT 1 FROM INFORMATION_SCHEMA.PROCESSLIST
64
WHERE ID = $con1_id AND STATE = 'Waiting for table';
65
--source include/wait_condition.inc
67
--echo # Unlock and close table and wait for con1 to close too.
70
--echo # This should give no result.
74
--echo # connection con1
77
SET SESSION debug="-d,sleep_open_and_lock_after_open";
79
--echo # connection default