~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/innobase/mysql-test/innodb_bug38231.test

  • Committer: Brian Aker
  • Date: 2010-12-08 22:35:56 UTC
  • mfrom: (1819.9.158 update-innobase)
  • Revision ID: brian@tangent.org-20101208223556-37mi4omqg7lkjzf3
Merge in Stewart's changes, 1.3 changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#
 
2
# Bug#38231 Innodb crash in lock_reset_all_on_table() on TRUNCATE + LOCK / UNLOCK
 
3
# http://bugs.mysql.com/38231
 
4
#
 
5
 
 
6
-- source include/have_innodb.inc
 
7
 
 
8
SET storage_engine=InnoDB;
 
9
 
 
10
# we care only that the following SQL commands do not crash the server
 
11
-- disable_query_log
 
12
-- disable_result_log
 
13
 
 
14
DROP TABLE IF EXISTS bug38231;
 
15
CREATE TABLE bug38231 (a INT);
 
16
 
 
17
-- connect (con1,localhost,root,,)
 
18
-- connect (con2,localhost,root,,)
 
19
-- connect (con3,localhost,root,,)
 
20
 
 
21
-- connection con1
 
22
SET autocommit=0;
 
23
LOCK TABLE bug38231 WRITE;
 
24
 
 
25
-- connection con2
 
26
SET autocommit=0;
 
27
-- send
 
28
LOCK TABLE bug38231 WRITE;
 
29
 
 
30
# When con1 does UNLOCK below this will release either con2 or con3 which are
 
31
# both waiting on LOCK. At the end we must first --reap and UNLOCK the
 
32
# connection that has been released, otherwise it will wait forever. We assume
 
33
# that the released connection will be the first one that has gained the LOCK,
 
34
# thus we force the order here - con2 does LOCK first, then con3. In other
 
35
# words we wait for LOCK from con2 above to be exected before doing LOCK in
 
36
# con3.
 
37
-- connection con1
 
38
let $wait_condition =
 
39
  SELECT COUNT(*) = 1 FROM information_schema.processlist
 
40
  WHERE info = 'LOCK TABLE bug38231 WRITE';
 
41
-- source include/wait_condition.inc
 
42
# the above enables query log, re-disable it
 
43
-- disable_query_log
 
44
 
 
45
-- connection con3
 
46
SET autocommit=0;
 
47
-- send
 
48
LOCK TABLE bug38231 WRITE;
 
49
 
 
50
-- connection default
 
51
-- send
 
52
TRUNCATE TABLE bug38231;
 
53
 
 
54
-- connection con1
 
55
# Wait for TRUNCATE and the other two LOCKs to be executed; without this,
 
56
# sometimes UNLOCK executes before them. We assume there are no other
 
57
# sessions executing at the same time with the same SQL commands.
 
58
let $wait_condition =
 
59
  SELECT COUNT(*) = 1 FROM information_schema.processlist
 
60
  WHERE info = 'TRUNCATE TABLE bug38231';
 
61
-- source include/wait_condition.inc
 
62
let $wait_condition =
 
63
  SELECT COUNT(*) = 2 FROM information_schema.processlist
 
64
  WHERE info = 'LOCK TABLE bug38231 WRITE';
 
65
-- source include/wait_condition.inc
 
66
# the above enables query log, re-disable it
 
67
-- disable_query_log
 
68
 
 
69
# this crashes the server if the bug is present
 
70
UNLOCK TABLES;
 
71
 
 
72
# clean up
 
73
 
 
74
-- connection con2
 
75
-- reap
 
76
UNLOCK TABLES;
 
77
 
 
78
-- connection con3
 
79
-- reap
 
80
UNLOCK TABLES;
 
81
 
 
82
-- connection default
 
83
-- reap
 
84
 
 
85
-- disconnect con1
 
86
-- disconnect con2
 
87
-- disconnect con3
 
88
 
 
89
# test that TRUNCATE works with with row-level locks
 
90
 
 
91
-- enable_query_log
 
92
-- enable_result_log
 
93
 
 
94
INSERT INTO bug38231 VALUES (1), (10), (300);
 
95
 
 
96
-- connect (con4,localhost,root,,)
 
97
 
 
98
-- connection con4
 
99
SET autocommit=0;
 
100
SELECT * FROM bug38231 FOR UPDATE;
 
101
 
 
102
-- connection default
 
103
TRUNCATE TABLE bug38231;
 
104
 
 
105
-- connection con4
 
106
COMMIT;
 
107
 
 
108
-- connection default
 
109
 
 
110
-- disconnect con4
 
111
 
 
112
DROP TABLE bug38231;