Debian Codegraph @

mysql-test/suite/group_replication/t/gr_flush_relay_log_no_split_trx.test

raw
1 # ==== Purpose ====
2 #
3 # The purpose of this script is to test that a `FLUSH RELAY LOG` doesn't split
4 # transactions among two different relay logs.
5 #
6 # ==== Requirements ====
7 #
8 # R1. A request for flushing the relay logs WILL be postponed if there is an
9 # ongoing transaction.
10 #
11 # R2. Once the given ongoing transaction comes to an end, the relay logs MUST be
12 # flushed.
13 #
14 # R3. The client or channel that requested the relay logs flush MUST be blocked
15 # and in wait until the actual flush is finished.
16 #
17 # ==== Implementation ====
18 #
19 # 1) Add a debug sync point that holds and makes the applier thread to wait, in
20 # the middle of a transaction - `signal.rpl_requested_for_a_flush` in
21 # `rpl_replica.cc:queue_event`.
22 # 2) Execute some statements in the master.
23 # 3) Retrieve the number of the relay log file with the highest index number.
24 # 4) Make the `FLUSH RELAY LOG` execution path to emit
25 # `signal.rpl_requested_for_a_flush` right before waiting on the transaction
26 # to end - in `rpl_info.cc:Rpl_info::request_rotate`.
27 # 5) Execute `FLUSH RELAY LOG` in the slave.
28 # 6) Add a debug sync point that holds the test execution and waits for the
29 # flush to terminate - `signal.rpl_broadcasted_rotate_end`.
30 # 7) Make the applier execution path to emit `signal.rpl_broadcasted_rotate_end`
31 # just after finishing processing the deferred flushing of the relay log - in
32 # `rpl_info.cc:Rpl_info::clear_rotate_requests`.
33 # 8) Retrieve the number of the relay log file with the highest index number and
34 # assert that the highest index number before the `FLUSH RELAY LOG` execution
35 # is lower than the highest index number after.
36 # 9) Assert that the statements that blocked the relay log rotation are not in
37 # the new relay log.
38 # 10) Ensure that all statements were executed on the slave.
39 #
40 # ==== References ====
41 #
42 # BUG#28684376 MAKE GR REPLICATION CHANNELS ROTATE RELAY LOG ON FLUSH LOGS
43 #
44
45 --source include/have_debug.inc
46 --source include/have_debug_sync.inc
47 --source include/have_group_replication_plugin.inc
48 --source include/group_replication.inc
49
50 --let $rpl_connection_name = server1
51 --source include/rpl_connection.inc
52 CREATE TABLE t1 (i INT PRIMARY KEY);
53 --source include/rpl_sync.inc
54
55 # 1) Add a debug sync point that holds and makes the applier thread to wait, in
56 # the middle of a transaction - `signal.rpl_requested_for_a_flush` in
57 # `rpl_replica.cc:queue_event`.
58 --let $rpl_connection_name = server2
59 --source include/rpl_connection.inc
60 SET GLOBAL debug = '+d,wait_in_the_middle_of_trx,deferred_flush_relay_log';
61
62 # 2) Execute some statements in the master.
63 --let $rpl_connection_name = server1
64 --source include/rpl_connection.inc
65 BEGIN;
66 INSERT INTO t1 VALUES(1);
67 INSERT INTO t1 VALUES(2);
68 COMMIT;
69
70 --let $rpl_connection_name = server2
71 --source include/rpl_connection.inc
72
73 # 3) Retrieve the number of the relay log file with the highest index number.
74 --let $pattern_to_match = $MYSQLTEST_VARDIR/mysqld.2/data/*relay*.*
75 --source include/rpl_log_file_max_number.inc
76 --let $max_log_file_before_flush = $log_file_max_number
77
78 # 5) Execute `FLUSH RELAY LOG` in the slave.
79 FLUSH RELAY LOGS;
80
81 # 6) Add a debug sync point that holds the test execution and waits for the
82 # flush to terminate - `signal.rpl_broadcasted_rotate_end`.
83 SET DEBUG_SYNC = "now WAIT_FOR signal.rpl_broadcasted_rotate_end";
84
85 # 8) Retrieve the number of the relay log file with the highest index number and
86 # assert that the highest index number before the `FLUSH RELAY LOG` execution
87 # is lower than the highest index number after.
88 --source include/rpl_log_file_max_number.inc
89 --let $max_log_file_after_flush = $log_file_max_number
90
91 --let $assert_text = 'FLUSH RELAY LOGS' rotated properly
92 --let $assert_cond = $max_log_file_before_flush < $max_log_file_after_flush
93 --source include/assert.inc
94
95 # 9) Assert that the statements that blocked the relay log rotation are not in
96 # the new relay log.
97 --let $relay_lof_file = $MYSQLTEST_VARDIR/mysqld.2/data/server-relay-log-group_replication_applier.$log_file_max_extension
98 --let $relay_log_dump = `SELECT CONCAT('$MYSQLTEST_VARDIR/tmp/flush_relay_log_', UUID(), '.dump')`
99
100 --exec $MYSQL_BINLOG --force-if-open -vv $relay_lof_file > $relay_log_dump
101
102 --let $assert_select = (BEGIN|Write_rows|COMMIT)
103 --let $assert_file = $relay_log_dump
104 --let $assert_text = No 'BEGIN|INSERT|COMMIT' in relay log
105 --let $assert_count = 0
106 --source include/assert_grep.inc
107
108 --let $rpl_connection_name = server1
109 --source include/rpl_connection.inc
110 --source include/rpl_sync.inc
111
112 # 10) Ensure that all statements were executed on the slave.
113 --let $diff_tables = server1:t1, server2:t1
114 --source include/diff_tables.inc
115
116 # Clean up
117 --let $rpl_connection_name = server2
118 --source include/rpl_connection.inc
119 SET DEBUG_SYNC = "reset";
120 SET GLOBAL debug = '-d,wait_in_the_middle_of_trx,deferred_flush_relay_log';
121
122 --remove_file $relay_log_dump
123
124 --let $rpl_connection_name = server1
125 --source include/rpl_connection.inc
126 DROP TABLE t1;
127 --source include/group_replication_end.inc