~jlukas79/+junk/mysql-server

« back to all changes in this revision

Viewing changes to mysql-test/t/merge-big.test

manual merge 6.0-main --> 6.0-bka-review

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#
2
 
# Test of MERGE tables with multisession and many waits.
3
 
#
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
10
 
 
11
 
--disable_warnings
12
 
drop table if exists t1,t2,t3,t4,t5,t6;
13
 
--enable_warnings
14
 
 
15
 
--echo #
16
 
--echo # Bug#26379 - Combination of FLUSH TABLE and REPAIR TABLE
17
 
--echo #             corrupts a MERGE table
18
 
--echo # Problem #3
19
 
--echo #
20
 
# Two FLUSH TABLES within a LOCK TABLES segment could invalidate the lock.
21
 
# This did *not* require a MERGE table.
22
 
#
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.
33
 
#
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.
39
 
#
40
 
CREATE TABLE t1 (c1 INT) ENGINE= MyISAM;
41
 
LOCK TABLE t1 WRITE;
42
 
#SELECT NOW();
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
49
 
connection default;
50
 
--echo # Let INSERT go into thr_multi_lock().
51
 
#--sleep 8
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
56
 
#SELECT NOW();
57
 
--echo # Kick INSERT out of thr_multi_lock().
58
 
FLUSH TABLES;
59
 
#SELECT NOW();
60
 
--echo # Let INSERT go through open_tables() where it sleeps.
61
 
#--sleep 8
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
66
 
#SELECT NOW();
67
 
--echo # Unlock and close table and wait for con1 to close too.
68
 
FLUSH TABLES;
69
 
#SELECT NOW();
70
 
--echo # This should give no result.
71
 
SELECT * FROM t1;
72
 
#SELECT NOW();
73
 
UNLOCK TABLES;
74
 
    --echo # connection con1
75
 
    connection con1;
76
 
    reap;
77
 
    SET SESSION debug="-d,sleep_open_and_lock_after_open";
78
 
    disconnect con1;
79
 
--echo # connection default
80
 
connection default;
81
 
DROP TABLE t1;
82