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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
|
include/master-slave.inc
[connection master]
connection master;
call mtr.add_suppression("Found 2 prepared XA transactions");
CREATE VIEW v_processlist as SELECT * FROM performance_schema.threads where type = 'FOREGROUND';
CREATE DATABASE d1;
CREATE DATABASE d2;
CREATE TABLE d1.t (a INT) ENGINE=innodb;
CREATE TABLE d2.t (a INT) ENGINE=innodb;
INSERT INTO d1.t VALUES(100);
connect master_conn1, 127.0.0.1,root,,test,$MASTER_MYPORT,;
SET @@session.binlog_format= statement;
XA START '1-stmt';
INSERT INTO d1.t VALUES (1);
XA END '1-stmt';
XA PREPARE '1-stmt';
disconnect master_conn1;
connection master;
connect master_conn2, 127.0.0.1,root,,test,$MASTER_MYPORT,;
SET @@session.binlog_format= row;
XA START '1-row';
INSERT INTO d2.t VALUES (1);
XA END '1-row';
XA PREPARE '1-row';
disconnect master_conn2;
connection master;
XA START '2';
INSERT INTO d1.t VALUES (2);
XA END '2';
XA PREPARE '2';
XA COMMIT '2';
XA COMMIT '1-row';
XA COMMIT '1-stmt';
include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Gtid # # BEGIN GTID #-#-#
master-bin.000001 # Query # # use `mtr`; INSERT INTO test_suppressions (pattern) VALUES ( NAME_CONST('pattern',_latin1'Found 2 prepared XA transactions' COLLATE 'latin1_swedish_ci'))
master-bin.000001 # Query # # COMMIT
master-bin.000001 # Gtid # # GTID #-#-#
master-bin.000001 # Query # # use `test`; CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v_processlist` AS SELECT * FROM performance_schema.threads where type = 'FOREGROUND'
master-bin.000001 # Gtid # # GTID #-#-#
master-bin.000001 # Query # # CREATE DATABASE d1
master-bin.000001 # Gtid # # GTID #-#-#
master-bin.000001 # Query # # CREATE DATABASE d2
master-bin.000001 # Gtid # # GTID #-#-#
master-bin.000001 # Query # # use `test`; CREATE TABLE d1.t (a INT) ENGINE=innodb
master-bin.000001 # Gtid # # GTID #-#-#
master-bin.000001 # Query # # use `test`; CREATE TABLE d2.t (a INT) ENGINE=innodb
master-bin.000001 # Gtid # # BEGIN GTID #-#-#
master-bin.000001 # Query # # use `test`; INSERT INTO d1.t VALUES(100)
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Gtid # # XA START X'312d73746d74',X'',1 GTID #-#-#
master-bin.000001 # Query # # use `test`; INSERT INTO d1.t VALUES (1)
master-bin.000001 # Query # # XA END X'312d73746d74',X'',1
master-bin.000001 # XA_prepare # # XA PREPARE X'312d73746d74',X'',1
master-bin.000001 # Gtid # # XA START X'312d726f77',X'',1 GTID #-#-#
master-bin.000001 # Annotate_rows # # INSERT INTO d2.t VALUES (1)
master-bin.000001 # Table_map # # table_id: # (d2.t)
master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F
master-bin.000001 # Query # # XA END X'312d726f77',X'',1
master-bin.000001 # XA_prepare # # XA PREPARE X'312d726f77',X'',1
master-bin.000001 # Gtid # # XA START X'32',X'',1 GTID #-#-#
master-bin.000001 # Query # # use `test`; INSERT INTO d1.t VALUES (2)
master-bin.000001 # Query # # XA END X'32',X'',1
master-bin.000001 # XA_prepare # # XA PREPARE X'32',X'',1
master-bin.000001 # Gtid # # GTID #-#-#
master-bin.000001 # Query # # XA COMMIT X'32',X'',1
master-bin.000001 # Gtid # # GTID #-#-#
master-bin.000001 # Query # # XA COMMIT X'312d726f77',X'',1
master-bin.000001 # Gtid # # GTID #-#-#
master-bin.000001 # Query # # XA COMMIT X'312d73746d74',X'',1
include/sync_slave_sql_with_master.inc
include/stop_slave.inc
connection master;
connect master2, 127.0.0.1,root,,test,$MASTER_MYPORT,;
connection master2;
SET @@session.binlog_format= statement;
XA START '3-stmt';
INSERT INTO d1.t VALUES (3);
XA END '3-stmt';
XA PREPARE '3-stmt';
disconnect master2;
connect master2, 127.0.0.1,root,,test,$MASTER_MYPORT,;
connection master2;
SET @@session.binlog_format= row;
XA START '3-row';
INSERT INTO d2.t VALUES (4);
XA END '3-row';
XA PREPARE '3-row';
disconnect master2;
connection master;
connect master2, 127.0.0.1,root,,test,$MASTER_MYPORT,;
connection master2;
XA START '4';
SELECT * FROM d1.t;
a
100
1
2
XA END '4';
XA PREPARE '4';
disconnect master2;
connect master_bulk_conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,;
XA START 'bulk_trx_10';
INSERT INTO d1.t VALUES (10);
INSERT INTO d2.t VALUES (10);
XA END 'bulk_trx_10';
XA PREPARE 'bulk_trx_10';
disconnect master_bulk_conn10;
connection master;
connect master_bulk_conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,;
XA START 'bulk_trx_9';
INSERT INTO d1.t VALUES (9);
INSERT INTO d2.t VALUES (9);
XA END 'bulk_trx_9';
XA PREPARE 'bulk_trx_9';
disconnect master_bulk_conn9;
connection master;
connect master_bulk_conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,;
XA START 'bulk_trx_8';
INSERT INTO d1.t VALUES (8);
INSERT INTO d2.t VALUES (8);
XA END 'bulk_trx_8';
XA PREPARE 'bulk_trx_8';
disconnect master_bulk_conn8;
connection master;
connect master_bulk_conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,;
XA START 'bulk_trx_7';
INSERT INTO d1.t VALUES (7);
INSERT INTO d2.t VALUES (7);
XA END 'bulk_trx_7';
XA PREPARE 'bulk_trx_7';
disconnect master_bulk_conn7;
connection master;
connect master_bulk_conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,;
XA START 'bulk_trx_6';
INSERT INTO d1.t VALUES (6);
INSERT INTO d2.t VALUES (6);
XA END 'bulk_trx_6';
XA PREPARE 'bulk_trx_6';
disconnect master_bulk_conn6;
connection master;
connect master_bulk_conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,;
XA START 'bulk_trx_5';
INSERT INTO d1.t VALUES (5);
INSERT INTO d2.t VALUES (5);
XA END 'bulk_trx_5';
XA PREPARE 'bulk_trx_5';
disconnect master_bulk_conn5;
connection master;
connect master_bulk_conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,;
XA START 'bulk_trx_4';
INSERT INTO d1.t VALUES (4);
INSERT INTO d2.t VALUES (4);
XA END 'bulk_trx_4';
XA PREPARE 'bulk_trx_4';
disconnect master_bulk_conn4;
connection master;
connect master_bulk_conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,;
XA START 'bulk_trx_3';
INSERT INTO d1.t VALUES (3);
INSERT INTO d2.t VALUES (3);
XA END 'bulk_trx_3';
XA PREPARE 'bulk_trx_3';
disconnect master_bulk_conn3;
connection master;
connect master_bulk_conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,;
XA START 'bulk_trx_2';
INSERT INTO d1.t VALUES (2);
INSERT INTO d2.t VALUES (2);
XA END 'bulk_trx_2';
XA PREPARE 'bulk_trx_2';
disconnect master_bulk_conn2;
connection master;
connect master_bulk_conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,;
XA START 'bulk_trx_1';
INSERT INTO d1.t VALUES (1);
INSERT INTO d2.t VALUES (1);
XA END 'bulk_trx_1';
XA PREPARE 'bulk_trx_1';
disconnect master_bulk_conn1;
connection master;
connection slave;
include/start_slave.inc
connection master;
include/sync_slave_sql_with_master.inc
include/stop_slave.inc
connection master;
XA COMMIT 'bulk_trx_10';
XA ROLLBACK 'bulk_trx_9';
XA COMMIT 'bulk_trx_8';
XA ROLLBACK 'bulk_trx_7';
XA COMMIT 'bulk_trx_6';
XA ROLLBACK 'bulk_trx_5';
XA COMMIT 'bulk_trx_4';
XA ROLLBACK 'bulk_trx_3';
XA COMMIT 'bulk_trx_2';
XA ROLLBACK 'bulk_trx_1';
include/rpl_restart_server.inc [server_number=1]
connection slave;
include/start_slave.inc
connection master;
*** '3-stmt','3-row' xa-transactions must be in the list ***
XA RECOVER;
formatID gtrid_length bqual_length data
1 6 0 3-stmt
1 5 0 3-row
XA COMMIT '3-stmt';
XA ROLLBACK '3-row';
include/sync_slave_sql_with_master.inc
connection master;
connect master_conn2, 127.0.0.1,root,,test,$MASTER_MYPORT,;
XA START '0123456789012345678901234567890123456789012345678901234567890124','0123456789012345678901234567890123456789012345678901234567890124',2147483647;
INSERT INTO d1.t VALUES (64);
XA END '0123456789012345678901234567890123456789012345678901234567890124','0123456789012345678901234567890123456789012345678901234567890124',2147483647;
XA PREPARE '0123456789012345678901234567890123456789012345678901234567890124','0123456789012345678901234567890123456789012345678901234567890124',2147483647;
disconnect master_conn2;
connection master;
connect master_conn3, 127.0.0.1,root,,test,$MASTER_MYPORT,;
XA START X'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF',X'00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',0;
INSERT INTO d1.t VALUES (0);
XA END X'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF',X'00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',0;
XA PREPARE X'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF',X'00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',0;
disconnect master_conn3;
connection master;
disconnect master_conn4;
connection master;
XA COMMIT '0123456789012345678901234567890123456789012345678901234567890124','0123456789012345678901234567890123456789012345678901234567890124',2147483647;
XA COMMIT X'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF',X'00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',0;
XA COMMIT 'RANDOM XID'
include/sync_slave_sql_with_master.inc
connect master_bulk_conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,;
connection master_bulk_conn10;
XA START 'one_phase_10';
INSERT INTO d1.t VALUES (10);
INSERT INTO d2.t VALUES (10);
XA END 'one_phase_10';
XA COMMIT 'one_phase_10' ONE PHASE;
disconnect master_bulk_conn10;
connect master_bulk_conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,;
connection master_bulk_conn9;
XA START 'one_phase_9';
INSERT INTO d1.t VALUES (9);
INSERT INTO d2.t VALUES (9);
XA END 'one_phase_9';
XA COMMIT 'one_phase_9' ONE PHASE;
disconnect master_bulk_conn9;
connect master_bulk_conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,;
connection master_bulk_conn8;
XA START 'one_phase_8';
INSERT INTO d1.t VALUES (8);
INSERT INTO d2.t VALUES (8);
XA END 'one_phase_8';
XA COMMIT 'one_phase_8' ONE PHASE;
disconnect master_bulk_conn8;
connect master_bulk_conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,;
connection master_bulk_conn7;
XA START 'one_phase_7';
INSERT INTO d1.t VALUES (7);
INSERT INTO d2.t VALUES (7);
XA END 'one_phase_7';
XA COMMIT 'one_phase_7' ONE PHASE;
disconnect master_bulk_conn7;
connect master_bulk_conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,;
connection master_bulk_conn6;
XA START 'one_phase_6';
INSERT INTO d1.t VALUES (6);
INSERT INTO d2.t VALUES (6);
XA END 'one_phase_6';
XA COMMIT 'one_phase_6' ONE PHASE;
disconnect master_bulk_conn6;
connect master_bulk_conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,;
connection master_bulk_conn5;
XA START 'one_phase_5';
INSERT INTO d1.t VALUES (5);
INSERT INTO d2.t VALUES (5);
XA END 'one_phase_5';
XA COMMIT 'one_phase_5' ONE PHASE;
disconnect master_bulk_conn5;
connect master_bulk_conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,;
connection master_bulk_conn4;
XA START 'one_phase_4';
INSERT INTO d1.t VALUES (4);
INSERT INTO d2.t VALUES (4);
XA END 'one_phase_4';
XA COMMIT 'one_phase_4' ONE PHASE;
disconnect master_bulk_conn4;
connect master_bulk_conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,;
connection master_bulk_conn3;
XA START 'one_phase_3';
INSERT INTO d1.t VALUES (3);
INSERT INTO d2.t VALUES (3);
XA END 'one_phase_3';
XA COMMIT 'one_phase_3' ONE PHASE;
disconnect master_bulk_conn3;
connect master_bulk_conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,;
connection master_bulk_conn2;
XA START 'one_phase_2';
INSERT INTO d1.t VALUES (2);
INSERT INTO d2.t VALUES (2);
XA END 'one_phase_2';
XA COMMIT 'one_phase_2' ONE PHASE;
disconnect master_bulk_conn2;
connect master_bulk_conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,;
connection master_bulk_conn1;
XA START 'one_phase_1';
INSERT INTO d1.t VALUES (1);
INSERT INTO d2.t VALUES (1);
XA END 'one_phase_1';
XA COMMIT 'one_phase_1' ONE PHASE;
disconnect master_bulk_conn1;
connection master;
include/sync_slave_sql_with_master.inc
include/diff_tables.inc [master:d1.t, slave:d1.t]
include/diff_tables.inc [master:d2.t, slave:d2.t]
connection master;
DELETE FROM d1.t;
DELETE FROM d2.t;
DROP TABLE d1.t, d2.t;
DROP DATABASE d1;
DROP DATABASE d2;
DROP VIEW v_processlist;
include/sync_slave_sql_with_master.inc
include/rpl_end.inc
|