| 1 |
# |
| 2 |
# WL#5569 MTS |
| 3 |
# |
| 4 |
# The test checks cases of hashing conflicts forcing a special hanling. |
| 5 |
# The cases include |
| 6 |
# |
| 7 |
# I. two Worker jobs conflict to each other |
| 8 |
# |
| 9 |
# a. two multi-statement transactions containing more than one partition |
| 10 |
# in which one is common are mapped to different Workers. |
| 11 |
# b. similarly two autocommit queries or ddl:s |
| 12 |
# |
| 13 |
# Handling of the cases is carried out as the following: |
| 14 |
# when Coordinator hits to an occupied by not the currenly assigned Worker |
| 15 |
# partition it marks the partition and goes to wait till the Worker-owner |
| 16 |
# has released it and signaled. |
| 17 |
# |
| 18 |
# II. An event requires the sequential execution |
| 19 |
# |
| 20 |
# Coordinator does not schedule the event and is waiting till all workers have |
| 21 |
# released their partitions and signalled. |
| 22 |
|
| 23 |
--source include/not_group_replication_plugin.inc |
| 24 |
--source include/have_replica_parallel_type_database.inc |
| 25 |
--source include/master-slave.inc |
| 26 |
|
| 27 |
# |
| 28 |
# Testing with the statement format requires |
| 29 |
# @@global.slave_run_query_in_parallel = 1. |
| 30 |
# Notice, parallelization for Query-log-event is limitted |
| 31 |
# to the default dababase. That's why 'use db'. |
| 32 |
# With the default @@global.slave_run_query_in_parallel == 0 |
| 33 |
# the tests in stmt format still run to prove switching to the sequential. |
| 34 |
|
| 35 |
# TODO: convert this file into two tests for either value of |
| 36 |
# @@global.slave_run_query_in_parallel |
| 37 |
--source include/have_binlog_format_row.inc |
| 38 |
|
| 39 |
connection slave; |
| 40 |
|
| 41 |
--disable_query_log |
| 42 |
--disable_result_log |
| 43 |
call mtr.add_suppression('Error reading replica worker configuration'); |
| 44 |
--enable_query_log |
| 45 |
--enable_result_log |
| 46 |
|
| 47 |
source include/stop_slave.inc; |
| 48 |
|
| 49 |
set @save.replica_parallel_workers= @@global.replica_parallel_workers; |
| 50 |
set @@global.replica_parallel_workers= 4; |
| 51 |
|
| 52 |
source include/start_slave.inc; |
| 53 |
|
| 54 |
|
| 55 |
connection master; |
| 56 |
|
| 57 |
create database d1; |
| 58 |
create database d2; |
| 59 |
create database d3; |
| 60 |
create table d1.t1 (a int auto_increment primary key) engine=innodb; |
| 61 |
create table d2.t1 (a int auto_increment primary key) engine=innodb; |
| 62 |
create table d3.t1 (a int auto_increment primary key) engine=innodb; |
| 63 |
|
| 64 |
# |
| 65 |
|
| 66 |
# I. Two parallel jobs conflict |
| 67 |
# |
| 68 |
# two conflicting jobs to follow |
| 69 |
|
| 70 |
--source include/sync_slave_sql_with_master.inc |
| 71 |
# To be really conflicting slave needs to block commit of the first. |
| 72 |
#connection slave; |
| 73 |
|
| 74 |
begin; |
| 75 |
insert into d2.t1 values (1); |
| 76 |
|
| 77 |
connection master; |
| 78 |
|
| 79 |
# Job_1 |
| 80 |
begin; |
| 81 |
use d1; |
| 82 |
insert into d1.t1 values (null); |
| 83 |
use d2; |
| 84 |
insert into d2.t1 values (1); # will be block at this point on Worker |
| 85 |
commit; |
| 86 |
|
| 87 |
# Job_2 |
| 88 |
begin; |
| 89 |
use d3; |
| 90 |
insert into d3.t1 values (null); |
| 91 |
use d1; |
| 92 |
insert into d1.t1 values (null); # will be block at this point on Coord if no transaction compression used |
| 93 |
commit; |
| 94 |
|
| 95 |
connection slave; |
| 96 |
|
| 97 |
--echo Either the coordinator is waiting for a worker to unlock d1 |
| 98 |
--echo (binlog transaction compression OFF) or the coordinator |
| 99 |
--echo has scheduled the 2nd transaction to the sane worker (binlog |
| 100 |
--echo transaction compression ON) |
| 101 |
|
| 102 |
--let $wait_condition=SELECT COUNT(*) = 1 FROM performance_schema.data_locks WHERE object_schema="d2" AND object_name="t1" AND lock_status="WAITING" |
| 103 |
--source include/wait_condition.inc |
| 104 |
|
| 105 |
if (`SELECT @@global.binlog_transaction_compression = FALSE`) |
| 106 |
{ |
| 107 |
# |
| 108 |
# note that if no compression used, then the coordinator had |
| 109 |
# started to assign 2nd transaction to the a second worker, |
| 110 |
# since it schedules event by event (blocks when the 2nd |
| 111 |
# event for the 2nd transaction is scheduled - d1's event). |
| 112 |
# |
| 113 |
# if compression is on, then the coordinator knows beforehand |
| 114 |
# which databases a transaction is going to touch, as it inspects |
| 115 |
# the payload event and gathers all the information about the |
| 116 |
# transaction events. Then it does not wait and assigns 2nd |
| 117 |
# transaction to the worker handling d1 already. |
| 118 |
# |
| 119 |
--let $wait_condition=SELECT COUNT(*) = 1 FROM performance_schema.threads WHERE processlist_state LIKE 'Waiting for Replica Worker to release partition' AND name = 'thread/sql/replica_sql' |
| 120 |
--source include/wait_condition.inc |
| 121 |
} |
| 122 |
|
| 123 |
# release the Worker |
| 124 |
rollback; |
| 125 |
|
| 126 |
# Bug#21461991 : RPL.RPL_PARALLEL_CONFLICTS FAILS SPORADICALLY |
| 127 |
# ON DAILY AND WEEKLY TRUNK |
| 128 |
# Waits until the slave SQL thread has been synced with master |
| 129 |
connection master; |
| 130 |
--source include/sync_slave_sql_with_master.inc |
| 131 |
|
| 132 |
let $count= 2; |
| 133 |
let $table= d1.t1; |
| 134 |
source include/wait_until_rows_count.inc; |
| 135 |
|
| 136 |
|
| 137 |
# |
| 138 |
# II. The only-sequential conflicts with ongoing parallel applying |
| 139 |
# |
| 140 |
|
| 141 |
# a. DDL waits for all workers have processed their earlier scheduled assignments |
| 142 |
|
| 143 |
connection slave1; |
| 144 |
|
| 145 |
# fix the tables status. Tables are supposed to exist, possibly with data left |
| 146 |
# after previous part. |
| 147 |
|
| 148 |
select count(*) from d1.t1 into @d1; |
| 149 |
select count(*) from d2.t1 into @d2; |
| 150 |
select count(*) from d3.t1 into @d3; |
| 151 |
use d1; |
| 152 |
create table `exists_only_on_slave` (a int); |
| 153 |
|
| 154 |
connection slave; |
| 155 |
|
| 156 |
# put in the way of workers blocking load |
| 157 |
|
| 158 |
begin; |
| 159 |
insert into d1.t1 values (null); |
| 160 |
insert into d2.t1 values (null); |
| 161 |
insert into d3.t1 values (null); |
| 162 |
|
| 163 |
connection master; |
| 164 |
|
| 165 |
# Job_1 |
| 166 |
begin; |
| 167 |
use d1; |
| 168 |
insert into d1.t1 values (null); |
| 169 |
commit; |
| 170 |
|
| 171 |
# Job_2 |
| 172 |
begin; |
| 173 |
use d2; |
| 174 |
insert into d2.t1 values (null); |
| 175 |
commit; |
| 176 |
|
| 177 |
|
| 178 |
# Job_3 |
| 179 |
begin; |
| 180 |
use d3; |
| 181 |
insert into d3.t1 values (null); |
| 182 |
commit; |
| 183 |
|
| 184 |
--disable_warnings |
| 185 |
use d1; |
| 186 |
drop table if exists `exists_only_on_slave`; |
| 187 |
--enable_warnings |
| 188 |
|
| 189 |
|
| 190 |
connection slave1; |
| 191 |
|
| 192 |
select sleep(1); # give Workers a little time to process (but they won't) |
| 193 |
|
| 194 |
select count(*) - @d1 as 'zero' from d1.t1; |
| 195 |
select count(*) - @d2 as 'zero' from d2.t1; |
| 196 |
select count(*) - @d3 as 'zero' from d3.t1; |
| 197 |
|
| 198 |
# proof the master DDL has not got through |
| 199 |
use d1; |
| 200 |
select count(*) as 'zero' from `exists_only_on_slave`; |
| 201 |
|
| 202 |
connection slave; |
| 203 |
|
| 204 |
rollback; # release workers |
| 205 |
|
| 206 |
connection slave1; |
| 207 |
|
| 208 |
# to finish up with getting all committed. |
| 209 |
|
| 210 |
let $count= `select @d1 + 1`; |
| 211 |
let $table= d1.t1; |
| 212 |
source include/wait_until_rows_count.inc; |
| 213 |
|
| 214 |
let $count= `select @d2 + 1`; |
| 215 |
let $table= d2.t1; |
| 216 |
source include/wait_until_rows_count.inc; |
| 217 |
|
| 218 |
let $count= `select @d3 + 1`; |
| 219 |
let $table= d3.t1; |
| 220 |
source include/wait_until_rows_count.inc; |
| 221 |
connection slave; |
| 222 |
|
| 223 |
|
| 224 |
# |
| 225 |
# cleanup |
| 226 |
# |
| 227 |
|
| 228 |
connection master; |
| 229 |
|
| 230 |
drop database d1; |
| 231 |
drop database d2; |
| 232 |
drop database d3; |
| 233 |
|
| 234 |
--source include/sync_slave_sql_with_master.inc |
| 235 |
#connection slave; |
| 236 |
|
| 237 |
set @@global.replica_parallel_workers= @save.replica_parallel_workers; |
| 238 |
|
| 239 |
--source include/rpl_end.inc |