summaryrefslogtreecommitdiff
path: root/mysql-test/suite/galera_sr/t/galera_sr_kill_connection.test
blob: 03d09f33fab8c582d5f42659cf1a0bba8f9225f5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
--source include/galera_cluster.inc
--source include/have_innodb.inc

#
# Test KILL CONNECTION on a transaction that has already replicated some data via SR
#

SET SESSION wsrep_trx_fragment_size = 1;

CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB;

SET AUTOCOMMIT=OFF;
START TRANSACTION;

INSERT INTO t1 VALUES (1);
INSERT INTO t1 VALUES (2);
INSERT INTO t1 VALUES (3);
INSERT INTO t1 VALUES (4);
INSERT INTO t1 VALUES (5);

# Confirm that the transaction is SR-replicated
--connection node_2
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
--let $wait_condition = SELECT COUNT(*) > 0 FROM t1;
--source include/wait_condition.inc

# Kill the transaction by killing the entire connection

--connection node_1
--let $connection_id = `SELECT CONNECTION_ID()`
--connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1
--disable_query_log
--eval KILL CONNECTION $connection_id
--enable_query_log

# Confirm that the disconnection caused the updates made so far to be removed
--connection node_2
--let $wait_condition = SELECT COUNT(*) = 0 FROM t1;
--source include/wait_condition.inc

# Confirm that the transaction can be reissued in its entirety on the slave without a conflict

SET AUTOCOMMIT=OFF;
START TRANSACTION;

INSERT INTO t1 VALUES (1);
INSERT INTO t1 VALUES (2);
INSERT INTO t1 VALUES (3);
INSERT INTO t1 VALUES (4);
INSERT INTO t1 VALUES (5);

COMMIT;

SELECT COUNT(*) = 5 FROM t1;

--connection node_1a
SELECT COUNT(*) = 5 FROM t1;

DROP TABLE t1;