| 1 |
# |
| 2 |
# Include file for testing ndb$epoch and ndb$epoch2 conflict functions |
| 3 |
# |
| 4 |
# |
| 5 |
|
| 6 |
if ($extended_exceptions_table) |
| 7 |
{ |
| 8 |
--disable_query_log |
| 9 |
call mtr.add_suppression("Replica: exceptions table .* has suspicious definition .*"); |
| 10 |
--enable_query_log |
| 11 |
} |
| 12 |
|
| 13 |
if (!$extended_exceptions_table) |
| 14 |
{ |
| 15 |
create table `test`.`t1$EX` |
| 16 |
(server_id int unsigned, |
| 17 |
master_server_id int unsigned, |
| 18 |
master_epoch bigint unsigned, |
| 19 |
count int unsigned, |
| 20 |
a int not null, |
| 21 |
d int, |
| 22 |
primary key(server_id, master_server_id, master_epoch, count)) engine ndb; |
| 23 |
} |
| 24 |
if ($extended_exceptions_table) |
| 25 |
{ |
| 26 |
create table `test`.`t1$EX` |
| 27 |
(ndb$server_id int unsigned, |
| 28 |
ndb$master_server_id int unsigned, |
| 29 |
ndb$master_epoch bigint unsigned, |
| 30 |
ndb$count int unsigned, |
| 31 |
a int not null, |
| 32 |
b$old varchar(255), |
| 33 |
b$new varchar(255), |
| 34 |
d int, |
| 35 |
ndb$op_type enum('write_row','update_row', 'delete_row') not null, |
| 36 |
ndb$cft_cause enum('row_does_not_exist','row_already_exists','data_in_conflict','trans_in_conflict') not null, |
| 37 |
ndb$orig_transid bigint unsigned not null, |
| 38 |
primary key(ndb$server_id, ndb$master_server_id, ndb$master_epoch, ndb$count)) engine ndb; |
| 39 |
} |
| 40 |
|
| 41 |
--echo Create table |
| 42 |
create table test.t1(a int primary key, b varchar(255)) engine = ndb; |
| 43 |
|
| 44 |
--echo Create other table |
| 45 |
create table test.t2(a int primary key, b int) engine = ndb; |
| 46 |
|
| 47 |
--source suite/ndb_rpl/t/ndb_conflict_info_init.inc |
| 48 |
|
| 49 |
--echo ---------------------------------- |
| 50 |
--echo Test 1 : Basic two-way replication |
| 51 |
--echo ---------------------------------- |
| 52 |
|
| 53 |
insert into test.t1 values (1, "Metropole"); |
| 54 |
|
| 55 |
# Here we want to verify that updates can originate at the Secondary without |
| 56 |
# causing conflicts |
| 57 |
# We first insert on the Primary, allow that to propagate, then update on |
| 58 |
# the secondary. |
| 59 |
# This is much complicated by the fact that we run with varying number of |
| 60 |
# extra GCI bits, from 0 to 31. With 0 extra GCI bits, the row's GCI appears |
| 61 |
# to be GCIhi|0xffffffff, which means that all secondary initiated changes |
| 62 |
# will be considered in-conflict until the MaxReplicatedEpoch hits GCIhi+1|0 |
| 63 |
# To make this test stable, we use a loop to check for this condition! |
| 64 |
|
| 65 |
--source suite/ndb_rpl/t/ndb_sync_primary_to_secondary.inc |
| 66 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 67 |
FLUSH LOGS; |
| 68 |
--source suite/ndb_rpl/t/ndb_sync_secondary_to_primary.inc |
| 69 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 70 |
|
| 71 |
--echo -- Verify that Max rep epoch has been updated |
| 72 |
|
| 73 |
--disable_query_log |
| 74 |
--disable_result_log |
| 75 |
SELECT @MaxRepGCIHI:=Variable_Value >> 32 |
| 76 |
FROM performance_schema.global_status |
| 77 |
WHERE Variable_Name like 'Ndb_slave_max_replicated_epoch'; |
| 78 |
|
| 79 |
SELECT @MaxRepGCIHI = 0; |
| 80 |
|
| 81 |
--let $first_gcihi = `SELECT @MaxRepGCIHI` |
| 82 |
--let $current_gcihi = $first_gcihi |
| 83 |
--let $different = `SELECT $current_gcihi - $first_gcihi` |
| 84 |
|
| 85 |
#--echo Difference is $different |
| 86 |
|
| 87 |
while (!$different) |
| 88 |
{ |
| 89 |
# Do something, sleep a little, and see if we've ticked over GCIhi yet |
| 90 |
replace into test.t2 values(2,1); |
| 91 |
replace into test.t2 values(2,2); |
| 92 |
--sleep 1 |
| 93 |
|
| 94 |
SELECT @MaxRepGCIHI:=Variable_Value >> 32 |
| 95 |
FROM performance_schema.global_status |
| 96 |
WHERE Variable_Name like 'Ndb_slave_max_replicated_epoch'; |
| 97 |
|
| 98 |
--let $current_gcihi = `SELECT @MaxRepGCIHI` |
| 99 |
--let $different = `SELECT $current_gcihi - $first_gcihi` |
| 100 |
#--echo Current GCI Hi is $current_gcihi |
| 101 |
#--echo Difference is $different |
| 102 |
} |
| 103 |
--enable_result_log |
| 104 |
--enable_query_log |
| 105 |
|
| 106 |
--echo -- Primary Cluster Max Rep Epoch now beyond the original update epoch |
| 107 |
|
| 108 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 109 |
|
| 110 |
--echo -- Now update data on slave |
| 111 |
update test.t1 set b="Favorit" where a=1; |
| 112 |
|
| 113 |
--source suite/ndb_rpl/t/ndb_sync_secondary_to_primary.inc |
| 114 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 115 |
|
| 116 |
--echo -- Now check data on Primary |
| 117 |
select * from test.t1 order by a; |
| 118 |
|
| 119 |
--source suite/ndb_rpl/t/ndb_conflict_info.inc |
| 120 |
|
| 121 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 122 |
--echo -- Now perform multiple consecutive updates on the Secondary |
| 123 |
|
| 124 |
update test.t1 set b="Elephant house" where a=1; |
| 125 |
update test.t1 set b="Beach house" where a=1; |
| 126 |
|
| 127 |
select * from test.t1 order by a; |
| 128 |
|
| 129 |
--source suite/ndb_rpl/t/ndb_sync_secondary_to_primary.inc |
| 130 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 131 |
--echo -- Now check they've applied on the Primary |
| 132 |
select * from test.t1 order by a; |
| 133 |
|
| 134 |
--source suite/ndb_rpl/t/ndb_conflict_info.inc |
| 135 |
|
| 136 |
--echo -------------------------------------------- |
| 137 |
--echo Test 2 : Normal Insert from Secondary Master |
| 138 |
--echo -------------------------------------------- |
| 139 |
|
| 140 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 141 |
--echo -- Insert a new row on the Secondary |
| 142 |
insert into test.t1 values (2, "Forrest"); |
| 143 |
|
| 144 |
--source suite/ndb_rpl/t/ndb_sync_secondary_to_primary.inc |
| 145 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 146 |
--echo -- Check it exists on the Primary |
| 147 |
select * from test.t1 order by a; |
| 148 |
|
| 149 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 150 |
--echo -- Update from the Secondary |
| 151 |
update test.t1 set b="Reds" where a=2; |
| 152 |
|
| 153 |
--source suite/ndb_rpl/t/ndb_sync_secondary_to_primary.inc |
| 154 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 155 |
select * from test.t1 order by a; |
| 156 |
|
| 157 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 158 |
delete from test.t1 where a=2; |
| 159 |
|
| 160 |
--source suite/ndb_rpl/t/ndb_sync_secondary_to_primary.inc |
| 161 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 162 |
select * from test.t1 order by a; |
| 163 |
|
| 164 |
--source suite/ndb_rpl/t/ndb_conflict_info.inc |
| 165 |
|
| 166 |
# Allow reflected Ndb$Epoch2 ops to propagate back to |
| 167 |
# Secondary before starting the next test. |
| 168 |
--source suite/ndb_rpl/t/ndb_sync_primary_to_secondary.inc |
| 169 |
|
| 170 |
|
| 171 |
--echo ------------------------------- |
| 172 |
--echo Test 3 : Insert-Insert conflict |
| 173 |
--echo ------------------------------- |
| 174 |
|
| 175 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 176 |
stop slave; |
| 177 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 178 |
|
| 179 |
--echo -- Insert a row on the Primary Master |
| 180 |
insert into test.t1 values (2, "Loopy Lornas"); |
| 181 |
|
| 182 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 183 |
--echo -- Insert a row on the secondary Master |
| 184 |
insert into test.t1 values (2, "Cloisters"); |
| 185 |
|
| 186 |
--source suite/ndb_rpl/t/ndb_sync_secondary_to_primary.inc |
| 187 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 188 |
--echo -- Examine data on Primary Master (should be unaffected) |
| 189 |
select * from test.t1 order by a; |
| 190 |
|
| 191 |
--echo -- Examine conflict indicators on Primary Master |
| 192 |
--source suite/ndb_rpl/t/ndb_conflict_info.inc |
| 193 |
|
| 194 |
--echo -- Examine data on isolated secondary Master (should be as-set) |
| 195 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 196 |
select * from test.t1 order by a; |
| 197 |
|
| 198 |
--echo -- Restart secondary Masters slave |
| 199 |
start slave; |
| 200 |
|
| 201 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 202 |
--source suite/ndb_rpl/t/ndb_sync_primary_to_secondary.inc |
| 203 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 204 |
|
| 205 |
--echo -- Reexamine secondary Master's data (should be same as Primary Masters) |
| 206 |
select * from test.t1 order by a; |
| 207 |
|
| 208 |
--echo ------------------------------- |
| 209 |
--echo Test 4 : Update-Update conflict |
| 210 |
--echo ------------------------------- |
| 211 |
|
| 212 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 213 |
--echo -- Stop replication to secondary master |
| 214 |
stop slave; |
| 215 |
|
| 216 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 217 |
--echo -- Update row on Primary Master |
| 218 |
|
| 219 |
update test.t1 set b="Peters Yard" where a=2; |
| 220 |
|
| 221 |
--echo -- Show data on Primary Master |
| 222 |
|
| 223 |
select * from test.t1 order by a; |
| 224 |
--source suite/ndb_rpl/t/ndb_conflict_info.inc |
| 225 |
|
| 226 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 227 |
|
| 228 |
--echo -- Update row on Secondary Master |
| 229 |
update test.t1 set b="Toast" where a=2; |
| 230 |
|
| 231 |
--source suite/ndb_rpl/t/ndb_sync_secondary_to_primary.inc |
| 232 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 233 |
|
| 234 |
--echo -- Examine data on Primary Master - should be unaffected |
| 235 |
|
| 236 |
select * from test.t1 order by a; |
| 237 |
--source suite/ndb_rpl/t/ndb_conflict_info.inc |
| 238 |
|
| 239 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 240 |
--echo -- Check data on secondary - should be as set |
| 241 |
|
| 242 |
select * from test.t1 order by a; |
| 243 |
|
| 244 |
--echo -- Now restart slave, will re-align row |
| 245 |
start slave; |
| 246 |
|
| 247 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 248 |
--source suite/ndb_rpl/t/ndb_sync_primary_to_secondary.inc |
| 249 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 250 |
|
| 251 |
--echo -- Check that Secondary is re-aligned |
| 252 |
|
| 253 |
select * from test.t1 order by a; |
| 254 |
|
| 255 |
|
| 256 |
--echo ------------------------------- |
| 257 |
--echo Test 5 : Update-Delete conflict |
| 258 |
--echo ------------------------------- |
| 259 |
|
| 260 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 261 |
--echo -- Stop Secondary slave |
| 262 |
stop slave; |
| 263 |
|
| 264 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 265 |
--echo -- Update on Primary Master |
| 266 |
|
| 267 |
update test.t1 set b="Pear tree" where a = 2; |
| 268 |
|
| 269 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 270 |
--echo -- Delete on Secondary Master |
| 271 |
|
| 272 |
delete from test.t1 where a = 2; |
| 273 |
|
| 274 |
--source suite/ndb_rpl/t/ndb_sync_secondary_to_primary.inc |
| 275 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 276 |
|
| 277 |
--echo -- Examine data on Primary Master, should be unaffected |
| 278 |
|
| 279 |
select * from test.t1 order by a; |
| 280 |
--source suite/ndb_rpl/t/ndb_conflict_info.inc |
| 281 |
|
| 282 |
--echo -- Examine data on Secondary Master before slave restart, still missing |
| 283 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 284 |
|
| 285 |
select * from test.t1 order by a; |
| 286 |
|
| 287 |
--echo -- Restart Secondary Master slave |
| 288 |
start slave; |
| 289 |
|
| 290 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 291 |
--source suite/ndb_rpl/t/ndb_sync_primary_to_secondary.inc |
| 292 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 293 |
|
| 294 |
--echo -- Examine data on Secondary Master after slave restart, aligned with Master |
| 295 |
select * from test.t1 order by a; |
| 296 |
|
| 297 |
--echo ------------------------------- |
| 298 |
--echo Test 6 : Delete-Update conflict |
| 299 |
--echo ------------------------------- |
| 300 |
|
| 301 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 302 |
--echo -- Stop Secondary slave |
| 303 |
stop slave; |
| 304 |
|
| 305 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 306 |
--echo -- Delete on Primary Master |
| 307 |
|
| 308 |
delete from test.t1 where a=2; |
| 309 |
|
| 310 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 311 |
--echo -- Update on Secondary Master |
| 312 |
|
| 313 |
update test.t1 set b="Black pig" where a=2; |
| 314 |
|
| 315 |
--source suite/ndb_rpl/t/ndb_sync_secondary_to_primary.inc |
| 316 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 317 |
|
| 318 |
--echo -- Examine data on Primary Master, should be unaffected (no row) |
| 319 |
|
| 320 |
select * from test.t1 order by a; |
| 321 |
--source suite/ndb_rpl/t/ndb_conflict_info.inc |
| 322 |
|
| 323 |
--echo -- Examine data on Secondary Master before slave restart, should be as inserted |
| 324 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 325 |
select * from test.t1 order by a; |
| 326 |
|
| 327 |
--echo -- Restart Secondary Master slave |
| 328 |
start slave; |
| 329 |
|
| 330 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 331 |
--source suite/ndb_rpl/t/ndb_sync_primary_to_secondary.inc |
| 332 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 333 |
|
| 334 |
--echo -- Examine data on Secondary Master after slave restart, aligned with Master (deleted) |
| 335 |
select * from test.t1 order by a; |
| 336 |
|
| 337 |
--echo ------------------------------- |
| 338 |
--echo Test 7 : Delete-Delete conflict |
| 339 |
--echo ------------------------------- |
| 340 |
|
| 341 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 342 |
--echo -- Stop Secondary slave |
| 343 |
stop slave; |
| 344 |
|
| 345 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 346 |
--echo -- Delete on Primary Master |
| 347 |
|
| 348 |
delete from test.t1 where a=1; |
| 349 |
|
| 350 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 351 |
--echo -- Delete on Secondary Master |
| 352 |
|
| 353 |
delete from test.t1 where a=1; |
| 354 |
|
| 355 |
--source suite/ndb_rpl/t/ndb_sync_secondary_to_primary.inc |
| 356 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 357 |
|
| 358 |
--echo -- Examine data on Primary Master, no row |
| 359 |
|
| 360 |
select * from test.t1 order by a; |
| 361 |
--source suite/ndb_rpl/t/ndb_conflict_info.inc |
| 362 |
|
| 363 |
--echo -- Examine data on Secondary Master before slave restart, no row |
| 364 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 365 |
select * from test.t1 order by a; |
| 366 |
|
| 367 |
--echo -- Restart Secondary Master slave |
| 368 |
start slave; |
| 369 |
|
| 370 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 371 |
--source suite/ndb_rpl/t/ndb_sync_primary_to_secondary.inc |
| 372 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 373 |
|
| 374 |
--echo -- Examine data on Secondary Master after slave restart, no row |
| 375 |
select * from test.t1 order by a; |
| 376 |
|
| 377 |
|
| 378 |
--echo ------------------------------------------------ |
| 379 |
--echo Test 8 : Delete-Delete, Insert conflict exposure |
| 380 |
--echo ------------------------------------------------ |
| 381 |
# NDB$EPOCH |
| 382 |
# Data will diverge : |
| 383 |
# This occurs as the Primary Master's Delete is still |
| 384 |
# in-flight when the Secondary Master's Insert arrives, |
| 385 |
# but as there is no knowledge of this at the Primary |
| 386 |
# Master, it accepts the Insert. |
| 387 |
# |
| 388 |
# NDB$EPOCH2 |
| 389 |
# Data will not diverge : |
| 390 |
# As above, except the Secondary Master's Insert will be |
| 391 |
# reflected back to it, and applied. |
| 392 |
# So the (eventual) result will be equal data. |
| 393 |
# |
| 394 |
|
| 395 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 396 |
--echo -- Insert a row on Secondary Master |
| 397 |
insert into test.t1 values (3, "Espy"); |
| 398 |
--source suite/ndb_rpl/t/ndb_sync_secondary_to_primary.inc |
| 399 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 400 |
|
| 401 |
--echo -- Check it's present on Primary Master |
| 402 |
select * from test.t1 order by a; |
| 403 |
|
| 404 |
--echo -- Stop replication in both directions |
| 405 |
stop slave; |
| 406 |
|
| 407 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 408 |
stop slave; |
| 409 |
|
| 410 |
--echo -- Delete row from both clusters |
| 411 |
delete from test.t1 where a=3; |
| 412 |
|
| 413 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 414 |
delete from test.t1 where a=3; |
| 415 |
|
| 416 |
--echo -- Follow up with Insert from Secondary master |
| 417 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 418 |
|
| 419 |
insert into test.t1 values (3, "Dalriada"); |
| 420 |
|
| 421 |
--echo -- Restart replication in both directions |
| 422 |
start slave; |
| 423 |
|
| 424 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 425 |
start slave; |
| 426 |
|
| 427 |
--source suite/ndb_rpl/t/ndb_sync_primary_to_secondary.inc |
| 428 |
--source suite/ndb_rpl/t/ndb_sync_secondary_to_primary.inc |
| 429 |
# |
| 430 |
# For Ndb$EPOCH2, Primary will reflect Secondary Insert |
| 431 |
# back to it - we must wait for that to occur before |
| 432 |
# expecting consistency |
| 433 |
# |
| 434 |
--source suite/ndb_rpl/t/ndb_sync_primary_to_secondary.inc |
| 435 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 436 |
|
| 437 |
--echo -- Check data on both sites |
| 438 |
--echo -- diverged with NDB\$EPOCH |
| 439 |
--echo -- consistent with NDB\$EPOCH2 |
| 440 |
--echo -- Secondary master : |
| 441 |
select * from test.t1 order by a; |
| 442 |
--echo -- Primary master : |
| 443 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 444 |
select * from test.t1 order by a; |
| 445 |
|
| 446 |
--echo --Remove extra row |
| 447 |
delete from test.t1 where a=3; |
| 448 |
|
| 449 |
--source suite/ndb_rpl/t/ndb_sync_primary_to_secondary.inc |
| 450 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 451 |
|
| 452 |
--echo -- Note that Delete-Delete conflict detected below |
| 453 |
--source suite/ndb_rpl/t/ndb_conflict_info.inc |
| 454 |
|
| 455 |
--echo ------------------------------------------------ |
| 456 |
--echo Test 9 : Insert, Insert-Update-Delete conflict |
| 457 |
--echo ------------------------------------------------ |
| 458 |
|
| 459 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 460 |
--echo -- Stop replication on Secondary Master |
| 461 |
stop slave; |
| 462 |
|
| 463 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 464 |
--echo -- Insert row on Primary Master |
| 465 |
insert into test.t1 values (4, "Haymarket"); |
| 466 |
|
| 467 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 468 |
--echo -- Insert row on Secondary Master |
| 469 |
insert into test.t1 values (4, "Outhouse"); |
| 470 |
--echo -- Update row on Secondary Master |
| 471 |
update test.t1 set b="Mathers" where a = 4; |
| 472 |
--echo -- Delete row on Secondary Master |
| 473 |
delete from test.t1 where a=4; |
| 474 |
|
| 475 |
--echo -- Examine data (none) on Secondary Master |
| 476 |
select * from test.t1 order by a; |
| 477 |
|
| 478 |
--source suite/ndb_rpl/t/ndb_sync_secondary_to_primary.inc |
| 479 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 480 |
--echo -- Examine data on Primary Master, should be unaffected |
| 481 |
|
| 482 |
select * from test.t1 order by a; |
| 483 |
--source suite/ndb_rpl/t/ndb_conflict_info.inc |
| 484 |
|
| 485 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 486 |
--echo -- Examine data on Secondary Master (none) |
| 487 |
select * from test.t1 order by a; |
| 488 |
|
| 489 |
--echo -- Restart Secondary Master's slave |
| 490 |
start slave; |
| 491 |
|
| 492 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 493 |
--source suite/ndb_rpl/t/ndb_sync_primary_to_secondary.inc |
| 494 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 495 |
--echo -- Check data on Secondary Master, should be same as Primary Master |
| 496 |
select * from test.t1; |
| 497 |
|
| 498 |
--echo ------------------------------------------------ |
| 499 |
--echo Test 10 : Update, Delete-Insert-Update conflict |
| 500 |
--echo ------------------------------------------------ |
| 501 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 502 |
--echo -- Stop replication on Secondary Master |
| 503 |
stop slave; |
| 504 |
|
| 505 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 506 |
--echo -- Update row on Primary Master |
| 507 |
update test.t1 set b="Blind poet" where a=4; |
| 508 |
|
| 509 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 510 |
--echo -- Delete row on Secondary Master |
| 511 |
delete from test.t1 where a=4; |
| 512 |
|
| 513 |
--echo -- Insert row on Secondary Master |
| 514 |
insert into test.t1 values (4, "Drouthy Neebors"); |
| 515 |
|
| 516 |
--echo -- Update row on Secondary Master |
| 517 |
update test.t1 set b="The Tankard" where a=4; |
| 518 |
|
| 519 |
--source suite/ndb_rpl/t/ndb_sync_secondary_to_primary.inc |
| 520 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 521 |
|
| 522 |
--echo -- Check data on Primary Master, should be unaffected |
| 523 |
select * from test.t1 order by a; |
| 524 |
--source suite/ndb_rpl/t/ndb_conflict_info.inc |
| 525 |
|
| 526 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 527 |
--echo -- Check data on Secondary Master, as set |
| 528 |
|
| 529 |
select * from test.t1 order by a; |
| 530 |
|
| 531 |
--echo -- Restart Secondary Master slave |
| 532 |
start slave; |
| 533 |
|
| 534 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 535 |
--source suite/ndb_rpl/t/ndb_sync_primary_to_secondary.inc |
| 536 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 537 |
|
| 538 |
--echo -- Check data on Secondary Master - should be as Primary |
| 539 |
select * from test.t1 order by a; |
| 540 |
|
| 541 |
--source suite/ndb_rpl/t/ndb_sync_secondary_to_primary.inc |
| 542 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 543 |
|
| 544 |
--echo ------------------------------------------------------------------------ |
| 545 |
--echo Test 11 : Test Secondary insert-update-delete accepted |
| 546 |
--echo ------------------------------------------------------------------------ |
| 547 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 548 |
--echo Insert row on Secondary |
| 549 |
insert into test.t1 values (5, "Minders"); |
| 550 |
--echo Update row on Secondary |
| 551 |
update test.t1 set b="Southsider" where a=5; |
| 552 |
--echo Delete row on Secondary |
| 553 |
delete from test.t1 where a=5; |
| 554 |
|
| 555 |
--source suite/ndb_rpl/t/ndb_sync_secondary_to_primary.inc |
| 556 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 557 |
|
| 558 |
--echo Check data on Primary, should be none. No new conflicts |
| 559 |
select * from test.t1 order by a; |
| 560 |
--source suite/ndb_rpl/t/ndb_conflict_info.inc |
| 561 |
|
| 562 |
# Test runs with --log-replica-updates=1 |
| 563 |
# This means that the Secondary logs reflected ops if they |
| 564 |
# take some effect in its binlog |
| 565 |
# (e.g. they go S->P --reflect--> S --logged--> P) |
| 566 |
# On the final return to P they are logged with the P server |
| 567 |
# id, so won't be applied. |
| 568 |
# BUT the table_map events are logged with the logging server |
| 569 |
# id (e.g. S in this case), and will be processed by the |
| 570 |
# slave SQL thread. |
| 571 |
# If e.g. the table has been dropped on the PRIMARY then |
| 572 |
# this can cause a slave failure... |
| 573 |
# In real life I guess that table drop is rare. |
| 574 |
# For this testcase, we'll do some more serialisation between |
| 575 |
# the last writes to a table, and the drop of the table |
| 576 |
# |
| 577 |
--source suite/ndb_rpl/t/ndb_sync_primary_to_secondary.inc |
| 578 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 579 |
--source suite/ndb_rpl/t/ndb_sync_secondary_to_primary.inc |
| 580 |
|
| 581 |
# Show nothing changed in the meantime |
| 582 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 583 |
--source suite/ndb_rpl/t/ndb_conflict_info.inc |
| 584 |
|
| 585 |
# Now drop |
| 586 |
drop table test.t1; |
| 587 |
drop table test.t2; |
| 588 |
drop table test.t1$EX; |
| 589 |
|
| 590 |
--source suite/ndb_rpl/t/ndb_sync_primary_to_secondary.inc |
| 591 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |