Debian Codegraph @

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

raw
1 # ==== Purpose ====
2 #
3 # Test verifies the truncation of single binary log file.
4 #
5 # ==== References ====
6 #
7 # MDEV-21117: recovery for --rpl-semi-sync-slave-enabled server
8
9 --source include/have_innodb.inc
10 --source include/have_aria.inc
11 # File: binlog_truncate_active_log.inc included in test makes use of
12 # 'debug_sync' facility.
13 --source include/have_debug_sync.inc
14 --source include/have_binlog_format_statement.inc
15
16 call mtr.add_suppression("Can.t init tc log");
17 call mtr.add_suppression("Aborting");
18
19 # The following cases are tested:
20 # A. 2pc transaction is followed by a blank "zero-engines" one
21 # B. 2pc transaction follows the blank one
22 # C. Similarly to A, with the XA blank transaction
23
24 RESET MASTER;
25 SET @@global.sync_binlog=1;
26 CREATE TABLE t (f INT) ENGINE=INNODB;
27 CREATE TABLE t2 (f INT) ENGINE=INNODB;
28 CREATE TABLE t4 (f INT) ENGINE=INNODB;
29 CREATE TABLE tm (f INT) ENGINE=Aria;
30
31 # Old (pre-crash) binlog file index initial value.
32 # It keeps incremented at the end of each case.
33 --let $binlog_file_index=1
34
35 --echo # Case A.
36 # Using 'debug_sync' hold 'query1' execution after 'query1' is flushed and
37 # synced to binary log but not yet committed. In an another connection hold
38 # 'query2' execution after 'query2' is flushed and synced to binlog.
39 # Crash and restart server with --init-rpl-role=SLAVE
40 #
41 # During recovery of binary log 'query1' status is checked with InnoDB engine,
42 # it will be in prepared but not yet commited. All transactions starting from
43 # 'query1' onwards will be removed from the binary log.
44 # Show-binlog-events is to prove that.
45
46 --let $truncate_gtid_pos = 0-1-7
47 --let $query1 = INSERT INTO t VALUES (20)
48 --let $query2 = DELETE FROM t2 WHERE f = 0 /* no such record */
49 --source binlog_truncate_active_log.inc
50
51 --echo # Case B.
52 # The inverted sequence ends up to truncate starting from $query2
53 --let $truncate_gtid_pos = 0-1-11
54 --let $query1 = DELETE FROM t2 WHERE f = 0
55 --let $query2 = INSERT INTO t VALUES (20)
56 --source binlog_truncate_active_log.inc
57
58
59 --echo # Case C.
60 delimiter |;
61 CREATE PROCEDURE sp_blank_xa()
62 BEGIN
63 XA START 'blank';
64 DELETE FROM t2 WHERE f = 0 /* no such record */;
65 XA END 'blank';
66 XA PREPARE 'blank';
67 END|
68 delimiter ;|
69
70 # The same as in A with $query2 being the zero-engine XA transaction.
71 # Both $query1 and $query2 are going to be truncated.
72 --let $truncate_gtid_pos = 0-1-15
73 --let $query1 = INSERT INTO t VALUES (20)
74 --let $query2 = CALL sp_blank_xa
75 --source binlog_truncate_active_log.inc
76
77 DROP PROCEDURE sp_blank_xa;
78
79
80 --echo # Case D.
81 delimiter |;
82 CREATE PROCEDURE sp_xa()
83 BEGIN
84 XA START 'xid';
85 DELETE FROM t WHERE f = 10;
86 XA END 'xid';
87 XA PREPARE 'xid';
88 END|
89 delimiter ;|
90
91 # The same as in B with $query1 being the prepared XA transaction.
92 # Truncation must occurs at $query2.
93 --let $truncate_gtid_pos = 0-1-21
94 --let $query1 = CALL sp_xa
95 --let $query2 = INSERT INTO t2 VALUES (20)
96 --source binlog_truncate_active_log.inc
97
98 DROP PROCEDURE sp_xa;
99
100
101 --echo # Cleanup
102 DROP TABLE t,t2,tm;
103 SET @@global.sync_binlog= default;
104 --echo # End of the tests