Debian Codegraph @

mysql-test/suite/rpl_gtid/t/rpl_heartbeat_log_pos_4gb.test

raw
1 # ==== Purpose ====
2 #
3 # Verify that heartbeat events work when the position is greater than 4 GiB
4 #
5 # ==== Requirements ====
6 #
7 # R1. If a binary log size is bigger than 4 GiB then the heartbeat event
8 # emitted should contain the correct size.
9 #
10 # ==== Implementation ====
11 #
12 # 1. Start only the IO_THREAD on replica and set the SOURCE_HEARTBEAT_PERIOD to
13 # 0 in order to avoid the heartbeat_events from dump thread
14 # 2. Create table on source.
15 # 3. Sync the IO_THREAD on replica and stop the replica.
16 # 4. Execute one 4 GiB transaction on connection_1 and one small transaction
17 # on connection_2, don't commit the transactions.
18 # 5. Set up a sync point on the source to make sure that the 2
19 # transactions are committed in the same commit group, with the big
20 # transaction first and the small transaction second.
21 # 6. Reap both transactions from connection 1 and 2.
22 # 7. Verify that the gtid event in the source has the position greater than 4 GiB.
23 # 8. Start the receiver thread and make it stop after receiving the first
24 # transaction from connection 1(the 4 GiB transaction)
25 # 9. Source enables a debug symbol that makes it hit an assertion in case it
26 # sends a heartbeat event with a position smaller than 4 GiB.
27 # 10.Replica starts the IO thread again. It uses the auto-position protocol,
28 # and therefore the dump thread will emit a heartbeat event after skipping
29 # the 4 GiB transaction (in order to notify the receiver of the position).
30 # 11.Verify that we received exactly 1 heartbeat event after step 8 by
31 # inspecting performance_schema.replication_connection_status
32 # 12.Cleanup
33 #
34 # ==== References ====
35 #
36 # Bug#33615584: Add mtr test to generate heartbeat_event in 4 gb binlog file
37 # for Bug#29913991
38
39 --source include/big_test.inc
40 --source include/have_debug.inc
41 --source include/have_debug_sync.inc
42 --source include/have_binlog_format_row.inc
43
44 --let $rpl_skip_start_slave = 1
45 --let $rpl_extra_connections_per_server = 2
46 --source include/master-slave.inc
47 # 1. Start only the IO_THREAD on replica and set the SOURCE_HEARTBEAT_PERIOD to
48 # 0 in order to avoid the heartbeat_events from dump thread
49 --source include/rpl_connection_slave.inc
50 CHANGE REPLICATION SOURCE TO SOURCE_HEARTBEAT_PERIOD=0;
51 --source include/start_slave_io.inc
52
53 --source include/rpl_connection_master.inc
54 # 2. Create tables on source.
55 CREATE TABLE t (a LONGBLOB);
56 --source include/save_binlog_position.inc
57
58 # 3. Sync the IO_THREAD on replica and stop the replica
59 --source include/sync_slave_io_with_master.inc
60 --source include/stop_slave_io.inc
61
62 # 4. Execute one 4 GiB transaction on connection_1 and one small transaction
63 # on connection_2, don't commit the transaction.
64
65 # Start one transaction that is a little more than 4 GiB
66 # (actually exactly 4 GiB row data, plus a bit of per-event overhead).
67 # Split it into 128 statements, each 32 MiB, to keep within default
68 # limits.
69 --let $four_gib = `SELECT 1 << 32`
70 --let $statement_count = 128
71 --let $statement_size = `SELECT $four_gib DIV $statement_count`
72 --disable_query_log
73
74 --connection server_1_1
75 BEGIN;
76 --let $i = 0
77 while ($i < $statement_count) {
78 eval INSERT INTO t VALUES (REPEAT('a', $statement_size));
79 --inc $i
80 }
81 --enable_query_log
82 # On a different connection, start a small transaction.
83 --connection server_1_2
84 BEGIN;
85 INSERT INTO t VALUES ('Hi!');
86 # 5. Set up a sync point on the source to make sure that the 2
87 # transactions are committed in the same commit group, with the big
88 # transaction first and the small transaction second.
89
90 --let $sync_point = bgc_after_enrolling_for_flush_stage
91 --let $statement = COMMIT
92 --let $auxiliary_connection = default
93
94 --let $statement_connection = server_1_1
95 --source include/execute_to_sync_point.inc
96 --let $statement_connection = server_1_2
97 --source include/execute_to_sync_point.inc
98 # Release the transactions from their sync points.
99 --let $skip_reap = 1
100
101 --let $statement_connection = server_1_1
102 --source include/execute_from_sync_point.inc
103 --let $statement_connection = server_1_2
104 --source include/execute_from_sync_point.inc
105
106 # 6. Reap both transactions from connection 1 and 2.
107
108 --connection server_1_1
109 --reap
110 --connection server_1_2
111 --reap
112
113 # 7. Verify that the gtid event in the source has the position greater than 4 GiB.
114
115 # The binlog should contain:
116 # GTID
117 # BEGIN
118 # ( Table_map + Write_rows ) * 128
119 # Xid
120 # GTID
121 # BEGIN
122 # Table_map + Write_rows
123 # Xid
124 # So the second GTID is the (2 + 2 * 128 + 1 + 1)'st event.
125 --let $second_gtid_type = query_get_value("SHOW BINLOG EVENTS IN '$binlog_file' FROM $binlog_position LIMIT 259, 1", Event_type, 1)
126 --let $assert_cond = "$second_gtid_type" = "Gtid"
127 --let $assert_text = The event we think is the second GTID, should actually be the second GTID
128 --source include/assert.inc
129
130 --let $second_gtid_position = query_get_value("SHOW BINLOG EVENTS IN '$binlog_file' FROM $binlog_position LIMIT 259, 1", Pos, 1)
131 --let $assert_cond = $second_gtid_position > $four_gib
132 --let $assert_text = The second GTID event should have position > 4 GiB
133 --source include/assert.inc
134
135 # 8. Start the receiver thread and make it stop after receiving the first
136 # transaction from connection 1(the 4 GiB transaction)
137
138 --source include/rpl_connection_slave.inc
139 --let $rpl_after_received_events_action= stop
140 --let $rpl_event_count= 2
141 --let $rpl_count_only_event_type= Gtid
142 --source include/rpl_receive_event_count.inc
143
144 --let $rcvd_heartbeats_before= query_get_value(select count_received_heartbeats from performance_schema.replication_connection_status, count_received_heartbeats, 1)
145
146 # 9. Source enables a debug symbol that makes it hit an assertion in case it
147 # sends a heartbeat event with a position smaller than 4 GiB.
148
149 --source include/rpl_connection_master.inc
150 --let $debug_point = heartbeat_event_with_position_greater_than_4_gb
151 --source include/add_debug_point.inc
152
153 # 10. Replica starts the IO thread again. It uses the auto-position protocol,
154 # and therefore the dump thread will emit a heartbeat event after skipping
155 # the 4 GiB transaction (in order to notify the receiver of the position).
156
157 --source include/rpl_connection_slave.inc
158 --source include/start_slave_io.inc
159 --source include/rpl_connection_master.inc
160 --source include/sync_slave_io_with_master.inc
161
162 # 11.Verify that we received exactly 1 heartbeat event after step 8 by
163 # inspecting performance_schema.replication_connection_status
164 --let $rcvd_heartbeats_after= query_get_value(select count_received_heartbeats from performance_schema.replication_connection_status, count_received_heartbeats, 1)
165
166 --let $result= query_get_value(SELECT ($rcvd_heartbeats_after - $rcvd_heartbeats_before) AS Result, Result, 1)
167 --let $assert_cond = $rcvd_heartbeats_after - $rcvd_heartbeats_before = 1
168 --let $assert_text = Exactly 1 heartbeat event occurred
169 --source include/assert.inc
170
171 # 12. Cleanup
172 --source include/rpl_connection_master.inc
173 --let $debug_point = heartbeat_event_with_position_greater_than_4_gb
174 --source include/remove_debug_point.inc
175 DROP TABLE t;
176
177 --let $rpl_only_running_threads = 1
178 --source include/rpl_end.inc