Debian Codegraph @

mysql-test/suite/rpl/t/rpl_relay_log_space_limit_net_write_timeout.test

raw
1 # ==== PURPOSE ====
2 #
3 # This test validates handling of the relay_log_space_limit by replication
4 # threads: receiver and applier coordinator. Here, we make sure that
5 # handling of the 'relay_log_space_limit' does not create a loop due to
6 # restarting the auto-positioning protocol.
7 #
8 # ==== REQUIREMENTS ====
9 #
10 # relay_log_space_limit requirements:
11 #
12 # R1. When transaction size is lower than the 'relay_log_space_limit', the
13 # replica shall use the maximum of the 'relay_log_space_limit' bytes to
14 # store transactions in the relay log.
15 # R2. When receiver writes transaction into the relay log, when the used
16 # relay log space plus the
17 # transaction size exceed the 'relay_log_space_limit', the receiver
18 # shall rotate the relay log and wait for notification that relay log
19 # space was reclaimed by the coordinator.
20 # R3. When the applier coordinator detects that the replica receiver is waiting,
21 # when outside of a group, the coordinator shall:
22 # a) wait for workers to apply scheduled jobs
23 # b) force purging the current relay log file before moving to the next file
24 # c) notify the receiver that a part of relay log space used was reclaimed
25 # R4. When transaction size is higher than the 'relay_log_space_limit', when all
26 # possible relay log files are purged, the replica shall ignore the limit
27 # and write the transaction into the relay log.
28 #
29 # test requirements:
30 #
31 # R1. When the 'relay_log_space_limit' is greater than the size of one
32 # transaction and lower than the size of two transactions, when running
33 # with GTID based replication, when the time of handling one transaction
34 # is greater that the 'net_write_timeout', the number of reconnects to the
35 # receiver shall not exceed to the number of executed transactions.
36 # R2. When a single transaction cannot fit into the 'relay_log_space_limit',
37 # when applier has purged all available logs, the 'relay_log_space_limit'
38 # shall be ignored for this transaction.
39 #
40 # ==== IMPLEMENTATION ====
41 #
42 # T1.
43 # Test steps:
44 #
45 # 0. Test setup: low value of 'net write timeout' and low value of the
46 # 'relay_log_space_limit', to make sure that:
47 # a) the 'relay_log_space_limit' is reached after writing each
48 # transaction to the relay log
49 # b) the time of handling the 'relay_log_space_limit' is greater than
50 # the 'net_write_timeout', causing the dump thread to disconnect and
51 # restart replication after each transaction
52 # c) the 'relay_log_space_limit' is able to fit one transaction and
53 # several events of the next transaction
54 # 1. Create a table
55 # 2. Generate several large transactions, containing large events
56 # 3. Run replication
57 # 4. Synchronize source and replica servers
58 # 5. Check Pass condition 1: the number of connects to the source
59 # is less than or equal to the number of transactions
60 # 6. Check Pass condition 2: test finished (no deadlock), checked
61 # automatically
62 #
63 # Test pass conditions:
64 #
65 # - step 5
66 # - step 6
67 #
68 # ==== REFERENCES ====
69 #
70 # Bug#36507020 relay_log_space_limit GTID and large txns may lead
71 # to no channel progress
72 #
73
74 --source include/big_test.inc
75
76 --source include/have_binlog_format_row.inc
77
78 --let $rpl_skip_start_slave=1
79 --source include/master-slave.inc
80
81 --echo
82 --echo # 1. Create a table
83 --echo # 2. Generate several large transactions, containing large events
84 --echo
85
86 CREATE TABLE t (a LONGBLOB) ENGINE = InnoDB;
87
88 DELIMITER %;
89
90 # Generates 'trx_count' transactions, each containing 'ev_count' events of
91 # size around 'insert_byte_count'
92 CREATE PROCEDURE gen_transactions(trx_count INT, ev_count INT, insert_byte_count INT)
93 BEGIN
94 SET @x = 0;
95 REPEAT
96 START TRANSACTION;
97 SET @ev_cnt = 0;
98 REPEAT
99 INSERT INTO t VALUES (REPEAT('a', insert_byte_count));
100 SET @ev_cnt = @ev_cnt + 1;
101 UNTIL @ev_cnt >= ev_count
102 END REPEAT;
103 COMMIT;
104 SET @x = @x + 1;
105 UNTIL @x >= trx_count
106 END REPEAT;
107 END %
108
109 DELIMITER ;%
110
111 # Generate 5 transactions, each containing 3 events ~100MiB
112 CALL gen_transactions(5, 3, 104857600);
113
114 --echo
115 --echo # 3. Run replication
116 --echo
117
118 --source include/rpl_connection_slave.inc
119 --source include/start_slave.inc
120
121 --echo
122 --echo # 4. Synchronize source and replica servers
123 --echo
124
125 --source include/rpl_connection_master.inc
126 --let $slave_timeout=3600
127 --source include/sync_slave_sql_with_master.inc
128
129 --echo
130 --echo # 5. Check Pass condition 1: the number of connects to the source
131 --echo # is less than or equal to the number of transactions
132 --echo
133
134 --let $assert_select=Replica receiver thread for channel '': connected to source
135 --let $assert_count_condition= <=5
136 --let $assert_text=Check Pass condition 1
137 --let $assert_file=$MYSQLTEST_VARDIR/log/mysqld.2.err
138 --source include/assert_grep.inc
139
140 --echo
141 --echo # Clean up
142 --echo
143
144 --source include/rpl_connection_master.inc
145 DROP TABLE t;
146 DROP PROCEDURE gen_transactions;
147 --source include/rpl_end.inc