Debian Codegraph @

mysql-test/suite/galera/t/galera_as_slave_replay.test

raw
1 #
2 # This test tests the operation of transaction replay for async replication slave.
3 # If a potentially conflicting galera transaction arrives at
4 # just the right time during the commit and has lock conflict with async replication transaction
5 # applied by slave SQL thread, then the async replication transaction should either abort
6 # or rollback and replay (depending on the nature of lock conflict).
7 #
8
9 --source include/have_innodb.inc
10 --source include/have_debug.inc
11 --source include/have_debug_sync.inc
12 --source include/galera_have_debug_sync.inc
13 --source include/log_bin.inc
14
15 --connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2
16
17 --connection node_2a
18 --source include/galera_cluster.inc
19
20 ALTER TABLE mysql.gtid_slave_pos ENGINE=InnoDB;
21
22 #
23 # node 3 is native MariaDB server operating as async replication master
24 #
25 --connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3
26 --connection node_3
27 RESET MASTER;
28
29 --connection node_2a
30 #
31 # count the number of wsrep replay's done in the node
32 #
33 --let $wsrep_local_replays_old = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_replays'`
34
35 #
36 # nodes 1 and 2 form a galera cluster, node 2 operates as slave for native MariaDB master in node 3
37 #
38 --disable_query_log
39 --eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_USER='root', MASTER_SSL_VERIFY_SERVER_CERT=0, MASTER_PORT=$NODE_MYPORT_3;
40 --enable_query_log
41 START SLAVE;
42
43 --connection node_3
44 CREATE TABLE t1 (f1 INTEGER PRIMARY KEY, f2 CHAR(1)) engine=innodb;
45 INSERT INTO t1 VALUES (1, 'a');
46 INSERT INTO t1 VALUES (3, 'a');
47
48 #
49 # use statement format replication to cause a false positive conflict with async replication transaction
50 # and galera replication. The conflict will be on GAP lock, and slave SQL thread should rollback
51 # and replay
52 #
53 set binlog_format=STATEMENT;
54
55 SET AUTOCOMMIT=ON;
56 START TRANSACTION;
57
58 SELECT * FROM t1 FOR UPDATE;
59 UPDATE t1 SET f2 = 'c' WHERE f1 > 1;
60
61 --connection node_2a
62 # wait for create table and inserts to be replicated from master
63 SET SESSION wsrep_sync_wait = 0;
64 --let $wait_condition = SELECT COUNT(*) = 2 FROM test.t1;
65 --source include/wait_condition.inc
66
67 # wait for create table and inserts to be replicated in cluster
68 --connection node_1
69 SET SESSION wsrep_sync_wait = 0;
70 --let $wait_condition = SELECT COUNT(*) = 2 FROM test.t1;
71 --source include/wait_condition.inc
72
73 --connection node_2a
74 # Block the future commit of async replication
75 --let $galera_sync_point = commit_monitor_master_enter_sync
76 --source include/galera_set_sync_point.inc
77
78 # block also the applier before applying begins
79 SET GLOBAL debug_dbug = "d,sync.wsrep_apply_cb";
80
81 #
82 # now inject a conflicting insert from node 1, it will replicate with
83 # earlier seqno (than async transaction) and pause before applying in node 2
84 #
85 --connection node_1
86 INSERT INTO test.t1 VALUES (2, 'b');
87
88 #
89 # send the update from master, this will succeed here, because of async replication.
90 # async replication will apply this in node 2 and pause before commit phase,
91 --connection node_3
92 --error 0
93 COMMIT;
94
95 # Wait until async slave commit is blocked in node_2
96 --connection node_2a
97 --source include/galera_wait_sync_point.inc
98
99 #
100 # release the applier
101 # note: have to clear wsrep_apply_cb sync point first, as async replication will go for replay
102 # and as this sync point, after BF applier is released to progress
103 #
104 SET GLOBAL debug_dbug = "";
105 SET DEBUG_SYNC = "now SIGNAL signal.wsrep_apply_cb";
106
107 # Unblock the async slave commit
108 --connection node_2a
109 --source include/galera_clear_sync_point.inc
110 --source include/galera_signal_sync_point.inc
111
112 --connection node_3
113
114 SELECT COUNT(*) = 1 FROM t1 WHERE f2 = 'a';
115 SELECT COUNT(*) = 1 FROM t1 WHERE f2 = 'c';
116 SELECT * FROM t1;
117
118 --connection node_2a
119
120 # wsrep_local_replays has increased by 1
121 set session wsrep_sync_wait=15;
122 --let $wsrep_local_replays_new = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_replays'`
123 set session wsrep_sync_wait=0;
124
125 --disable_query_log
126 --eval SELECT $wsrep_local_replays_new - $wsrep_local_replays_old = 1 AS wsrep_local_replays;
127 --enable_query_log
128
129 #
130 # replaying of async transaction should be effective, and row 3 having 'c' in f2
131 #
132 SELECT * FROM t1;
133 SET DEBUG_SYNC = "RESET";
134
135 --connection node_2a
136 STOP SLAVE;
137 RESET SLAVE;
138
139 DROP TABLE t1;
140
141 --connection node_3
142 DROP TABLE t1;
143 RESET MASTER;
144
145 --connection node_1
146 --disconnect node_2a
147 --disconnect node_3