Debian Codegraph @

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

raw
1 # ==== Purpose ====
2 #
3 # This test will generate a random workload on master and will
4 # assert that all generated transactions have the correct transaction
5 # length on both master and slave binary logs.
6 #
7 # On a first step, the test will generate the transactions varying
8 # both the amount of inserts per transaction and the size of the
9 # per statement value to be inserted.
10 #
11 # On a second step, the test will also generate a SAVEPOINT, insert
12 # some more random data, will ROLLBACK TO SAVE POINT and will insert
13 # more random data again. This should test that we can remove content
14 # from the binary log cache and add content again to it without
15 # compromising the transaction length feature.
16 #
17 # On a third step, the test will generate the transactions parallely.
18 # This will test that transaction length feature wont get affected
19 # when multiple transactions are getting committed parallely. Also in
20 # MTS mode the test will check that transaction length feature wont
21 # get affected when two MTS workers are executing transactions
22 # parallely.
23 #
24 # On a fourth step, the test will do the transactions which will
25 # initiate the TRIGGER which does DML operations. This should test
26 # that transaction length will be correctly evaluated for the
27 # transactions executed by the TRIGGER.
28 #
29 # ==== Related Bugs and Worklogs ====
30 #
31 # WL#10493: Add transaction length to gtid_log_event
32 #
33 --source include/set_privilege_checks_user_as_system_user.inc
34 --source include/master-slave.inc
35
36 # this test uses large transactions, tence cannot use compression
37 --source include/not_binlog_transaction_compression_on.inc
38
39 --echo ###################################################
40 --echo # Step 1 #
41 --echo ###################################################
42 --let $transactions=200
43 CREATE TABLE t1 (c1 INT AUTO_INCREMENT PRIMARY KEY, c2 LONGTEXT);
44 --echo Generating $transactions transactions on master
45 --disable_query_log
46 while ($transactions)
47 {
48 --let $inserts=`SELECT FLOOR(1 + RAND() * 9)`
49 BEGIN;
50 while ($inserts)
51 {
52 --let $string_size=`SELECT FLOOR(1 + RAND() * 65534)`
53 # Make the last transaction having at least one huge event
54 if ($transactions == 1)
55 {
56 if ($inserts == 1)
57 {
58 --let $string_size=`SELECT FLOOR(16777216 + RAND() * 65534)`
59 }
60 }
61 --eval INSERT INTO t1 (c2) VALUES (REPEAT("X", $string_size))
62 --dec $inserts
63 }
64 COMMIT;
65 --dec $transactions
66 }
67 --enable_query_log
68 DROP TABLE t1;
69
70 --echo ###################################################
71 --echo # Step 2 #
72 --echo ###################################################
73 --let $transactions=200
74 CREATE TABLE t2 (c1 INT AUTO_INCREMENT PRIMARY KEY, c2 TEXT);
75 --echo Generating $transactions transactions on master using SAVEPOINT/ROLLBACK TO SAVEPOINT
76 --disable_query_log
77 while ($transactions)
78 {
79 --let $inserts_before_savepoint=`SELECT FLOOR(1 + RAND() * 9)`
80 --let $inserts_after_savepoint=`SELECT FLOOR(1 + RAND() * 9)`
81 --let $inserts_after_rollback=`SELECT FLOOR(1 + RAND() * 9)`
82 BEGIN;
83 while ($inserts_before_savepoint)
84 {
85 --let $string_size=`SELECT FLOOR(1 + RAND() * 65534)`
86 --eval INSERT INTO t2 (c2) VALUES (REPEAT("X", $string_size))
87 --dec $inserts_before_savepoint
88 }
89 SAVEPOINT `a`;
90 while ($inserts_after_savepoint)
91 {
92 --let $string_size=`SELECT FLOOR(1 + RAND() * 65534)`
93 --eval INSERT INTO t2 (c2) VALUES (REPEAT("X", $string_size))
94 --dec $inserts_after_savepoint
95 }
96 ROLLBACK TO SAVEPOINT `a`;
97 while ($inserts_after_rollback)
98 {
99 --let $string_size=`SELECT FLOOR(1 + RAND() * 65534)`
100 --eval INSERT INTO t2 (c2) VALUES (REPEAT("X", $string_size))
101 --dec $inserts_after_rollback
102 }
103 COMMIT;
104 --dec $transactions
105 }
106 --enable_query_log
107 DROP TABLE t2;
108
109 --echo ###################################################
110 --echo # Step 3 #
111 --echo ###################################################
112
113 --let $transactions=50
114 --let $number=`SELECT $transactions*2`
115
116 --disable_query_log
117 DELIMITER $$;
118 CREATE PROCEDURE dml(X INT)
119 BEGIN
120 WHILE X>0 do
121 INSERT INTO t3 VALUES (X);
122 SET X=X-1;
123 END WHILE;
124 DROP TABLE t3;
125 END$$
126 DELIMITER ;$$
127 --enable_query_log
128
129 CREATE TABLE t3 (a int);
130 CREATE DATABASE db1;
131 CREATE TABLE db1.t4 (c1 INT AUTO_INCREMENT PRIMARY KEY, c2 TEXT);
132
133 --echo Generating $number transactions on master parallely.
134
135 --send_eval CALL dml($transactions)
136
137 --source include/rpl_connection_master1.inc
138
139 --disable_query_log
140 while ($transactions)
141 {
142 --let $inserts=`SELECT FLOOR(1 + RAND() * 9)`
143 BEGIN;
144 while ($inserts)
145 {
146 --let $string_size=`SELECT FLOOR(1 + RAND() * 65534)`
147 --eval INSERT INTO db1.t4 (c2) VALUES (REPEAT("X", $string_size))
148 --dec $inserts
149 }
150 COMMIT;
151 --dec $transactions
152 }
153 --enable_query_log
154 DROP DATABASE db1;
155
156 --source include/rpl_connection_master.inc
157 --reap
158 DROP PROCEDURE dml;
159
160 --echo ###################################################
161 --echo # Step 4 #
162 --echo ###################################################
163
164 --let $transactions=50
165 CREATE TABLE t5 (a int);
166 CREATE TABLE t6 (a int);
167
168 DELIMITER $$;
169
170 CREATE TRIGGER tr_1 BEFORE INSERT ON t5 FOR EACH ROW
171 BEGIN
172 INSERT INTO t6 VALUES (1);
173 END$$
174
175 DELIMITER ;$$
176
177 --echo Generating $transactions transactions on master which initiates the TRIGGER.
178
179 --disable_query_log
180 while ($transactions)
181 {
182 --eval INSERT INTO t5 values ($transactions)
183 --dec $transactions
184 }
185 --enable_query_log
186
187 DROP TABLE t5;
188 DROP TABLE t6;
189
190 --source include/sync_slave_sql_with_master.inc
191
192 # Assert the transaction length in all slave log files
193 --source include/assert_transaction_length_all_logs.inc
194 # Assert the transaction length in all master log files
195 --source include/rpl_connection_master.inc
196 --source include/assert_transaction_length_all_logs.inc
197 --source include/rpl_end.inc