| 1 |
# |
| 2 |
# Test engine native conflict resolution for ndb |
| 3 |
# NDB$EPOCH2() function |
| 4 |
# |
| 5 |
# Extra tests |
| 6 |
# |
| 7 |
--source include/have_ndb.inc |
| 8 |
--source include/have_binlog_format_mixed_or_row.inc |
| 9 |
--source suite/ndb_rpl/ndb_master-slave.inc |
| 10 |
|
| 11 |
--echo Setup circular replication |
| 12 |
--echo The circle is setup between Primary and Secondary |
| 13 |
|
| 14 |
--disable_query_log |
| 15 |
--disable_result_log |
| 16 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 17 |
# Gather port + serverid |
| 18 |
|
| 19 |
select @primary_server_id:=(variable_value+0) |
| 20 |
from performance_schema.global_variables |
| 21 |
where variable_name like 'server_id'; |
| 22 |
let $PRIMARY_SERVER_ID= query_get_value('select @primary_server_id as v',v,1); |
| 23 |
select @primary_server_port:=(variable_value+0) |
| 24 |
from performance_schema.global_variables |
| 25 |
where variable_name like 'port'; |
| 26 |
let $PRIMARY_SERVER_PORT= query_get_value('select @primary_server_port as v', v,1); |
| 27 |
|
| 28 |
# Suppress warnings sometimes seen |
| 29 |
call mtr.add_suppression("Source is configured to log replication events with checksum"); |
| 30 |
call mtr.add_suppression("Request to stop replica SQL Thread received while applying a group that has non-transactional changes; waiting for completion of the group"); |
| 31 |
|
| 32 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 33 |
# Gather port + serverid |
| 34 |
select @secondary_server_id:=(variable_value+0) |
| 35 |
from performance_schema.global_variables |
| 36 |
where variable_name like 'server_id'; |
| 37 |
let $SECONDARY_SERVER_ID= query_get_value('select @secondary_server_id as v',v,1); |
| 38 |
select @secondary_server_port:=(variable_value+0) |
| 39 |
from performance_schema.global_variables |
| 40 |
where variable_name like 'port'; |
| 41 |
let $SECONDARY_SERVER_PORT= query_get_value('select @secondary_server_port as v', v,1); |
| 42 |
|
| 43 |
# Suppress warnings sometimes seen |
| 44 |
call mtr.add_suppression("Source is configured to log replication events with checksum"); |
| 45 |
call mtr.add_suppression("Request to stop replica SQL Thread received while applying a group that has non-transactional changes; waiting for completion of the group"); |
| 46 |
|
| 47 |
# Now set it up |
| 48 |
# Stop Slave @ Secondary |
| 49 |
STOP SLAVE; |
| 50 |
# Clear Secondary Binlog |
| 51 |
RESET MASTER; |
| 52 |
|
| 53 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 54 |
# Stop Slave @ Primary |
| 55 |
STOP SLAVE; |
| 56 |
# Clear Primary Binlog |
| 57 |
RESET MASTER; |
| 58 |
|
| 59 |
--eval CHANGE REPLICATION SOURCE TO SOURCE_HOST="127.0.0.1",SOURCE_PORT=$SECONDARY_SERVER_PORT,SOURCE_USER="root" |
| 60 |
|
| 61 |
# Start Primary replicating from Secondary |
| 62 |
START SLAVE; |
| 63 |
|
| 64 |
--enable_query_log |
| 65 |
--enable_result_log |
| 66 |
|
| 67 |
--source suite/ndb_rpl/t/ndb_conflict_info_epoch2_init.inc |
| 68 |
|
| 69 |
--disable_query_log |
| 70 |
--disable_result_log |
| 71 |
|
| 72 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 73 |
--eval CHANGE REPLICATION SOURCE TO SOURCE_HOST="127.0.0.1",SOURCE_PORT=$PRIMARY_SERVER_PORT,SOURCE_USER="root" |
| 74 |
|
| 75 |
# Start Secondary replicating from Primary |
| 76 |
START SLAVE; |
| 77 |
|
| 78 |
--source suite/ndb_rpl/t/ndb_conflict_info_epoch2_init.inc |
| 79 |
|
| 80 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 81 |
|
| 82 |
--enable_query_log |
| 83 |
--enable_result_log |
| 84 |
|
| 85 |
--echo Setup ndb_replication and t1$EX exceptions table |
| 86 |
|
| 87 |
--disable_warnings |
| 88 |
--disable_query_log |
| 89 |
drop table if exists mysql.ndb_replication; |
| 90 |
CREATE TABLE mysql.ndb_replication |
| 91 |
(db VARBINARY(63), |
| 92 |
table_name VARBINARY(63), |
| 93 |
server_id INT UNSIGNED, |
| 94 |
binlog_type INT UNSIGNED, |
| 95 |
conflict_fn VARBINARY(128), |
| 96 |
PRIMARY KEY USING HASH (db,table_name,server_id)) |
| 97 |
ENGINE=NDB PARTITION BY KEY(db,table_name); |
| 98 |
--enable_warnings |
| 99 |
--enable_query_log |
| 100 |
|
| 101 |
--echo Populate ndb_replication table |
| 102 |
--disable_query_log |
| 103 |
eval replace into mysql.ndb_replication values |
| 104 |
("test", "t1", 0, 7, "NDB\$EPOCH2()"); |
| 105 |
--enable_query_log |
| 106 |
|
| 107 |
create table test.t1$EX( |
| 108 |
ndb$server_id int unsigned, |
| 109 |
ndb$master_server_id int unsigned, |
| 110 |
ndb$master_epoch bigint unsigned, |
| 111 |
ndb$count int unsigned, |
| 112 |
k int not null, |
| 113 |
v$old int, |
| 114 |
v$new int, |
| 115 |
c$old varchar(2000), |
| 116 |
c$new varchar(2000), |
| 117 |
ndb$op_type enum('write_row','update_row', 'delete_row') not null, |
| 118 |
ndb$cft_cause enum('row_does_not_exist','row_already_exists','data_in_conflict','trans_in_conflict') not null, |
| 119 |
primary key(ndb$server_id, ndb$master_server_id, ndb$master_epoch, ndb$count)) |
| 120 |
engine ndb character set latin1; |
| 121 |
|
| 122 |
create table test.t1 ( |
| 123 |
k int primary key, |
| 124 |
v int, |
| 125 |
c varchar(2000)) engine=ndb character set latin1; |
| 126 |
|
| 127 |
--echo Setup conflict roles |
| 128 |
--echo -------------------- |
| 129 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 130 |
STOP SLAVE; |
| 131 |
set global ndb_applier_conflict_role="PRIMARY"; |
| 132 |
START SLAVE; |
| 133 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 134 |
STOP SLAVE; |
| 135 |
set global ndb_applier_conflict_role="SECONDARY"; |
| 136 |
START SLAVE; |
| 137 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 138 |
|
| 139 |
--echo Create some initial data |
| 140 |
--echo ------------------------ |
| 141 |
|
| 142 |
insert into test.t1 values |
| 143 |
(1,10, "Swimming"), |
| 144 |
(2,20, "Cycling"), |
| 145 |
(3,30, "Running"), |
| 146 |
(4,40, "Triathlon"); |
| 147 |
|
| 148 |
--let loop_count=4 |
| 149 |
|
| 150 |
# Loop over tests, with different roles |
| 151 |
while ($loop_count) |
| 152 |
{ |
| 153 |
|
| 154 |
--echo Content on PRIMARY |
| 155 |
select * from test.t1 order by k; |
| 156 |
|
| 157 |
--source suite/ndb_rpl/t/ndb_sync_primary_to_secondary.inc |
| 158 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 159 |
--echo Content on SECONDARY |
| 160 |
select * from test.t1 order by k; |
| 161 |
|
| 162 |
--source suite/ndb_rpl/t/ndb_sync_secondary_to_primary.inc |
| 163 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 164 |
|
| 165 |
--echo Basic delete-delete cases |
| 166 |
--echo ------------------------- |
| 167 |
|
| 168 |
--echo Stop Slave on SECONDARY |
| 169 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 170 |
STOP SLAVE; |
| 171 |
|
| 172 |
--echo Delete row 3 on PRIMARY |
| 173 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 174 |
delete from t1 where k=3; |
| 175 |
|
| 176 |
--echo Delete row 3 on SECONDARY |
| 177 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 178 |
delete from t1 where k=3; |
| 179 |
|
| 180 |
--echo Insert replacement row on SECONDARY |
| 181 |
--echo This is likely to go in the same SECONDARY epoch transaction |
| 182 |
# TODO Variant where epoch boundary is forced here. |
| 183 |
insert into t1 values (3,31, "Judo"); |
| 184 |
|
| 185 |
--echo Wait for SECONDARY change to apply on PRIMARY |
| 186 |
--echo Expect it to apply correctly here as the PRIMARY |
| 187 |
--echo has no track of its outstanding DELETE |
| 188 |
--echo |
| 189 |
|
| 190 |
--source suite/ndb_rpl/t/ndb_sync_secondary_to_primary.inc |
| 191 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 192 |
--echo PRIMARY content |
| 193 |
select * from test.t1 order by k; |
| 194 |
|
| 195 |
--echo PRIMARY counters |
| 196 |
--source suite/ndb_rpl/t/ndb_conflict_info_epoch2.inc |
| 197 |
|
| 198 |
--source suite/ndb_rpl/t/ndb_conflict_info_epoch2_init.inc |
| 199 |
|
| 200 |
--echo Re-enable SECONDARY Slave, and check state there |
| 201 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 202 |
START SLAVE; |
| 203 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 204 |
--source suite/ndb_rpl/t/ndb_sync_primary_to_secondary.inc |
| 205 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 206 |
|
| 207 |
--echo SECONDARY content |
| 208 |
select * from test.t1 order by k; |
| 209 |
|
| 210 |
--echo SECONDARY counters |
| 211 |
--source suite/ndb_rpl/t/ndb_conflict_info_epoch2.inc |
| 212 |
|
| 213 |
--source suite/ndb_rpl/t/ndb_conflict_info_epoch2_init.inc |
| 214 |
|
| 215 |
--echo Look at PRIMARY exceptions table content |
| 216 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 217 |
SELECT k, v$old, v$new, c$old, c$new, ndb$op_type, ndb$cft_cause from test.t1$EX order by ndb$count; |
| 218 |
|
| 219 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 220 |
--source suite/ndb_rpl/t/ndb_sync_secondary_to_primary.inc |
| 221 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 222 |
|
| 223 |
--echo Now check behaviour of Secondary when reflected ops should not be applied |
| 224 |
--echo ------------------------------------------------------------------------- |
| 225 |
--echo The interpreted program attached to reflected ops at the Secondary slave |
| 226 |
--echo is intended to avoid an 'old' reflected op overwriting a 'new' locally |
| 227 |
--echo inserted row value. The end result should still be the same (the new |
| 228 |
--echo value will be applied later, but we should avoid having every modification |
| 229 |
--echo made at the secondary applied twice with some time lag as that will cause |
| 230 |
--echo chaos for Secondary applications) |
| 231 |
|
| 232 |
--echo Stop Slave on SECONDARY |
| 233 |
STOP SLAVE; |
| 234 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 235 |
|
| 236 |
--echo Stop Slave on PRIMARY |
| 237 |
STOP SLAVE; |
| 238 |
|
| 239 |
--echo Delete row 4 on PRIMARY |
| 240 |
DELETE from test.t1 where k=4; |
| 241 |
|
| 242 |
--echo Primary state |
| 243 |
select * from test.t1 order by k; |
| 244 |
|
| 245 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 246 |
|
| 247 |
--echo Delete row 4 on SECONDARY |
| 248 |
|
| 249 |
DELETE from test.t1 where k=4; |
| 250 |
|
| 251 |
--echo Follow with INSERT on SECONDARY |
| 252 |
|
| 253 |
INSERT into test.t1 values (4, 440, "Fell running"); |
| 254 |
|
| 255 |
--echo Secondary state : |
| 256 |
select * from test.t1 order by k; |
| 257 |
|
| 258 |
--echo Allow Primary change to propagate to Secondary |
| 259 |
--echo (Which will delete the new, updated row on the Secondary) |
| 260 |
START SLAVE; |
| 261 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 262 |
--source suite/ndb_rpl/t/ndb_sync_primary_to_secondary.inc |
| 263 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 264 |
|
| 265 |
--echo Examine data on the SECONDARY - row 4 deleted |
| 266 |
select * from test.t1 order by k; |
| 267 |
|
| 268 |
--echo Now allow the SECONDARY Binlog to propagate back to the PRIMARY |
| 269 |
--echo while blocking the return path... |
| 270 |
STOP SLAVE; |
| 271 |
|
| 272 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 273 |
START SLAVE; |
| 274 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 275 |
--source suite/ndb_rpl/t/ndb_sync_secondary_to_primary.inc |
| 276 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 277 |
|
| 278 |
--echo Examine data on the PRIMARY - row 4 exists |
| 279 |
--echo as the PRIMARY's delete is not applied if present |
| 280 |
select * from test.t1 order by k; |
| 281 |
|
| 282 |
--echo Now stop the PRIMARY Slave - changes from the |
| 283 |
--echo SECONDARY cannot now reach the PRIMARY |
| 284 |
STOP SLAVE; |
| 285 |
|
| 286 |
--echo Now go back to the SECONDARY and create a new |
| 287 |
--echo row version |
| 288 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 289 |
|
| 290 |
--echo First show there is no row 4 on the SECONDARY |
| 291 |
select * from test.t1 order by k; |
| 292 |
|
| 293 |
INSERT into test.t1 values (4, 4444, "Cyclo-cross"); |
| 294 |
|
| 295 |
select * from test.t1 order by k; |
| 296 |
|
| 297 |
--echo Now allow the Binlog of the PRIMARY (containing the |
| 298 |
--echo reflected DELETE + Insert (4, 440, "Fell running") |
| 299 |
--echo to be applied locally |
| 300 |
--echo The SECONDARY should reject this application |
| 301 |
|
| 302 |
--source suite/ndb_rpl/t/ndb_conflict_info_epoch2_init.inc |
| 303 |
START SLAVE; |
| 304 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 305 |
--source suite/ndb_rpl/t/ndb_sync_primary_to_secondary.inc |
| 306 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 307 |
|
| 308 |
--echo Examine data on the SECONDARY : Row 4 should be untouched |
| 309 |
--echo (4, 4444, "Cyclo-cross"). |
| 310 |
--echo Insert will be rejected as row already exists. |
| 311 |
select * from test.t1 order by k; |
| 312 |
|
| 313 |
--echo Show operation counter diff on the SECONDARY |
| 314 |
--echo Should show reflected op prepared + rejected. |
| 315 |
--echo Should show equal, non-zero reflected op prep+reject counts |
| 316 |
--source suite/ndb_rpl/t/ndb_conflict_info_epoch2.inc |
| 317 |
|
| 318 |
--echo Ok, now allow SECONDARY Binlog to propagate to Primary |
| 319 |
--echo and realign it |
| 320 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 321 |
START SLAVE; |
| 322 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 323 |
--source suite/ndb_rpl/t/ndb_sync_secondary_to_primary.inc |
| 324 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 325 |
|
| 326 |
--echo Show data on PRIMARY |
| 327 |
select * from test.t1 order by k; |
| 328 |
|
| 329 |
--echo Allow reflection back to the SECONDARY... |
| 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 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 335 |
|
| 336 |
|
| 337 |
--echo Now show same for UPDATE, then DELETE |
| 338 |
--echo ------------------------------------- |
| 339 |
--echo First stop SLAVEs |
| 340 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 341 |
STOP SLAVE; |
| 342 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 343 |
STOP SLAVE; |
| 344 |
--echo Now perform UPDATE 1 at Secondary |
| 345 |
UPDATE test.t1 SET c="Bathing" where k=1; |
| 346 |
|
| 347 |
--echo Show data on Secondary |
| 348 |
select * from test.t1 order by k; |
| 349 |
|
| 350 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 351 |
|
| 352 |
--echo Data on Primary |
| 353 |
select * from test.t1 order by k; |
| 354 |
|
| 355 |
--echo Now propagate to Primary... |
| 356 |
START SLAVE; |
| 357 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 358 |
--source suite/ndb_rpl/t/ndb_sync_secondary_to_primary.inc |
| 359 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 360 |
|
| 361 |
--echo Updated data on Primary |
| 362 |
select * from test.t1 order by k; |
| 363 |
|
| 364 |
--echo Now stop Primary slave to stop further propagation |
| 365 |
STOP SLAVE; |
| 366 |
|
| 367 |
--echo Now make update 2 on Secondary |
| 368 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 369 |
update test.t1 SET c="Paddling" where k=1; |
| 370 |
|
| 371 |
--echo Data on Secondary |
| 372 |
select * from test.t1 order by k; |
| 373 |
|
| 374 |
--echo Now allow Primary binlog, containing reflected update op |
| 375 |
--echo setting column c of row 1 to "Bathing" to be applied |
| 376 |
--echo it should be rejected by the Secondary, and increment |
| 377 |
--echo the defined + rejected counts |
| 378 |
|
| 379 |
START SLAVE; |
| 380 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 381 |
--source suite/ndb_rpl/t/ndb_sync_primary_to_secondary.inc |
| 382 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 383 |
|
| 384 |
--echo Data on Secondary (should be unchanged) |
| 385 |
|
| 386 |
select * from test.t1 order by k; |
| 387 |
|
| 388 |
--echo Conflict counts on Secondary (incremented preped + rejected) |
| 389 |
|
| 390 |
--source suite/ndb_rpl/t/ndb_conflict_info_epoch2.inc |
| 391 |
|
| 392 |
--echo Now allow sync... |
| 393 |
|
| 394 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 395 |
START SLAVE; |
| 396 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 397 |
--source suite/ndb_rpl/t/ndb_sync_secondary_to_primary.inc |
| 398 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 399 |
--source suite/ndb_rpl/t/ndb_sync_primary_to_secondary.inc |
| 400 |
|
| 401 |
--echo Allowing the sync should have allowed the second update |
| 402 |
--echo (To 'Paddling') to be reflected, and rejected |
| 403 |
|
| 404 |
--echo Data on Secondary (should be unchanged) |
| 405 |
|
| 406 |
select * from test.t1 order by k; |
| 407 |
|
| 408 |
--echo Conflict counts on Secondary (incremented preped + rejected) |
| 409 |
|
| 410 |
--source suite/ndb_rpl/t/ndb_conflict_info_epoch2.inc |
| 411 |
|
| 412 |
--source suite/ndb_rpl/t/ndb_conflict_info_epoch2_init.inc |
| 413 |
|
| 414 |
|
| 415 |
--echo Show same for DELETE |
| 416 |
--echo -------------------- |
| 417 |
--echo First stop SLAVEs |
| 418 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 419 |
STOP SLAVE; |
| 420 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 421 |
STOP SLAVE; |
| 422 |
--echo Now perform DELETE of row 2 at Secondary |
| 423 |
DELETE from test.t1 where k=2; |
| 424 |
|
| 425 |
--echo Show data on Secondary |
| 426 |
select * from test.t1 order by k; |
| 427 |
|
| 428 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 429 |
|
| 430 |
--echo Data on Primary |
| 431 |
select * from test.t1 order by k; |
| 432 |
|
| 433 |
--echo Now propagate to Primary... |
| 434 |
START SLAVE; |
| 435 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 436 |
--source suite/ndb_rpl/t/ndb_sync_secondary_to_primary.inc |
| 437 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 438 |
|
| 439 |
--echo Updated data on Primary |
| 440 |
select * from test.t1 order by k; |
| 441 |
|
| 442 |
--echo Now stop Primary slave to stop further propagation |
| 443 |
STOP SLAVE; |
| 444 |
|
| 445 |
--echo Now make a further change on Secondary |
| 446 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 447 |
INSERT into test.t1 VALUES (2, 22, "Rock-climbing"); |
| 448 |
|
| 449 |
--echo Data on Secondary |
| 450 |
select * from test.t1 order by k; |
| 451 |
|
| 452 |
--echo Now allow Primary binlog, containing reflected delete op |
| 453 |
--echo on row 2 to be applied it should be rejected by the |
| 454 |
--echo Secondary, and increment the defined + rejected counts |
| 455 |
|
| 456 |
START SLAVE; |
| 457 |
|
| 458 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 459 |
--source suite/ndb_rpl/t/ndb_sync_primary_to_secondary.inc |
| 460 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 461 |
|
| 462 |
--echo Data on Secondary (should be unchanged) |
| 463 |
|
| 464 |
select * from test.t1 order by k; |
| 465 |
|
| 466 |
--echo Conflict counts on Secondary (incremented preped + rejected) |
| 467 |
|
| 468 |
--source suite/ndb_rpl/t/ndb_conflict_info_epoch2.inc |
| 469 |
|
| 470 |
--echo Now allow sync... |
| 471 |
|
| 472 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 473 |
START SLAVE; |
| 474 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 475 |
--source suite/ndb_rpl/t/ndb_sync_secondary_to_primary.inc |
| 476 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 477 |
--source suite/ndb_rpl/t/ndb_sync_primary_to_secondary.inc |
| 478 |
|
| 479 |
--echo Allowing the sync should have allowed the insert |
| 480 |
--echo (To 'Rock-climbing') to be reflected, and rejected |
| 481 |
|
| 482 |
--echo Data on Secondary (should be unchanged) |
| 483 |
|
| 484 |
select * from test.t1 order by k; |
| 485 |
|
| 486 |
--echo Conflict counts on Secondary (incremented preped + rejected) |
| 487 |
|
| 488 |
--source suite/ndb_rpl/t/ndb_conflict_info_epoch2.inc |
| 489 |
|
| 490 |
|
| 491 |
--echo Primary insert-delete obscures Secondary insert problem |
| 492 |
--echo ------------------------------------------------------- |
| 493 |
--echo Stop slaves in both directions |
| 494 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 495 |
STOP SLAVE; |
| 496 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 497 |
STOP SLAVE; |
| 498 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 499 |
--echo Start with non-existent row (5, 50, "Disco dancing") on primary |
| 500 |
insert into test.t1 values (5, 50, "Disco dancing"); |
| 501 |
select * from test.t1 order by k; |
| 502 |
|
| 503 |
--echo Reset conflict counters on Primary |
| 504 |
--source suite/ndb_rpl/t/ndb_conflict_info_epoch2_init.inc |
| 505 |
--echo Empty exceptions table on Primary |
| 506 |
DELETE from test.t1$EX; |
| 507 |
|
| 508 |
--echo Insert non-existent row (5, 500, "Line dancing") on secondary |
| 509 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 510 |
insert into test.t1 values (5, 500, "Line dancing"); |
| 511 |
select * from test.t1 order by k; |
| 512 |
|
| 513 |
--echo Reset conflict counters on Secondary |
| 514 |
--source suite/ndb_rpl/t/ndb_conflict_info_epoch2_init.inc |
| 515 |
|
| 516 |
--echo Allow Primary insert to trample Secondary insert. |
| 517 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 518 |
START SLAVE; |
| 519 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 520 |
--source suite/ndb_rpl/t/ndb_sync_primary_to_secondary.inc |
| 521 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 522 |
select * from test.t1 order by k; |
| 523 |
|
| 524 |
--echo Secondary now updates the row set by the Primary |
| 525 |
update test.t1 set v=v+5 where k=5; |
| 526 |
select * from test.t1 order by k; |
| 527 |
|
| 528 |
--echo Stop Secondary Slave again |
| 529 |
STOP SLAVE; |
| 530 |
|
| 531 |
--echo Now delete row from the primary |
| 532 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 533 |
delete from test.t1 where k=5; |
| 534 |
select * from test.t1 order by k; |
| 535 |
|
| 536 |
--echo Now allow Secondary writes to propagate to Primary |
| 537 |
START SLAVE; |
| 538 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 539 |
--source suite/ndb_rpl/t/ndb_sync_secondary_to_primary.inc |
| 540 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 541 |
|
| 542 |
--echo Expect that the Secondary insert succeeded as no row existed |
| 543 |
--echo on arrival, but then the secondary row was trampled by the |
| 544 |
--echo primary, and then a secondary update was applied... |
| 545 |
--echo So what do we see at the Primary? |
| 546 |
select * from test.t1 order by k; |
| 547 |
|
| 548 |
--echo Show primary conflict info counter diff - expect nothing. |
| 549 |
--source suite/ndb_rpl/t/ndb_conflict_info_epoch2.inc |
| 550 |
|
| 551 |
--echo Show primary's exceptions table content - expect there to be none. |
| 552 |
SELECT k, v$old, v$new, c$old, c$new, ndb$op_type, ndb$cft_cause from test.t1$EX order by ndb$count; |
| 553 |
|
| 554 |
# TODO : Finish + cleanup |
| 555 |
|
| 556 |
--echo Now allow Primary changes to propagate back to Secondary |
| 557 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 558 |
START SLAVE; |
| 559 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 560 |
--source suite/ndb_rpl/t/ndb_sync_primary_to_secondary.inc |
| 561 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 562 |
|
| 563 |
--echo Look at Secondary content |
| 564 |
select * from test.t1 order by k; |
| 565 |
|
| 566 |
--echo Look at Secondary conflict counters diff - showing |
| 567 |
--echo reflected ops applied on Secondary |
| 568 |
--source suite/ndb_rpl/t/ndb_conflict_info_epoch2.inc |
| 569 |
|
| 570 |
--source suite/ndb_rpl/t/ndb_sync_secondary_to_primary.inc |
| 571 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 572 |
select * from test.t1 order by k; |
| 573 |
|
| 574 |
# End of loop, if relevant, swap roles... |
| 575 |
--dec $loop_count |
| 576 |
if ($loop_count) |
| 577 |
{ |
| 578 |
--echo Iteration $loop_count |
| 579 |
|
| 580 |
# Switch primary and secondary roles |
| 581 |
# TODO, various ways to do this etc, just one for now. |
| 582 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 583 |
STOP SLAVE; |
| 584 |
# Reset exceptions table + counters on old primary |
| 585 |
DELETE FROM test.t1$EX; |
| 586 |
--source suite/ndb_rpl/t/ndb_conflict_info_epoch2_init.inc |
| 587 |
|
| 588 |
# Switch Primary -> Secondary |
| 589 |
set global ndb_applier_conflict_role="SECONDARY"; |
| 590 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 591 |
STOP SLAVE; |
| 592 |
# Reset exceptions table + counters on old primary |
| 593 |
DELETE FROM test.t1$EX; |
| 594 |
--source suite/ndb_rpl/t/ndb_conflict_info_epoch2_init.inc |
| 595 |
|
| 596 |
# Switch Secondary -> Primary |
| 597 |
set global ndb_applier_conflict_role="PRIMARY"; |
| 598 |
|
| 599 |
# TODO : Make it work for more iterations that 1 + 0 |
| 600 |
let $switchroles=query_get_value('SELECT $loop_count %2 as odd', odd, 1); |
| 601 |
if ($switchroles) |
| 602 |
{ |
| 603 |
--echo Setup S1 P2 |
| 604 |
# Switch meaning of include scripts |
| 605 |
--let $SWITCH_CLUSTER_ROLES=1 |
| 606 |
} |
| 607 |
if (!$switchroles) |
| 608 |
{ |
| 609 |
--echo Setup P1 S2 |
| 610 |
# Switch meaning of include scripts |
| 611 |
--let $SWITCH_CLUSTER_ROLES=0 |
| 612 |
} |
| 613 |
|
| 614 |
# Reconnect to aid clarity |
| 615 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 616 |
# Now reset t1 to initial state... |
| 617 |
delete from test.t1; |
| 618 |
insert into test.t1 values |
| 619 |
(1,10, "Swimming"), |
| 620 |
(2,20, "Cycling"), |
| 621 |
(3,30, "Running"), |
| 622 |
(4,40, "Triathlon"); |
| 623 |
|
| 624 |
# Now restart slaves |
| 625 |
START SLAVE; |
| 626 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 627 |
START SLAVE; |
| 628 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 629 |
|
| 630 |
# Now two way sync |
| 631 |
--source suite/ndb_rpl/t/ndb_sync_primary_to_secondary.inc |
| 632 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 633 |
--source suite/ndb_rpl/t/ndb_sync_secondary_to_primary.inc |
| 634 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 635 |
} |
| 636 |
|
| 637 |
} # End of roles loop |
| 638 |
|
| 639 |
|
| 640 |
--echo Now test SCR_PASS |
| 641 |
--echo ----------------- |
| 642 |
--echo SCR_PASS is a slave conflict role which should act as a |
| 643 |
--echo filterless pass-through of replication events, with no |
| 644 |
--echo conflict detection etc. The idea is that it might be |
| 645 |
--echo useful for failover situations etc. |
| 646 |
--echo Here we test that it does not detect conflicts, and |
| 647 |
--echo allows divergence etc. |
| 648 |
--echo Lets set it up |
| 649 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 650 |
STOP SLAVE; |
| 651 |
set global ndb_applier_conflict_role="NONE"; |
| 652 |
set global ndb_applier_conflict_role="PASS"; |
| 653 |
--source suite/ndb_rpl/t/ndb_conflict_info_epoch2_init.inc |
| 654 |
START SLAVE; |
| 655 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 656 |
STOP SLAVE; |
| 657 |
set global ndb_applier_conflict_role="NONE"; |
| 658 |
set global ndb_applier_conflict_role="PASS"; |
| 659 |
--source suite/ndb_rpl/t/ndb_conflict_info_epoch2_init.inc |
| 660 |
START SLAVE; |
| 661 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 662 |
|
| 663 |
--echo Initial data on Primary |
| 664 |
select * from test.t1 order by k; |
| 665 |
|
| 666 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 667 |
|
| 668 |
--echo Initial data on Secondary |
| 669 |
select * from test.t1 order by k; |
| 670 |
|
| 671 |
--echo STOP SLAVE on Secondary |
| 672 |
STOP SLAVE; |
| 673 |
|
| 674 |
--echo Create a conflict between two updates |
| 675 |
--echo First at the primary |
| 676 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 677 |
|
| 678 |
update test.t1 set c="Capoiera" where c="Judo"; |
| 679 |
select * from test.t1 order by k; |
| 680 |
|
| 681 |
--disable_query_log |
| 682 |
--disable_result_log |
| 683 |
SHOW BINLOG EVENTS; # Force end-of-epoch |
| 684 |
--enable_result_log |
| 685 |
--enable_query_log |
| 686 |
|
| 687 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 688 |
--echo Now at the secondary |
| 689 |
|
| 690 |
update test.t1 set c="Wing chun" where c="Judo"; |
| 691 |
select * from test.t1 order by k; |
| 692 |
|
| 693 |
--disable_query_log |
| 694 |
--disable_result_log |
| 695 |
SHOW BINLOG EVENTS; # Force end-of-epoch |
| 696 |
--enable_result_log |
| 697 |
--enable_query_log |
| 698 |
|
| 699 |
--echo Now restart the secondary slave and allow propagation |
| 700 |
START SLAVE; |
| 701 |
|
| 702 |
--echo Synchronise |
| 703 |
--source suite/ndb_rpl/t/ndb_sync_secondary_to_primary.inc |
| 704 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 705 |
--source suite/ndb_rpl/t/ndb_sync_primary_to_secondary.inc |
| 706 |
|
| 707 |
# Debugging for bug#28840766 |
| 708 |
--let $EXPECT_STABILITY=1 |
| 709 |
--echo Now look at primary content and conflict counters |
| 710 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 711 |
select * from test.t1 order by k; |
| 712 |
--source suite/ndb_rpl/t/ndb_conflict_info_epoch2.inc |
| 713 |
|
| 714 |
--echo Now look at secondary content and conflict counters |
| 715 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 716 |
select * from test.t1 order by k; |
| 717 |
--source suite/ndb_rpl/t/ndb_conflict_info_epoch2.inc |
| 718 |
--let $EXPECT_STABILITY=0 |
| 719 |
|
| 720 |
--echo Now look at how row existence errors are handled |
| 721 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 722 |
--echo PRIMARY |
| 723 |
#--source suite/ndb_rpl/t/ndb_conflict_info_epoch2.inc |
| 724 |
|
| 725 |
insert into test.t1 values (6, 60, "Cigars"); |
| 726 |
insert into test.t1 values (7, 70, "Whisky"); |
| 727 |
|
| 728 |
--echo Synchronise |
| 729 |
--source suite/ndb_rpl/t/ndb_sync_primary_to_secondary.inc |
| 730 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 731 |
--source suite/ndb_rpl/t/ndb_sync_secondary_to_primary.inc |
| 732 |
|
| 733 |
--echo Cause misalignment via 'secret' deletes. |
| 734 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 735 |
--echo PRIMARY |
| 736 |
#--source suite/ndb_rpl/t/ndb_conflict_info_epoch2.inc |
| 737 |
|
| 738 |
set sql_log_bin=0; |
| 739 |
delete from test.t1 where k=7; |
| 740 |
set sql_log_bin=1; |
| 741 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 742 |
--echo SECONDARY |
| 743 |
set sql_log_bin=0; |
| 744 |
delete from test.t1 where k=6; |
| 745 |
set sql_log_bin=1; |
| 746 |
|
| 747 |
--echo Synchronise |
| 748 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 749 |
--source suite/ndb_rpl/t/ndb_sync_primary_to_secondary.inc |
| 750 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 751 |
--source suite/ndb_rpl/t/ndb_sync_secondary_to_primary.inc |
| 752 |
|
| 753 |
--echo Show start state |
| 754 |
--echo Primary : |
| 755 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 756 |
select * from test.t1 order by k; |
| 757 |
#--source suite/ndb_rpl/t/ndb_conflict_info_epoch2.inc |
| 758 |
|
| 759 |
--echo Secondary : |
| 760 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 761 |
select * from test.t1 order by k; |
| 762 |
|
| 763 |
--echo Now insert a row on the Secondary which already |
| 764 |
--echo exists on the Primary |
| 765 |
insert into test.t1 values (6,66, "Snuff"); |
| 766 |
select * from test.t1 order by k; |
| 767 |
|
| 768 |
--source suite/ndb_rpl/t/ndb_sync_secondary_to_primary.inc |
| 769 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 770 |
--echo Show that the primary was overwritten with the Secondary's |
| 771 |
--echo value, and no conflict reported. |
| 772 |
select * from test.t1 order by k; |
| 773 |
--source suite/ndb_rpl/t/ndb_conflict_info_epoch2.inc |
| 774 |
|
| 775 |
--echo Same for a Secondary sourced update of a row |
| 776 |
--echo which doesn't exist on the primary. |
| 777 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 778 |
update test.t1 set c="Tawny Port" where c="Whisky"; |
| 779 |
select * from test.t1 order by k; |
| 780 |
--source suite/ndb_rpl/t/ndb_sync_secondary_to_primary.inc |
| 781 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 782 |
|
| 783 |
--echo Show state on Primary. No row, but also no conflicts |
| 784 |
--echo or slave errors. |
| 785 |
select * from test.t1 order by k; |
| 786 |
--source suite/ndb_rpl/t/ndb_conflict_info_epoch2.inc |
| 787 |
|
| 788 |
--echo Now show a row delete from the secondary for |
| 789 |
--echo a row which does not exist on the primary |
| 790 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 791 |
delete from test.t1 where k=7; |
| 792 |
select * from test.t1 order by k; |
| 793 |
|
| 794 |
--source suite/ndb_rpl/t/ndb_sync_secondary_to_primary.inc |
| 795 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 796 |
|
| 797 |
--echo Show state on Primary. No conflicts or slave errors |
| 798 |
select * from test.t1 order by k; |
| 799 |
--source suite/ndb_rpl/t/ndb_conflict_info_epoch2.inc |
| 800 |
|
| 801 |
--echo Remove inconsistencies from the table |
| 802 |
delete from test.t1 where k in (3, 6); |
| 803 |
|
| 804 |
--source suite/ndb_rpl/t/ndb_sync_primary_to_secondary.inc |
| 805 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 806 |
--source suite/ndb_rpl/t/ndb_sync_secondary_to_primary.inc |
| 807 |
|
| 808 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 809 |
STOP SLAVE; |
| 810 |
set global ndb_applier_conflict_role="NONE"; |
| 811 |
set global ndb_applier_conflict_role="PRIMARY"; |
| 812 |
START SLAVE; |
| 813 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 814 |
STOP SLAVE; |
| 815 |
set global ndb_applier_conflict_role="NONE"; |
| 816 |
set global ndb_applier_conflict_role="SECONDARY"; |
| 817 |
START SLAVE; |
| 818 |
|
| 819 |
--echo Test ndb_conflict_last_stable_epoch |
| 820 |
--echo This status var is intended to help in situations |
| 821 |
--echo where there is an unexpected PRIMARY failure, and |
| 822 |
--echo the SECONDARY can determine that there were in-flight |
| 823 |
--echo realignment ops (conflicts), based on |
| 824 |
--echo ndb_conflict_last_conflict_epoch > |
| 825 |
--echo ndb_slave_max_replicated_epoch |
| 826 |
--echo ndb_conflict_last_stable_epoch will contain the |
| 827 |
--echo last (highest) SECONDARY epoch which is known |
| 828 |
--echo to have replicated via the PRIMARY with no |
| 829 |
--echo conflicts being discovered. This is then |
| 830 |
--echo a consistent baseline from which to potentially |
| 831 |
--echo resolve any partial realignments. |
| 832 |
--echo How to resolve them is an exercise left for |
| 833 |
--echo the reader :) |
| 834 |
|
| 835 |
--echo Testcase to show the variable in action |
| 836 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 837 |
--echo Stop SECONDARY slave |
| 838 |
STOP SLAVE; |
| 839 |
|
| 840 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 841 |
--echo Change on Primary, won't propagate to Secondary as SLAVE is stopped. |
| 842 |
update test.t1 set c="Loafing" where k=1; |
| 843 |
|
| 844 |
--source suite/ndb_rpl/t/ndb_conflict_info_epoch2_init.inc |
| 845 |
|
| 846 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 847 |
--echo Conflicting change on Secondary |
| 848 |
update test.t1 set c="Idling" where k=1; |
| 849 |
|
| 850 |
--source include/wait_for_ndb_committed_to_binlog.inc |
| 851 |
|
| 852 |
--echo Add some epochs after the conflicting modification |
| 853 |
|
| 854 |
let $e_count=10; |
| 855 |
while ($e_count) |
| 856 |
{ |
| 857 |
eval insert into t1 values ($e_count + 10, 10, "Sequencing"); |
| 858 |
dec $e_count; |
| 859 |
--source include/wait_for_ndb_committed_to_binlog.inc |
| 860 |
} |
| 861 |
|
| 862 |
--echo Now look at Secondary values, should have |
| 863 |
--echo Max_Replicated_Epoch == Last_Stable_Epoch |
| 864 |
|
| 865 |
--disable_query_log |
| 866 |
--disable_result_log |
| 867 |
SELECT @ndb_last_conflict_epoch:= VARIABLE_VALUE FROM performance_schema.global_status WHERE VARIABLE_NAME LIKE "NDB_CONFLICT_LAST_CONFLICT_EPOCH"; |
| 868 |
SELECT @ndb_last_stable_epoch:=VARIABLE_VALUE FROM performance_schema.global_status WHERE VARIABLE_NAME LIKE "NDB_CONFLICT_LAST_STABLE_EPOCH"; |
| 869 |
SELECT @ndb_max_replicated_epoch:=VARIABLE_VALUE FROM performance_schema.global_status WHERE VARIABLE_NAME LIKE "NDB_SLAVE_MAX_REPLICATED_EPOCH"; |
| 870 |
--enable_result_log |
| 871 |
--enable_query_log |
| 872 |
# SELECT @ndb_last_conflict_epoch, @ndb_last_stable_epoch, @ndb_max_replicated_epoch; |
| 873 |
|
| 874 |
--echo Expect 1,0,1 - all is well. |
| 875 |
SELECT (@ndb_last_conflict_epoch+0) <= (@ndb_max_replicated_epoch+0) AS SECONDARY_IS_CURRENTLY_CONFLICT_FREE; |
| 876 |
SELECT (@ndb_last_stable_epoch+0) < (@ndb_max_replicated_epoch+0) AS STABLE_EPOCH_LAGS_MAX_REPLICATED_EPOCH; |
| 877 |
SELECT (@ndb_last_stable_epoch+0) = (@ndb_max_replicated_epoch+0) AS STABLE_EPOCH_IS_MAX_REPLICATED_EPOCH; |
| 878 |
|
| 879 |
--source suite/ndb_rpl/t/ndb_sync_secondary_to_primary.inc |
| 880 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 881 |
|
| 882 |
--echo Stop PRIMARY slave just to have control |
| 883 |
STOP SLAVE; |
| 884 |
|
| 885 |
--source suite/ndb_rpl/t/ndb_conflict_info_epoch2.inc |
| 886 |
|
| 887 |
--echo Now Start SECONDARY slave, to get conflict realignment |
| 888 |
--echo and following SECONDARY epochs re-applied on the SEOCNDARY |
| 889 |
|
| 890 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 891 |
START SLAVE; |
| 892 |
|
| 893 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 894 |
--source suite/ndb_rpl/t/ndb_sync_primary_to_secondary.inc |
| 895 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 896 |
|
| 897 |
--echo Now look at variables on the SECONDARY again |
| 898 |
|
| 899 |
--disable_query_log |
| 900 |
--disable_result_log |
| 901 |
SELECT @ndb_last_conflict_epoch:= VARIABLE_VALUE FROM performance_schema.global_status WHERE VARIABLE_NAME LIKE "NDB_CONFLICT_LAST_CONFLICT_EPOCH"; |
| 902 |
SELECT @ndb_last_stable_epoch:=VARIABLE_VALUE FROM performance_schema.global_status WHERE VARIABLE_NAME LIKE "NDB_CONFLICT_LAST_STABLE_EPOCH"; |
| 903 |
SELECT @ndb_max_replicated_epoch:=VARIABLE_VALUE FROM performance_schema.global_status WHERE VARIABLE_NAME LIKE "NDB_SLAVE_MAX_REPLICATED_EPOCH"; |
| 904 |
--enable_result_log |
| 905 |
--enable_query_log |
| 906 |
#SELECT @ndb_last_conflict_epoch, @ndb_last_stable_epoch, @ndb_max_replicated_epoch; |
| 907 |
|
| 908 |
|
| 909 |
--echo Expect 0,1,0 - Conflict handling open, stable epoch is old, most recent |
| 910 |
--echo replicated epochs are not yet stable. |
| 911 |
SELECT (@ndb_last_conflict_epoch+0) <= (@ndb_max_replicated_epoch+0) AS SECONDARY_IS_CURRENTLY_CONFLICT_FREE; |
| 912 |
SELECT (@ndb_last_stable_epoch+0) < (@ndb_max_replicated_epoch+0) AS STABLE_EPOCH_LAGS_MAX_REPLICATED_EPOCH; |
| 913 |
SELECT (@ndb_last_stable_epoch+0) = (@ndb_max_replicated_epoch+0) AS STABLE_EPOCH_IS_MAX_REPLICATED_EPOCH; |
| 914 |
|
| 915 |
--echo Now make a SECONDARY change and allow it to flow |
| 916 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 917 |
START SLAVE; |
| 918 |
|
| 919 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 920 |
delete from test.t1 where k >=10; |
| 921 |
|
| 922 |
--source suite/ndb_rpl/t/ndb_sync_secondary_to_primary.inc |
| 923 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 924 |
--source suite/ndb_rpl/t/ndb_sync_primary_to_secondary.inc |
| 925 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 926 |
|
| 927 |
--echo Now look at variables on the SECONDARY for third time |
| 928 |
|
| 929 |
--disable_query_log |
| 930 |
--disable_result_log |
| 931 |
SELECT @ndb_last_conflict_epoch:= VARIABLE_VALUE FROM performance_schema.global_status WHERE VARIABLE_NAME LIKE "NDB_CONFLICT_LAST_CONFLICT_EPOCH"; |
| 932 |
SELECT @ndb_last_stable_epoch:=VARIABLE_VALUE FROM performance_schema.global_status WHERE VARIABLE_NAME LIKE "NDB_CONFLICT_LAST_STABLE_EPOCH"; |
| 933 |
SELECT @ndb_max_replicated_epoch:=VARIABLE_VALUE FROM performance_schema.global_status WHERE VARIABLE_NAME LIKE "NDB_SLAVE_MAX_REPLICATED_EPOCH"; |
| 934 |
--enable_result_log |
| 935 |
--enable_query_log |
| 936 |
#SELECT @ndb_last_conflict_epoch, @ndb_last_stable_epoch, @ndb_max_replicated_epoch; |
| 937 |
|
| 938 |
--echo Expect 1,0,1 - stability has returned |
| 939 |
SELECT (@ndb_last_conflict_epoch+0) <= (@ndb_max_replicated_epoch+0) AS SECONDARY_IS_CURRENTLY_CONFLICT_FREE; |
| 940 |
SELECT (@ndb_last_stable_epoch+0) < (@ndb_max_replicated_epoch+0) AS STABLE_EPOCH_LAGS_MAX_REPLICATED_EPOCH; |
| 941 |
SELECT (@ndb_last_stable_epoch+0) = (@ndb_max_replicated_epoch+0) AS STABLE_EPOCH_IS_MAX_REPLICATED_EPOCH; |
| 942 |
|
| 943 |
--echo Done. |
| 944 |
|
| 945 |
|
| 946 |
--echo Cleanup conflict roles |
| 947 |
--echo -------------------- |
| 948 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 949 |
STOP SLAVE; |
| 950 |
set global ndb_applier_conflict_role="NONE"; |
| 951 |
START SLAVE; |
| 952 |
--source suite/ndb_rpl/t/ndb_connect_to_secondary.inc |
| 953 |
STOP SLAVE; |
| 954 |
set global ndb_applier_conflict_role="NONE"; |
| 955 |
START SLAVE; |
| 956 |
--source suite/ndb_rpl/t/ndb_connect_to_primary.inc |
| 957 |
|
| 958 |
|
| 959 |
# Note use of fixed connection names here. |
| 960 |
--connection master |
| 961 |
stop slave; |
| 962 |
reset slave; |
| 963 |
drop table test.t1; |
| 964 |
drop table test.t1$EX; |
| 965 |
drop table mysql.ndb_replication; |
| 966 |
--sync_slave_with_master slave |
| 967 |
|
| 968 |
--source include/rpl_end.inc |