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