Debian Codegraph @

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

raw
1 #Want to skip this test from daily Valgrind execution
2 --source include/no_valgrind_without_big.inc
3 # ==== Purpose ====
4 #
5 # Stress-test concurrent re-execution of transactions generated with
6 # GTID_MODE = ON.
7 #
8 # ==== Implementation ====
9 #
10 # 1. Generate a load on the master consisting of:
11 # - transactions (INSERT/UPDATE/DELETE)
12 # - DDL (ALTER and RENAME)
13 # - FLUSH LOGS
14 # Do not replicate anything.
15 #
16 # 2. Apply the binary logs on the slave (which is fresh). The binary
17 # logs are applied in N parallel connections. In addition, for
18 # increased concurrency, we open N concurrent connections that
19 # repeatedly execute SHOW SLAVE STATUS, and N concurrent
20 # connections that repeatedly read @@GLOBAL.GTID_EXECUTED and
21 # @@GLOBAL.GTID_PURGED.
22 #
23 # 3. Check that master and slave have the same data.
24 #
25 # ==== References ====
26 #
27 # Implemented as part of WL#3584: Global Transaction Identifiers
28
29 --source include/not_group_replication_plugin.inc
30 --source include/not_rpl_gtid_only.inc
31 --source include/big_test.inc
32 --source include/not_windows.inc
33 --source include/not_have_privilege_checks_user.inc
34 --source include/master-slave.inc
35
36 --echo ==== Configure ====
37
38 --let $max_iterations= 10000
39 --let $max_seconds= 100
40 --let $n_forks= 8
41 --let $flush_probability= 0.05
42 --let $rename_probability= 0.1
43
44 --echo ==== Initialize ====
45
46 --enable_connect_log
47 --connection slave
48 --source include/stop_slave.inc
49
50 --delimiter |
51 CREATE PROCEDURE show_slave_status ()
52 BEGIN
53 DECLARE name VARCHAR(100) DEFAULT('');
54 WHILE name = '' DO
55 SHOW SLAVE STATUS;
56 SELECT TABLE_NAME INTO name
57 FROM INFORMATION_SCHEMA.TABLES
58 WHERE TABLE_NAME = 't_end';
59 END WHILE;
60 END|
61
62 CREATE PROCEDURE read_gtid_executed ()
63 BEGIN
64 DECLARE name VARCHAR(100) DEFAULT('');
65 DECLARE temp VARCHAR(10000) DEFAULT('');
66 WHILE name = '' DO
67 SET temp = @@GLOBAL.GTID_EXECUTED;
68 SET temp = @@GLOBAL.GTID_OWNED;
69 SELECT TABLE_NAME INTO name
70 FROM INFORMATION_SCHEMA.TABLES
71 WHERE TABLE_NAME = 't_end';
72 END WHILE;
73 END|
74 --delimiter ;
75
76 --connection master
77
78 --let $t= 1
79 eval CREATE TABLE t1_$t (a INT) ENGINE = InnoDB;
80 eval CREATE TABLE t2_$t (a INT) ENGINE = InnoDB;
81 eval INSERT INTO t1_$t VALUES (0);
82 eval INSERT INTO t2_$t VALUES (0);
83
84 --echo ==== Generate binary log ====
85
86 --let $iteration= 1
87 --let $start_time= `SELECT UNIX_TIMESTAMP()`
88 --let $done= 0
89 --disable_query_log
90 while (!$done)
91 {
92 --let $rand_type= decide
93 --let $rand_probability= $rename_probability
94 --source include/rand.inc
95 if ($rand)
96 {
97 --let $last_t= $t
98 --inc $t
99 eval ALTER TABLE t1_$last_t RENAME TO t1_$t;
100 eval RENAME TABLE t2_$last_t TO t2_$t;
101 }
102 BEGIN;
103 eval INSERT INTO t2_$t VALUES ($iteration);
104 eval UPDATE t1_$t SET a = $iteration WHERE a = $iteration - 1;
105 eval DELETE FROM t2_$t WHERE a = $iteration - 1;
106 COMMIT;
107
108 --let $rand_type= decide
109 --let $rand_probability= $flush_probability
110 --source include/rand.inc
111 if ($rand)
112 {
113 FLUSH LOGS;
114 }
115 --inc $iteration
116
117 if ($iteration >= $max_iterations)
118 {
119 --let $done= 1
120 }
121 if (`SELECT UNIX_TIMESTAMP() - $start_time > $max_seconds`)
122 {
123 --let $done= 1
124 }
125 }
126 --enable_query_log
127 CREATE TABLE t_end (a INT);
128
129 --echo ==== Apply the generated binary logs ====
130
131 --let $binlog_file= query_get_value(SHOW MASTER STATUS, File, 1)
132 --let $data_dir= `SELECT @@datadir`
133 --let _BINLOG_FILE= $data_dir/$binlog_file
134 --let _N_FORKS= $n_forks
135
136 perl;
137 my $mysql_pipe= "| $ENV{MYSQL} --defaults-group-suffix=.2";
138 my $file= $ENV{_BINLOG_FILE};
139 $file=~ s/0*([1-9][0-9]*)$//;
140 my $number= $1;
141 my @mysqlbinlog_commands=
142 map { sprintf("$ENV{MYSQL_BINLOG} %s%06d", $file, $_) } 1 .. $number;
143 my $n_forks= $ENV{_N_FORKS};
144 my $n= $n_forks;
145 my @cmd_lists= ( [ 'echo "USE test; CALL show_slave_status();"' ],
146 [ 'echo "USE test; CALL read_gtid_executed();"' ],
147 \@mysqlbinlog_commands,
148 \@mysqlbinlog_commands );
149 $n-- while $n && fork;
150 my $cmd_list= $cmd_lists[$n % @cmd_lists];
151 for my $cmd (@$cmd_list)
152 {
153 # discard stdout from $cmd (redirect to /dev/null is not portable)
154 `$cmd $mysql_pipe`;
155 $? == 0 or die "Error executing running $cmd (n=$n): $!";
156 }
157 EOF
158
159 --echo ==== Wait for load to finish ====
160
161 --connection slave
162 --let $show_statement= SHOW TABLES;
163 --let $field= Tables_in_test
164 --let $condition= t_end
165 --source include/wait_show_condition.inc
166
167 --echo ==== Check result ====
168
169 --let $diff_tables= master:t1_$t, master:t2_$t, slave:t1_$t, slave:t2_$t
170 --let $diff_tables_silent= 1
171 --source include/diff_tables.inc
172
173 --echo ==== Clean up ====
174
175 --connection master
176 --disable_query_log
177 eval DROP TABLE t1_$t, t2_$t;
178 --enable_query_log
179 DROP TABLE t_end;
180
181 --connection slave
182 --disable_query_log
183 eval DROP TABLE t1_$t, t2_$t;
184 --enable_query_log
185 DROP TABLE t_end;
186 DROP PROCEDURE show_slave_status;
187 DROP PROCEDURE read_gtid_executed;
188 CHANGE REPLICATION SOURCE TO SOURCE_AUTO_POSITION= 0;