Debian Codegraph @

mysql-test/suite/binlog/t/binlog_xa_trx_split_across_binlog.test

raw
1 ###############################################################################
2 # This test script is to check the behaviour of applying XA transaction from
3 # a binlog dump if the XA transaction split across binary logs.
4 #
5 # Steps to reproduce:
6 # 1) Reset the master and set max_binlog_size to a smaller value 4KB.
7 # 2) Start a XA transaction which is more than max_binlog_size (4KB).
8 # 3) Prepare the XA trx.
9 # (trx content will be written to binlog.000001 and the binlog
10 # will be rotated because of the size limit).
11 # 4) Commit the XA trx (commit will be written to binlog2).
12 # 5) Save the binlog dump for the reapply purpose.
13 # 6) Cleanup the server and make it ready to apply the binlog dump.
14 # 7) Apply the binlog dump.
15 # 8) Verify that the old data is restorted properly without any issues.
16 # 9) Cleanup.
17 ###############################################################################
18
19 --source include/have_binlog_format_row.inc
20
21 # this test requires creating a large binlog that triggers rotation
22 # with compression turned on this is not deterministic
23 --source include/not_binlog_transaction_compression_on.inc
24 --let $MYSQLD_DATADIR= `select @@datadir`
25
26 --echo #
27 --echo # 1) Reset the master and set max_binlog_size to a smaller value 4KB.
28 --echo #
29 SET @save_max_binlog_size=@@global.max_binlog_size;
30 SET GLOBAL max_binlog_size=4096;
31 RESET MASTER;
32
33 --echo #
34 --echo # 2) Start a XA transaction which is more than max_binlog_size (4KB).
35 --echo #
36 CREATE TABLE t1(i varchar(4096));
37 XA START 'xa1';
38 INSERT INTO t1 VALUES (REPEAT('a', 4096));
39 XA END 'xa1';
40
41 --echo #
42 --echo # 3) Prepare the XA trx.
43 --echo # (trx content will be written to binlog.000001 and the binlog
44 --echo # will be rotated because of the size limit).
45 XA PREPARE 'xa1';
46
47 --echo #
48 --echo # 4) Commit the XA trx (commit will be written to binlog.000002).
49 --echo #
50 XA COMMIT 'xa1';
51
52 --echo #
53 --echo # 5) Save the binlog dump for the reapply purpose.
54 --echo #
55 --exec $MYSQL_BINLOG --force-if-open $MYSQLD_DATADIR/binlog.000001 > $MYSQLTEST_VARDIR/tmp/xa_trx_part1.sql
56 --exec $MYSQL_BINLOG --force-if-open $MYSQLD_DATADIR/binlog.000002 > $MYSQLTEST_VARDIR/tmp/xa_trx_part2.sql
57
58 --echo #
59 --echo # 6) Cleanup the server and make it ready to apply the binlog dump.
60 --echo #
61 RENAME TABLE t1 TO t2;
62 RESET MASTER;
63
64 --echo #
65 --echo # 7) Apply the binlog dump.
66 --echo #
67 --exec $MYSQL < $MYSQLTEST_VARDIR/tmp/xa_trx_part1.sql
68 --exec $MYSQL < $MYSQLTEST_VARDIR/tmp/xa_trx_part2.sql
69
70 --echo #
71 --echo # 8) Verify that the old data is restorted properly without any issues.
72 --echo #
73 --let $diff_tables=default:t1, default:t2
74 --source include/diff_tables.inc
75
76 --echo #
77 --echo # 9) Cleanup
78 --echo #
79 DROP TABLE t1,t2;
80 SET GLOBAL max_binlog_size=@save_max_binlog_size;
81 --remove_file $MYSQLTEST_VARDIR/tmp/xa_trx_part1.sql
82 --remove_file $MYSQLTEST_VARDIR/tmp/xa_trx_part2.sql