| 1 |
--source include/galera_cluster.inc |
| 2 |
--source include/have_innodb.inc |
| 3 |
--source include/no_protocol.inc |
| 4 |
|
| 5 |
CREATE TABLE t (i int primary key auto_increment, j varchar(20) character set utf8); |
| 6 |
|
| 7 |
--connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1 |
| 8 |
--connection node_1a |
| 9 |
SET SESSION wsrep_sync_wait = 0; |
| 10 |
|
| 11 |
--connection node_1 |
| 12 |
insert into t values (1, 'first'); |
| 13 |
|
| 14 |
# prepare a statement for inserting rows into table t |
| 15 |
--PS_prepare INSERT INTO t(j) VALUES (?); |
| 16 |
|
| 17 |
# bind parameter, to insert with column j having value 'node1' |
| 18 |
--PS_bind node1 |
| 19 |
|
| 20 |
# insert two rows with the PS |
| 21 |
# this is for showing that two execute commands can follow a bind command |
| 22 |
--PS_execute |
| 23 |
--PS_execute |
| 24 |
select * from t; |
| 25 |
|
| 26 |
# close the prepared statement, and prepare a new PS, |
| 27 |
# this happens to be same as the first PS |
| 28 |
# also bind parameter for the PS |
| 29 |
--PS_close |
| 30 |
--PS_prepare INSERT INTO t(j) VALUES (?); |
| 31 |
--PS_bind node1 |
| 32 |
|
| 33 |
# start a transaction and make one update |
| 34 |
# leaving the transaction open |
| 35 |
begin; |
| 36 |
update t set j='node1' where i=1; |
| 37 |
|
| 38 |
# replicate a transaction from node2, which BF aborts the open |
| 39 |
# transaction in node1 |
| 40 |
--connection node_2 |
| 41 |
update t set j='node2' where i=1; |
| 42 |
|
| 43 |
# wait until the BF has completed, and update from node_2 has committed |
| 44 |
--connection node_1a |
| 45 |
--let $wait_condition = SELECT COUNT(*) = 1 FROM t WHERE j='node2' |
| 46 |
--source include/wait_condition.inc |
| 47 |
|
| 48 |
# continue the open transaction, trying to insert third row, deadlock is now observed |
| 49 |
--connection node_1 |
| 50 |
--error ER_LOCK_DEADLOCK |
| 51 |
--PS_execute |
| 52 |
|
| 53 |
# try to insert one more row |
| 54 |
--PS_execute |
| 55 |
commit; |
| 56 |
|
| 57 |
--PS_close |
| 58 |
|
| 59 |
select * from t; |
| 60 |
|
| 61 |
drop table t; |