Debian Codegraph @

mysql-test/suite/innodb/t/innodb_bug42419.test

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