| 1 |
# |
| 2 |
# WL#5569 MTS |
| 3 |
# |
| 4 |
# The test verifies correctness of Query events parallelization. |
| 5 |
# |
| 6 |
|
| 7 |
--source include/not_group_replication_plugin.inc |
| 8 |
--source include/have_binlog_format_statement.inc |
| 9 |
--source include/master-slave.inc |
| 10 |
|
| 11 |
call mtr.add_suppression('Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT.'); |
| 12 |
|
| 13 |
let $temp_tables= 16; |
| 14 |
let $workers= 4; |
| 15 |
|
| 16 |
connection slave; |
| 17 |
|
| 18 |
flush status; # to nullify Replica_open_temp_tables |
| 19 |
|
| 20 |
# restart in Parallel |
| 21 |
source include/stop_slave.inc; |
| 22 |
set @save.replica_parallel_workers= @@global.replica_parallel_workers; |
| 23 |
eval set @@global.replica_parallel_workers= $workers; |
| 24 |
|
| 25 |
source include/start_slave.inc; |
| 26 |
|
| 27 |
# Two connections each create 2 db:s a regular table and a set of temp tables. |
| 28 |
# The temp tables contribute content to the regular tables. |
| 29 |
# In the end there must be consistent data on both sides. |
| 30 |
|
| 31 |
connection master; |
| 32 |
|
| 33 |
let $n= `select round($workers/2)`; |
| 34 |
let $n1= `select $n`; |
| 35 |
while ($n) |
| 36 |
{ |
| 37 |
eval create database d$n1; |
| 38 |
eval use d$n1; |
| 39 |
eval create table d$n1.t1 (a int auto_increment primary key, b int) engine=innodb; |
| 40 |
let $i= $temp_tables; |
| 41 |
|
| 42 |
--disable_query_log |
| 43 |
while($i) |
| 44 |
{ |
| 45 |
let $temp_rows= `select round(rand()*$temp_tables) + 1`; |
| 46 |
let $k= $temp_rows; |
| 47 |
# create makes a table in explicit db |
| 48 |
eval create temporary table d$n1.tt_$i (a int auto_increment primary key); |
| 49 |
while($k) |
| 50 |
{ |
| 51 |
eval insert into tt_$i values (null); |
| 52 |
dec $k; |
| 53 |
} |
| 54 |
dec $i; |
| 55 |
} |
| 56 |
--enable_query_log |
| 57 |
|
| 58 |
let $j= `select floor(rand()*$temp_tables) + 1`; |
| 59 |
--replace_regex /tt_.*/tt_##/ |
| 60 |
eval insert into d$n1.t1 (b) select count(*) from tt_$j; |
| 61 |
dec $n; |
| 62 |
dec $n1; |
| 63 |
} |
| 64 |
|
| 65 |
connection master1; |
| 66 |
|
| 67 |
let $n= `select round($workers/2)`; |
| 68 |
let $n1= `select 2*$n`; |
| 69 |
while ($n) |
| 70 |
{ |
| 71 |
eval create database d$n1; |
| 72 |
eval use d$n1; |
| 73 |
eval create table d$n1.t1 (a int auto_increment primary key, b int) engine=innodb; |
| 74 |
let $i= $temp_tables; |
| 75 |
|
| 76 |
--disable_query_log |
| 77 |
while($i) |
| 78 |
{ |
| 79 |
let $temp_rows= `select round(rand()*$temp_tables) + 1`; |
| 80 |
let $k= $temp_rows; |
| 81 |
# create makes a table in the default db |
| 82 |
eval create temporary table tt_$i (a int auto_increment primary key); |
| 83 |
while($k) |
| 84 |
{ |
| 85 |
eval insert into tt_$i values (null); |
| 86 |
dec $k; |
| 87 |
} |
| 88 |
dec $i; |
| 89 |
} |
| 90 |
--enable_query_log |
| 91 |
|
| 92 |
let $j= `select floor(rand()*$temp_tables) + 1`; |
| 93 |
--replace_regex /tt_.*/tt_##/ |
| 94 |
eval insert into d$n1.t1 (b) select count(*) from tt_$j; |
| 95 |
dec $n; |
| 96 |
dec $n1; |
| 97 |
} |
| 98 |
|
| 99 |
--source include/sync_slave_sql_with_master.inc |
| 100 |
|
| 101 |
if (`select variable_value - $workers*$temp_tables as must_be_zero from performance_schema.global_status where variable_name like 'Replica_open_temp_tables'`) |
| 102 |
{ |
| 103 |
--let $actual_temps= `select variable_value from performance_schema.global_status where variable_name like 'Replica_open_temp_tables'` |
| 104 |
--let $exected= `select $workers*$temp_tables` |
| 105 |
--echo *** Wrong value of Replica_open_temp_tables: got $actual_temps, expected $expected *** |
| 106 |
--die |
| 107 |
} |
| 108 |
|
| 109 |
# |
| 110 |
# Consistency check |
| 111 |
# |
| 112 |
|
| 113 |
let $n = $workers; |
| 114 |
while($n) |
| 115 |
{ |
| 116 |
let $diff_tables=master:d$n.t1, slave:d$n.t1; |
| 117 |
source include/diff_tables.inc; |
| 118 |
|
| 119 |
dec $n; |
| 120 |
} |
| 121 |
|
| 122 |
# |
| 123 |
# cleanup |
| 124 |
# |
| 125 |
# All temp tables are removed explicitly. |
| 126 |
# |
| 127 |
|
| 128 |
connection master; |
| 129 |
let $n= `select round($workers/2)`; |
| 130 |
let $n1= `select $n`; |
| 131 |
while($n) |
| 132 |
{ |
| 133 |
eval use d$n1; |
| 134 |
let $i= $temp_tables; |
| 135 |
|
| 136 |
--disable_query_log |
| 137 |
while($i) |
| 138 |
{ |
| 139 |
eval drop temporary table tt_$i; |
| 140 |
dec $i; |
| 141 |
} |
| 142 |
--enable_query_log |
| 143 |
dec $n; |
| 144 |
dec $n1; |
| 145 |
} |
| 146 |
|
| 147 |
let $n= `select round($workers/2)`; |
| 148 |
let $n1= `select $n`; |
| 149 |
while ($n) |
| 150 |
{ |
| 151 |
eval drop database d$n1; |
| 152 |
dec $n; |
| 153 |
dec $n1; |
| 154 |
} |
| 155 |
|
| 156 |
connection master1; |
| 157 |
|
| 158 |
let $n= `select round($workers/2)`; |
| 159 |
let $n1= `select 2*$n`; |
| 160 |
while ($n) |
| 161 |
{ |
| 162 |
eval use d$n1; |
| 163 |
let $i= $temp_tables; |
| 164 |
--disable_query_log |
| 165 |
while($i) |
| 166 |
{ |
| 167 |
eval drop temporary table tt_$i; |
| 168 |
dec $i; |
| 169 |
} |
| 170 |
--enable_query_log |
| 171 |
dec $n; |
| 172 |
dec $n1; |
| 173 |
} |
| 174 |
|
| 175 |
--source include/sync_slave_sql_with_master.inc |
| 176 |
#connection slave; |
| 177 |
|
| 178 |
connection master1; |
| 179 |
disconnect master1; |
| 180 |
|
| 181 |
# |
| 182 |
# Clean-up |
| 183 |
# |
| 184 |
|
| 185 |
connection master; |
| 186 |
|
| 187 |
let $n= `select round($workers/2)`; |
| 188 |
let $n1= `select 2*$n`; |
| 189 |
while ($n) |
| 190 |
{ |
| 191 |
eval drop database d$n1; |
| 192 |
dec $n; |
| 193 |
dec $n1; |
| 194 |
} |
| 195 |
|
| 196 |
--source include/sync_slave_sql_with_master.inc |
| 197 |
source include/stop_slave.inc; |
| 198 |
|
| 199 |
--disable_warnings |
| 200 |
set @@global.replica_parallel_workers= @save.replica_parallel_workers; |
| 201 |
--enable_warnings |
| 202 |
CHANGE REPLICATION SOURCE TO SOURCE_AUTO_POSITION= 0; |
| 203 |
--let $rpl_only_running_threads= 1 |
| 204 |
--source include/rpl_end.inc |