| 1 |
--source include/galera_cluster.inc |
| 2 |
--source include/have_innodb.inc |
| 3 |
|
| 4 |
# |
| 5 |
# Test case 1: Start a transaction on node_2a and kill it |
| 6 |
# from other connection on same node |
| 7 |
# |
| 8 |
|
| 9 |
--connection node_2 |
| 10 |
call mtr.add_suppression("InnoDB: Transaction was aborted due to "); |
| 11 |
CREATE TABLE t1(a int not null primary key auto_increment,b int) engine=InnoDB; |
| 12 |
insert into t1 values (NULL,1); |
| 13 |
|
| 14 |
--connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2 |
| 15 |
--connection node_2a |
| 16 |
call mtr.add_suppression("InnoDB: Transaction was aborted due to "); |
| 17 |
begin; |
| 18 |
update t1 set a = 5; |
| 19 |
|
| 20 |
--connection node_2 |
| 21 |
|
| 22 |
--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'root' AND COMMAND = 'Sleep' LIMIT 1 |
| 23 |
--source include/wait_condition.inc |
| 24 |
|
| 25 |
--let $k_thread = `SELECT ID FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'root' AND COMMAND = 'Sleep' LIMIT 1` |
| 26 |
|
| 27 |
--disable_query_log |
| 28 |
--eval KILL $k_thread |
| 29 |
--enable_query_log |
| 30 |
|
| 31 |
select * from t1; |
| 32 |
--disconnect node_2a |
| 33 |
|
| 34 |
# |
| 35 |
# Test case 2: Start a transaction on node_2a and use |
| 36 |
# kill query from other connection on same node |
| 37 |
# |
| 38 |
|
| 39 |
--connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2 |
| 40 |
--connection node_2a |
| 41 |
begin; |
| 42 |
update t1 set a =5; |
| 43 |
|
| 44 |
--connection node_2 |
| 45 |
--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'root' AND COMMAND = 'Sleep' LIMIT 1 |
| 46 |
--source include/wait_condition.inc |
| 47 |
|
| 48 |
--let $k_thread = `SELECT ID FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'root' AND COMMAND = 'Sleep' LIMIT 1` |
| 49 |
|
| 50 |
--disable_query_log |
| 51 |
--eval KILL QUERY $k_thread |
| 52 |
--enable_query_log |
| 53 |
|
| 54 |
select * from t1; |
| 55 |
--disconnect node_2a |
| 56 |
# |
| 57 |
# Test case 3: Start a transaction on node_2a and start a DDL on other transaction |
| 58 |
# that will then abort node_2a transaction |
| 59 |
# |
| 60 |
--connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2 |
| 61 |
--connection node_2a |
| 62 |
begin; |
| 63 |
update t1 set a =5, b=2; |
| 64 |
|
| 65 |
--connection node_2 |
| 66 |
ALTER TABLE t1 ADD UNIQUE KEY b1(b); |
| 67 |
ALTER TABLE t1 DROP KEY b1; |
| 68 |
|
| 69 |
select * from t1; |
| 70 |
|
| 71 |
--disconnect node_2a |
| 72 |
|
| 73 |
# |
| 74 |
# Test case 4: Start a transaction on node_2a and conflicting transaction on node_2b |
| 75 |
# and start a DDL on other transaction that will then abort node_2a and node_2b |
| 76 |
# transactions |
| 77 |
# |
| 78 |
|
| 79 |
--connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2 |
| 80 |
--connection node_2a |
| 81 |
begin; |
| 82 |
update t1 set a =5, b=2; |
| 83 |
|
| 84 |
--connect node_2b, 127.0.0.1, root, , test, $NODE_MYPORT_2 |
| 85 |
--connection node_2b |
| 86 |
begin; |
| 87 |
send update t1 set a =6, b=7; |
| 88 |
|
| 89 |
--connection node_2 |
| 90 |
ALTER TABLE t1 ADD UNIQUE KEY b2(b); |
| 91 |
ALTER TABLE t1 DROP KEY b2; |
| 92 |
|
| 93 |
select * from t1; |
| 94 |
|
| 95 |
--disconnect node_2a |
| 96 |
--disconnect node_2b |
| 97 |
|
| 98 |
# |
| 99 |
# Test case 5: Start a transaction on node_2a with wsrep disabled. |
| 100 |
# A conflicting DDL on other transaction can't BF abort |
| 101 |
# transaction from node_2a (wsrep disabled). |
| 102 |
# |
| 103 |
|
| 104 |
--connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2 |
| 105 |
--connect node_2b, 127.0.0.1, root, , test, $NODE_MYPORT_2 |
| 106 |
--connection node_2a |
| 107 |
SET SESSION wsrep_on=OFF; |
| 108 |
begin; |
| 109 |
update t1 set a =5, b=2; |
| 110 |
|
| 111 |
--connection node_2 |
| 112 |
--send ALTER TABLE t1 ADD UNIQUE KEY b3(b) |
| 113 |
|
| 114 |
--connection node_2b |
| 115 |
SET SESSION wsrep_sync_wait=0; |
| 116 |
--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE LIKE 'Waiting for table metadata lock%' OR STATE LIKE 'Waiting to execute in isolation%'; |
| 117 |
--source include/wait_condition.inc |
| 118 |
|
| 119 |
--connection node_2a |
| 120 |
select * from t1; |
| 121 |
|
| 122 |
# We expect that ALTER should not be able to BF abort |
| 123 |
# this transaction, it must wait for it to finish. |
| 124 |
# Expect commit to succeed. |
| 125 |
commit; |
| 126 |
|
| 127 |
--connection node_2 |
| 128 |
--reap |
| 129 |
|
| 130 |
--disconnect node_2a |
| 131 |
--disconnect node_2b |
| 132 |
|
| 133 |
# |
| 134 |
# Test case 6: Start a transaction on node_2a with wsrep disabled |
| 135 |
# and kill it from other connection on same node. |
| 136 |
# |
| 137 |
|
| 138 |
--connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2 |
| 139 |
--connection node_2a |
| 140 |
SET SESSION wsrep_on=OFF; |
| 141 |
begin; |
| 142 |
update t1 set a =5, b=2; |
| 143 |
|
| 144 |
--connection node_2 |
| 145 |
--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'root' AND COMMAND = 'Sleep' LIMIT 1 |
| 146 |
--source include/wait_condition.inc |
| 147 |
|
| 148 |
--let $k_thread = `SELECT ID FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'root' AND COMMAND = 'Sleep' LIMIT 1` |
| 149 |
|
| 150 |
--disable_query_log |
| 151 |
--eval KILL $k_thread |
| 152 |
--enable_query_log |
| 153 |
|
| 154 |
select * from t1; |
| 155 |
|
| 156 |
--disconnect node_2a |
| 157 |
|
| 158 |
--connection node_1 |
| 159 |
|
| 160 |
source include/maybe_debug.inc; |
| 161 |
if ($have_debug) { |
| 162 |
# |
| 163 |
# Test case 7: Start a transaction on node_2 and use KILL to abort |
| 164 |
# a query in connection node_2a |
| 165 |
# During the KILL execution replicate conflicting transaction from node_1 |
| 166 |
# to BF abort the transaction executing the KILL |
| 167 |
# |
| 168 |
|
| 169 |
--connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2 |
| 170 |
--connection node_2a |
| 171 |
truncate t1; |
| 172 |
insert into t1 values (7,0); |
| 173 |
|
| 174 |
--connection node_2 |
| 175 |
set wsrep_sync_wait=0; |
| 176 |
|
| 177 |
# get the ID of connection to be later killed |
| 178 |
--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'root' AND COMMAND = 'Sleep' LIMIT 1 |
| 179 |
--source include/wait_condition.inc |
| 180 |
--let $k_thread = `SELECT ID FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'root' AND COMMAND = 'Sleep' LIMIT 1` |
| 181 |
|
| 182 |
# start a transaction |
| 183 |
begin; |
| 184 |
update t1 set b=2 where a=7; |
| 185 |
|
| 186 |
# set sync point for incoming applying |
| 187 |
--connect node_2b, 127.0.0.1, root, , test, $NODE_MYPORT_2 |
| 188 |
set wsrep_sync_wait=0; |
| 189 |
|
| 190 |
SET GLOBAL debug_dbug = "d,sync.wsrep_apply_cb"; |
| 191 |
|
| 192 |
# replicate conflicting transaction, should stopp in the sync point |
| 193 |
--connection node_1 |
| 194 |
update t1 set b=1 where a=7; |
| 195 |
|
| 196 |
# wait for the applier to reach the sync point |
| 197 |
--connection node_2b |
| 198 |
SET SESSION DEBUG_SYNC = "now WAIT_FOR sync.wsrep_apply_cb_reached"; |
| 199 |
|
| 200 |
# issue KILL inside the transacion, implicit commit is expected |
| 201 |
--connection node_2 |
| 202 |
--disable_query_log |
| 203 |
--send_eval KILL QUERY $k_thread |
| 204 |
--enable_query_log |
| 205 |
|
| 206 |
# wait for the KILL processing to be seen in processlist |
| 207 |
--connection node_2b |
| 208 |
--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'root' AND INFO LIKE 'KILL QUERY%' |
| 209 |
--source include/wait_condition.inc |
| 210 |
|
| 211 |
# resume applying, BF abort should follow |
| 212 |
SET DEBUG_SYNC = "now SIGNAL signal.wsrep_apply_cb"; |
| 213 |
|
| 214 |
--connection node_2 |
| 215 |
--error ER_LOCK_DEADLOCK |
| 216 |
--reap |
| 217 |
|
| 218 |
commit; |
| 219 |
|
| 220 |
select * from t1; |
| 221 |
|
| 222 |
--connection node_2a |
| 223 |
SET DEBUG_SYNC= 'RESET'; |
| 224 |
SET GLOBAL debug_dbug = ""; |
| 225 |
|
| 226 |
--disconnect node_2a |
| 227 |
--disconnect node_2b |
| 228 |
|
| 229 |
--connection node_1 |
| 230 |
} |
| 231 |
|
| 232 |
drop table t1; |