~ubuntu-branches/ubuntu/precise/mysql-5.1/precise

« back to all changes in this revision

Viewing changes to mysql-test/t/innodb_bug42419.test

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Tretkowski
  • Date: 2010-03-17 14:56:02 UTC
  • Revision ID: james.westby@ubuntu.com-20100317145602-x7e30l1b2sb5s6w6
Tags: upstream-5.1.45
ImportĀ upstreamĀ versionĀ 5.1.45

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#
 
2
# Testcase for InnoDB
 
3
# Bug#42419 Server crash with "Pure virtual method called" on two concurrent connections
 
4
#
 
5
 
 
6
--source include/not_embedded.inc
 
7
--source include/have_innodb.inc
 
8
 
 
9
let $innodb_lock_wait_timeout= query_get_value(SHOW VARIABLES LIKE 'innodb_lock_wait_timeout%', Value, 1);
 
10
if (`SELECT $innodb_lock_wait_timeout < 10`)
 
11
{
 
12
   --echo # innodb_lock_wait_timeout must be >= 10 seconds
 
13
   --echo # so that this test can work all time fine on an overloaded testing box
 
14
   SHOW VARIABLES LIKE 'innodb_lock_wait_timeout';
 
15
   exit;
 
16
}
 
17
 
 
18
# Save the initial number of concurrent sessions
 
19
--source include/count_sessions.inc
 
20
 
 
21
# First session
 
22
connection default;
 
23
 
 
24
 
 
25
--enable_warnings
 
26
CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY, b INT) ENGINE = InnoDB;
 
27
 
 
28
INSERT INTO t1 VALUES (1,1),(2,2),(3,3);
 
29
COMMIT;
 
30
SET AUTOCOMMIT = 0;
 
31
 
 
32
CREATE TEMPORARY TABLE t1_tmp ( b INT );
 
33
 
 
34
INSERT INTO t1_tmp (b) SELECT b FROM t1 WHERE a = 3;
 
35
INSERT INTO t1_tmp (b) SELECT b FROM t1 WHERE a = 2;
 
36
 
 
37
# Second session
 
38
connect (user2,localhost,root,,,$MASTER_MYPORT,$MASTER_MYSOCK);
 
39
 
 
40
SET AUTOCOMMIT = 0;
 
41
 
 
42
CREATE TEMPORARY TABLE t2_tmp ( a int, new_a int );
 
43
INSERT INTO t2_tmp VALUES (1,51),(2,52),(3,53);
 
44
 
 
45
UPDATE t1 SET a = (SELECT new_a FROM t2_tmp WHERE t2_tmp.a = t1.a) WHERE a = 1;
 
46
send
 
47
UPDATE t1 SET a = (SELECT new_a FROM t2_tmp WHERE t2_tmp.a = t1.a) WHERE a = 2;
 
48
 
 
49
# The last update will wait for a lock held by the first session
 
50
 
 
51
# First session
 
52
connection default;
 
53
 
 
54
# Poll till the UPDATE of the second session waits for lock
 
55
let $show_statement= SHOW PROCESSLIST;
 
56
let $field= State;
 
57
let $condition= = 'Updating';
 
58
--source include/wait_show_condition.inc
 
59
 
 
60
# If the testing box is overloadeded and innodb_lock_wait_timeout is too small
 
61
# we might get here ER_LOCK_WAIT_TIMEOUT.
 
62
--error ER_LOCK_DEADLOCK
 
63
INSERT INTO t1_tmp (b) SELECT b FROM t1 WHERE a = 1;
 
64
 
 
65
# Second session
 
66
connection user2;
 
67
--echo Reap the server message for connection user2 UPDATE t1 ...
 
68
reap;
 
69
 
 
70
# The server crashed when executing this UPDATE or the succeeding SQL command.
 
71
UPDATE t1 SET a = (SELECT new_a FROM t2_tmp WHERE t2_tmp.a = t1.a) WHERE a = 3;
 
72
 
 
73
connection default;
 
74
disconnect user2;
 
75
DROP TABLE t1;
 
76
 
 
77
# Wait till all disconnects are completed
 
78
--source include/wait_until_count_sessions.inc