| 1 |
# |
| 2 |
# Ensure that the number of locks (SELECT FOR UPDATE for example) is |
| 3 |
# added to the number of altered rows when choosing the smallest |
| 4 |
# transaction to kill as a victim when a deadlock is detected. |
| 5 |
# Also transactions what had edited non-transactional tables should |
| 6 |
# be heavier than ones that had not. |
| 7 |
# |
| 8 |
|
| 9 |
|
| 10 |
SET default_storage_engine=InnoDB; |
| 11 |
|
| 12 |
# we do not really care about what gets printed, we are only |
| 13 |
# interested in getting the deadlock resolved according to our |
| 14 |
# expectations |
| 15 |
-- disable_query_log |
| 16 |
-- disable_result_log |
| 17 |
|
| 18 |
# we want to use "-- eval statement1; statement2" which does not work with |
| 19 |
# prepared statements. Because this test should not behave differently with |
| 20 |
# or without prepared statements we disable them so the test does not fail |
| 21 |
# if someone runs ./mysql-test-run.pl --ps-protocol |
| 22 |
-- disable_ps_protocol |
| 23 |
|
| 24 |
-- disable_warnings |
| 25 |
DROP TABLE IF EXISTS t1, t2, t3, t4, t5_nontrans; |
| 26 |
-- enable_warnings |
| 27 |
|
| 28 |
# we will create a simple deadlock with t1, t2 and two connections |
| 29 |
CREATE TABLE t1 (a INT); |
| 30 |
CREATE TABLE t2 (a INT); |
| 31 |
|
| 32 |
# auxiliary table with a bulk of rows which will be locked by a |
| 33 |
# transaction to increase its weight |
| 34 |
CREATE TABLE t3 (a INT); |
| 35 |
|
| 36 |
# auxiliary empty table which will be inserted by a |
| 37 |
# transaction to increase its weight |
| 38 |
CREATE TABLE t4 (a INT); |
| 39 |
|
| 40 |
# auxiliary non-transactional table which will be edited by a |
| 41 |
# transaction to tremendously increase its weight |
| 42 |
CREATE TABLE t5_nontrans (a INT) ENGINE=MyISAM; |
| 43 |
|
| 44 |
INSERT INTO t1 VALUES (1); |
| 45 |
INSERT INTO t2 VALUES (1); |
| 46 |
# insert a lot of rows in t3 |
| 47 |
INSERT INTO t3 VALUES (1); |
| 48 |
INSERT INTO t3 SELECT * FROM t3; |
| 49 |
INSERT INTO t3 SELECT * FROM t3; |
| 50 |
INSERT INTO t3 SELECT * FROM t3; |
| 51 |
INSERT INTO t3 SELECT * FROM t3; |
| 52 |
INSERT INTO t3 SELECT * FROM t3; |
| 53 |
INSERT INTO t3 SELECT * FROM t3; |
| 54 |
INSERT INTO t3 SELECT * FROM t3; |
| 55 |
INSERT INTO t3 SELECT * FROM t3; |
| 56 |
INSERT INTO t3 SELECT * FROM t3; |
| 57 |
INSERT INTO t3 SELECT * FROM t3; |
| 58 |
INSERT INTO t3 SELECT * FROM t3; |
| 59 |
|
| 60 |
# test locking weight |
| 61 |
|
| 62 |
-- let $con1_extra_sql = INSERT INTO t4 VALUES (1), (1), (1), (1), (1), (1), (1), (1), (1), (1), (1), (1), (1), (1), (1), (1), (1), (1) |
| 63 |
-- let $con1_extra_sql_present = 1 |
| 64 |
-- let $con2_extra_sql = SELECT * FROM t3 FOR UPDATE |
| 65 |
-- let $con2_extra_sql_present = 1 |
| 66 |
-- let $con1_should_be_rolledback = 0 |
| 67 |
-- source include/innodb_trx_weight.inc |
| 68 |
|
| 69 |
# insert more rows for 64k page size. |
| 70 |
INSERT INTO t3 SELECT * FROM t3; |
| 71 |
|
| 72 |
-- let $con1_extra_sql = INSERT INTO t4 VALUES (1), (1) |
| 73 |
-- let $con1_extra_sql_present = 1 |
| 74 |
-- let $con2_extra_sql = SELECT * FROM t3 FOR UPDATE |
| 75 |
-- let $con2_extra_sql_present = 1 |
| 76 |
-- let $con1_should_be_rolledback = 1 |
| 77 |
-- source include/innodb_trx_weight.inc |
| 78 |
|
| 79 |
-- let $con1_extra_sql = |
| 80 |
-- let $con1_extra_sql_present = 0 |
| 81 |
-- let $con2_extra_sql = SELECT * FROM t3 FOR UPDATE |
| 82 |
-- let $con2_extra_sql_present = 1 |
| 83 |
-- let $con1_should_be_rolledback = 1 |
| 84 |
-- source include/innodb_trx_weight.inc |
| 85 |
|
| 86 |
# test weight when non-transactional tables are edited |
| 87 |
|
| 88 |
-- let $con1_extra_sql = INSERT INTO t4 VALUES (1), (1), (1) |
| 89 |
-- let $con1_extra_sql_present = 1 |
| 90 |
-- let $con2_extra_sql = |
| 91 |
-- let $con2_extra_sql_present = 0 |
| 92 |
-- let $con1_should_be_rolledback = 0 |
| 93 |
-- source include/innodb_trx_weight.inc |
| 94 |
|
| 95 |
-- let $con1_extra_sql = INSERT INTO t4 VALUES (1), (1), (1) |
| 96 |
-- let $con1_extra_sql_present = 1 |
| 97 |
-- let $con2_extra_sql = INSERT INTO t5_nontrans VALUES (1) |
| 98 |
-- let $con2_extra_sql_present = 1 |
| 99 |
-- let $con1_should_be_rolledback = 1 |
| 100 |
-- source include/innodb_trx_weight.inc |
| 101 |
|
| 102 |
-- let $con1_extra_sql = INSERT INTO t4 VALUES (1), (1), (1) |
| 103 |
-- let $con1_extra_sql = $con1_extra_sql; INSERT INTO t5_nontrans VALUES (1) |
| 104 |
-- let $con1_extra_sql_present = 1 |
| 105 |
-- let $con2_extra_sql = INSERT INTO t5_nontrans VALUES (1) |
| 106 |
-- let $con2_extra_sql_present = 1 |
| 107 |
-- let $con1_should_be_rolledback = 0 |
| 108 |
-- source include/innodb_trx_weight.inc |
| 109 |
|
| 110 |
DROP TABLE t1, t2, t3, t4, t5_nontrans; |