| 1 |
# |
| 2 |
# Test basic read tracking for engine native |
| 3 |
# conflict resolution for ndb |
| 4 |
# |
| 5 |
# |
| 6 |
--source include/have_ndb.inc |
| 7 |
--source include/have_binlog_format_mixed_or_row.inc |
| 8 |
--source suite/ndb_rpl/ndb_master-slave.inc |
| 9 |
--source suite/ndb_rpl/t/ndb_trans_conflict_info_init.inc |
| 10 |
|
| 11 |
--echo Setup circular replication |
| 12 |
|
| 13 |
--connection slave |
| 14 |
RESET MASTER; |
| 15 |
let $SLAVE_SERVER_ID= `select @@server_id`; |
| 16 |
echo SLAVE_SERVER_ID: $SLAVE_SERVER_ID; |
| 17 |
|
| 18 |
--connection master |
| 19 |
--replace_result $SLAVE_MYPORT SLAVE_PORT |
| 20 |
--eval CHANGE REPLICATION SOURCE TO SOURCE_HOST="127.0.0.1",SOURCE_PORT=$SLAVE_MYPORT,SOURCE_USER="root" |
| 21 |
START REPLICA; |
| 22 |
let $MASTER_SERVER_ID= `select @@server_id`; |
| 23 |
echo MASTER_SERVER_ID: $MASTER_SERVER_ID; |
| 24 |
|
| 25 |
--echo Setup ndb_replication and t1$EX exceptions table |
| 26 |
|
| 27 |
--disable_warnings |
| 28 |
--disable_query_log |
| 29 |
--connection master |
| 30 |
drop table if exists mysql.ndb_replication; |
| 31 |
CREATE TABLE mysql.ndb_replication |
| 32 |
(db VARBINARY(63), |
| 33 |
table_name VARBINARY(63), |
| 34 |
server_id INT UNSIGNED, |
| 35 |
binlog_type INT UNSIGNED, |
| 36 |
conflict_fn VARBINARY(128), |
| 37 |
PRIMARY KEY USING HASH (db,table_name,server_id)) |
| 38 |
ENGINE=NDB PARTITION BY KEY(db,table_name); |
| 39 |
|
| 40 |
create table test.t1$EX |
| 41 |
(NDB$SERVER_ID int unsigned, |
| 42 |
NDB$MASTER_SERVER_ID int unsigned, |
| 43 |
NDB$MASTER_EPOCH bigint unsigned, |
| 44 |
NDB$COUNT int unsigned, |
| 45 |
a int not null, |
| 46 |
b$old varchar(2000), |
| 47 |
b$new varchar(2000), |
| 48 |
NDB$OP_TYPE ENUM('WRITE_ROW','UPDATE_ROW','DELETE_ROW','REFRESH_ROW','READ_ROW') NOT NULL, |
| 49 |
NDB$CFT_CAUSE ENUM('ROW_DOES_NOT_EXIST','ROW_ALREADY_EXISTS','DATA_IN_CONFLICT','TRANS_IN_CONFLICT') NOT NULL, |
| 50 |
NDB$ORIG_TRANSID BIGINT UNSIGNED NOT NULL, |
| 51 |
primary key(NDB$SERVER_ID, NDB$MASTER_SERVER_ID, NDB$MASTER_EPOCH, NDB$COUNT)) |
| 52 |
ENGINE=NDB CHARACTER SET latin1; |
| 53 |
|
| 54 |
create table test.t2$EX |
| 55 |
(NDB$SERVER_ID int unsigned, |
| 56 |
NDB$MASTER_SERVER_ID int unsigned, |
| 57 |
NDB$MASTER_EPOCH bigint unsigned, |
| 58 |
NDB$COUNT int unsigned, |
| 59 |
a int not null, |
| 60 |
b$old varchar(2000), |
| 61 |
b$new varchar(2000), |
| 62 |
NDB$OP_TYPE ENUM('WRITE_ROW','UPDATE_ROW','DELETE_ROW','REFRESH_ROW','READ_ROW') NOT NULL, |
| 63 |
NDB$CFT_CAUSE ENUM('ROW_DOES_NOT_EXIST','ROW_ALREADY_EXISTS','DATA_IN_CONFLICT','TRANS_IN_CONFLICT') NOT NULL, |
| 64 |
NDB$ORIG_TRANSID BIGINT UNSIGNED NOT NULL, |
| 65 |
primary key(NDB$SERVER_ID, NDB$MASTER_SERVER_ID, NDB$MASTER_EPOCH, NDB$COUNT)) |
| 66 |
ENGINE=NDB CHARACTER SET latin1; |
| 67 |
|
| 68 |
--enable_warnings |
| 69 |
--enable_query_log |
| 70 |
|
| 71 |
--echo Populate ndb_replication table as necessary |
| 72 |
eval replace into mysql.ndb_replication values |
| 73 |
("test", "t1", $SLAVE_SERVER_ID, 7, NULL), |
| 74 |
("test", "t1", $MASTER_SERVER_ID, 7, "NDB\$EPOCH_TRANS()"), |
| 75 |
("test", "t2", $SLAVE_SERVER_ID, 7, NULL), |
| 76 |
("test", "t2", $MASTER_SERVER_ID, 7, "NDB\$EPOCH_TRANS()"); |
| 77 |
|
| 78 |
|
| 79 |
create table test.t1 ( |
| 80 |
a int primary key, |
| 81 |
b varchar(2000)) engine=ndb character set latin1; |
| 82 |
|
| 83 |
create table test.t2 ( |
| 84 |
a int primary key, |
| 85 |
b varchar(2000)) engine=ndb character set latin1; |
| 86 |
|
| 87 |
--sync_slave_with_master slave |
| 88 |
|
| 89 |
--connection master |
| 90 |
--echo Add some data |
| 91 |
insert into test.t1 values |
| 92 |
(1, "Initial data 1"), |
| 93 |
(2, "Initial data 2"), |
| 94 |
(3, "Initial data 3"), |
| 95 |
(4, "Initial data 4"), |
| 96 |
(5, "Initial data 5"), |
| 97 |
(6, "Initial data 6"), |
| 98 |
(7, "Initial data 7"), |
| 99 |
(8, "Initial data 8"), |
| 100 |
(9, "Initial data 9"), |
| 101 |
(10, "Initial data 10"); |
| 102 |
|
| 103 |
insert into test.t2 values |
| 104 |
(1, "Initial data 1"), |
| 105 |
(2, "Initial data 2"), |
| 106 |
(3, "Initial data 3"), |
| 107 |
(4, "Initial data 4"), |
| 108 |
(5, "Initial data 5"), |
| 109 |
(6, "Initial data 6"), |
| 110 |
(7, "Initial data 7"), |
| 111 |
(8, "Initial data 8"), |
| 112 |
(9, "Initial data 9"), |
| 113 |
(10, "Initial data 10"); |
| 114 |
|
| 115 |
--echo Sync all changes |
| 116 |
--echo --------------------------------------- |
| 117 |
--sync_slave_with_master slave |
| 118 |
--sync_slave_with_master master |
| 119 |
|
| 120 |
-- echo Test 1, read-update conflict without read tracking |
| 121 |
|
| 122 |
--connection slave |
| 123 |
--echo Stopping secondary replica |
| 124 |
stop replica; |
| 125 |
|
| 126 |
--connection master |
| 127 |
--echo Stopping primary replica |
| 128 |
stop replica; |
| 129 |
|
| 130 |
begin; |
| 131 |
update test.t1 set b="Primary first change 1" where a=1; |
| 132 |
update test.t1 set b="Primary first change 2" where a=2; |
| 133 |
commit; |
| 134 |
|
| 135 |
--connection slave |
| 136 |
SET ndb_log_exclusive_reads= 0; |
| 137 |
begin; |
| 138 |
select * from test.t1 where a = 1 for update; |
| 139 |
update test.t2 set b="Secondary first change 3" where a=3; |
| 140 |
commit; |
| 141 |
|
| 142 |
--echo Checking tables before conflict resolution |
| 143 |
--echo --------------------------------------- |
| 144 |
--connection master |
| 145 |
--echo **** Primary **** |
| 146 |
select * from test.t1 order by a; |
| 147 |
select * from test.t2 order by a; |
| 148 |
|
| 149 |
--echo Starting primary replica |
| 150 |
start replica; |
| 151 |
|
| 152 |
--connection slave |
| 153 |
--echo **** Secondary **** |
| 154 |
select * from test.t1 order by a; |
| 155 |
select * from test.t2 order by a; |
| 156 |
|
| 157 |
--sync_slave_with_master master |
| 158 |
|
| 159 |
--echo Primary should not have rejected change from Secondary |
| 160 |
|
| 161 |
select * from test.t1 order by a; |
| 162 |
select * from test.t2 order by a; |
| 163 |
|
| 164 |
--source suite/ndb_rpl/t/ndb_trans_conflict_info.inc |
| 165 |
|
| 166 |
--source suite/ndb_rpl/t/ndb_trans_conflict_info_init.inc |
| 167 |
|
| 168 |
select NDB$OP_TYPE, b$old, b$new, NDB$CFT_CAUSE from test.t1$EX |
| 169 |
order by a; |
| 170 |
select NDB$OP_TYPE, b$old, b$new, NDB$CFT_CAUSE from test.t2$EX |
| 171 |
order by a; |
| 172 |
|
| 173 |
--connection slave |
| 174 |
-- Echo starting secondary replica |
| 175 |
start replica; |
| 176 |
|
| 177 |
--connection master |
| 178 |
--sync_slave_with_master slave |
| 179 |
|
| 180 |
--connection slave |
| 181 |
|
| 182 |
--echo Secondary should not have been realigned to Primary |
| 183 |
--connection master |
| 184 |
--echo **** Primary **** |
| 185 |
select * from test.t1 order by a; |
| 186 |
select * from test.t2 order by a; |
| 187 |
|
| 188 |
--connection slave |
| 189 |
--echo **** Secondary **** |
| 190 |
select * from test.t1 order by a; |
| 191 |
select * from test.t2 order by a; |
| 192 |
|
| 193 |
--connection master |
| 194 |
update test.t1 set b="Initial data 1" where a=1; |
| 195 |
update test.t1 set b="Initial data 2" where a=2; |
| 196 |
update test.t2 set b="Initial data 3" where a=3; |
| 197 |
--echo Sync all changes |
| 198 |
--echo --------------------------------------- |
| 199 |
--sync_slave_with_master slave |
| 200 |
--sync_slave_with_master master |
| 201 |
delete from test.t2$EX; |
| 202 |
|
| 203 |
-- echo Test 2, read-update conflict with read tracking |
| 204 |
|
| 205 |
--connection slave |
| 206 |
--echo Stopping secondary replica |
| 207 |
stop replica; |
| 208 |
|
| 209 |
--connection master |
| 210 |
--echo Stopping primary replica |
| 211 |
stop replica; |
| 212 |
|
| 213 |
begin; |
| 214 |
update test.t1 set b="Primary first change 1" where a=1; |
| 215 |
update test.t1 set b="Primary first change 2" where a=2; |
| 216 |
commit; |
| 217 |
|
| 218 |
--connection slave |
| 219 |
SET ndb_log_exclusive_reads= 1; |
| 220 |
begin; |
| 221 |
select * from test.t1 where a = 1 for update; |
| 222 |
update test.t2 set b="Secondary first change 3" where a=3; |
| 223 |
commit; |
| 224 |
|
| 225 |
--echo Checking tables before conflict resolution |
| 226 |
--echo --------------------------------------- |
| 227 |
--connection master |
| 228 |
--echo **** Primary **** |
| 229 |
select * from test.t1 order by a; |
| 230 |
select * from test.t2 order by a; |
| 231 |
|
| 232 |
--echo Starting primary replica |
| 233 |
start replica; |
| 234 |
|
| 235 |
--connection slave |
| 236 |
--echo **** Secondary **** |
| 237 |
select * from test.t1 order by a; |
| 238 |
select * from test.t2 order by a; |
| 239 |
|
| 240 |
--sync_slave_with_master master |
| 241 |
|
| 242 |
--echo Primary should have rejected change from Secondary, keeping its value |
| 243 |
|
| 244 |
select * from test.t1 order by a; |
| 245 |
select * from test.t2 order by a; |
| 246 |
|
| 247 |
--source suite/ndb_rpl/t/ndb_trans_conflict_info.inc |
| 248 |
|
| 249 |
--source suite/ndb_rpl/t/ndb_trans_conflict_info_init.inc |
| 250 |
|
| 251 |
select NDB$OP_TYPE, b$old, b$new, NDB$CFT_CAUSE from test.t1$EX |
| 252 |
order by a; |
| 253 |
select NDB$OP_TYPE, b$old, b$new, NDB$CFT_CAUSE from test.t2$EX |
| 254 |
order by a; |
| 255 |
|
| 256 |
--connection slave |
| 257 |
-- Echo starting secondary replica |
| 258 |
start replica; |
| 259 |
|
| 260 |
--connection master |
| 261 |
--sync_slave_with_master slave |
| 262 |
|
| 263 |
--connection slave |
| 264 |
|
| 265 |
--echo Secondary should have been realigned to Primary |
| 266 |
--connection master |
| 267 |
--echo **** Primary **** |
| 268 |
select * from test.t1 order by a; |
| 269 |
select * from test.t2 order by a; |
| 270 |
|
| 271 |
--connection slave |
| 272 |
--echo **** Secondary **** |
| 273 |
select * from test.t1 order by a; |
| 274 |
select * from test.t2 order by a; |
| 275 |
|
| 276 |
--connection master |
| 277 |
update test.t1 set b="Initial data 1" where a=1; |
| 278 |
update test.t1 set b="Initial data 2" where a=2; |
| 279 |
update test.t2 set b="Initial data 3" where a=3; |
| 280 |
--echo Sync all changes |
| 281 |
--echo --------------------------------------- |
| 282 |
--sync_slave_with_master slave |
| 283 |
--sync_slave_with_master master |
| 284 |
delete from test.t1$EX; |
| 285 |
delete from test.t2$EX; |
| 286 |
|
| 287 |
-- echo Test 3, read-read conflict without read tracking |
| 288 |
|
| 289 |
--connection slave |
| 290 |
--echo Stopping secondary replica |
| 291 |
stop replica; |
| 292 |
|
| 293 |
--connection master |
| 294 |
--echo Stopping primary replica |
| 295 |
stop replica; |
| 296 |
|
| 297 |
SET ndb_log_exclusive_reads= 0; |
| 298 |
begin; |
| 299 |
select * from test.t1 where a = 1 for update; |
| 300 |
update test.t1 set b="Primary first change 2" where a=2; |
| 301 |
commit; |
| 302 |
|
| 303 |
--connection slave |
| 304 |
SET ndb_log_exclusive_reads= 0; |
| 305 |
begin; |
| 306 |
select * from test.t1 where a = 1 for update; |
| 307 |
update test.t2 set b="Secondary first change 3" where a=3; |
| 308 |
commit; |
| 309 |
|
| 310 |
--echo Checking tables before conflict resolution |
| 311 |
--echo --------------------------------------- |
| 312 |
--connection master |
| 313 |
--echo **** Primary **** |
| 314 |
select * from test.t1 order by a; |
| 315 |
select * from test.t2 order by a; |
| 316 |
|
| 317 |
--echo Starting primary replica |
| 318 |
start replica; |
| 319 |
|
| 320 |
--connection slave |
| 321 |
--echo **** Secondary **** |
| 322 |
select * from test.t1 order by a; |
| 323 |
select * from test.t2 order by a; |
| 324 |
|
| 325 |
--sync_slave_with_master master |
| 326 |
|
| 327 |
--echo Primary should not have rejected change from Secondary |
| 328 |
|
| 329 |
select * from test.t1 order by a; |
| 330 |
select * from test.t2 order by a; |
| 331 |
|
| 332 |
--source suite/ndb_rpl/t/ndb_trans_conflict_info.inc |
| 333 |
|
| 334 |
--source suite/ndb_rpl/t/ndb_trans_conflict_info_init.inc |
| 335 |
|
| 336 |
select NDB$OP_TYPE, b$old, b$new, NDB$CFT_CAUSE from test.t1$EX |
| 337 |
order by a; |
| 338 |
select NDB$OP_TYPE, b$old, b$new, NDB$CFT_CAUSE from test.t2$EX |
| 339 |
order by a; |
| 340 |
|
| 341 |
--connection slave |
| 342 |
-- Echo starting secondary replica |
| 343 |
start replica; |
| 344 |
|
| 345 |
--connection master |
| 346 |
--sync_slave_with_master slave |
| 347 |
|
| 348 |
--connection slave |
| 349 |
|
| 350 |
--echo Secondary should not have been realigned to Primary |
| 351 |
--connection master |
| 352 |
--echo **** Primary **** |
| 353 |
select * from test.t1 order by a; |
| 354 |
select * from test.t2 order by a; |
| 355 |
|
| 356 |
--connection slave |
| 357 |
--echo **** Secondary **** |
| 358 |
select * from test.t1 order by a; |
| 359 |
select * from test.t2 order by a; |
| 360 |
|
| 361 |
--connection master |
| 362 |
update test.t1 set b="Initial data 1" where a=1; |
| 363 |
update test.t1 set b="Initial data 2" where a=2; |
| 364 |
update test.t2 set b="Initial data 3" where a=3; |
| 365 |
|
| 366 |
--echo Sync all changes |
| 367 |
--echo --------------------------------------- |
| 368 |
--sync_slave_with_master slave |
| 369 |
--sync_slave_with_master master |
| 370 |
delete from test.t1$EX; |
| 371 |
delete from test.t2$EX; |
| 372 |
-- echo Test 4, read-read conflict with read tracking |
| 373 |
|
| 374 |
--connection slave |
| 375 |
--echo Stopping secondary replica |
| 376 |
stop replica; |
| 377 |
|
| 378 |
--connection master |
| 379 |
--echo Stopping primary replica |
| 380 |
stop replica; |
| 381 |
|
| 382 |
SET ndb_log_exclusive_reads= 1; |
| 383 |
begin; |
| 384 |
select * from test.t1 where a = 1 for update; |
| 385 |
update test.t1 set b="Primary first change 2" where a=2; |
| 386 |
commit; |
| 387 |
|
| 388 |
--connection slave |
| 389 |
SET ndb_log_exclusive_reads= 1; |
| 390 |
begin; |
| 391 |
select * from test.t1 where a = 1 for update; |
| 392 |
update test.t2 set b="Secondary first change 3" where a=3; |
| 393 |
commit; |
| 394 |
|
| 395 |
--echo Checking tables before conflict resolution |
| 396 |
--echo --------------------------------------- |
| 397 |
--connection master |
| 398 |
--echo **** Primary **** |
| 399 |
select * from test.t1 order by a; |
| 400 |
select * from test.t2 order by a; |
| 401 |
|
| 402 |
--echo Starting primary replica |
| 403 |
start replica; |
| 404 |
|
| 405 |
--connection slave |
| 406 |
--echo **** Secondary **** |
| 407 |
select * from test.t1 order by a; |
| 408 |
select * from test.t2 order by a; |
| 409 |
|
| 410 |
--sync_slave_with_master master |
| 411 |
|
| 412 |
--echo Primary should have rejected change from Secondary, keeping its value |
| 413 |
|
| 414 |
select * from test.t1 order by a; |
| 415 |
select * from test.t2 order by a; |
| 416 |
|
| 417 |
--source suite/ndb_rpl/t/ndb_trans_conflict_info.inc |
| 418 |
|
| 419 |
--source suite/ndb_rpl/t/ndb_trans_conflict_info_init.inc |
| 420 |
|
| 421 |
select NDB$OP_TYPE, b$old, b$new, NDB$CFT_CAUSE from test.t1$EX |
| 422 |
order by a; |
| 423 |
select NDB$OP_TYPE, b$old, b$new, NDB$CFT_CAUSE from test.t2$EX |
| 424 |
order by a; |
| 425 |
|
| 426 |
--connection slave |
| 427 |
-- Echo starting secondary replica |
| 428 |
start replica; |
| 429 |
|
| 430 |
--connection master |
| 431 |
--sync_slave_with_master slave |
| 432 |
|
| 433 |
--connection slave |
| 434 |
|
| 435 |
--echo Secondary should have been realigned to Primary |
| 436 |
--connection master |
| 437 |
--echo **** Primary **** |
| 438 |
select * from test.t1 order by a; |
| 439 |
select * from test.t2 order by a; |
| 440 |
|
| 441 |
--connection slave |
| 442 |
--echo **** Secondary **** |
| 443 |
select * from test.t1 order by a; |
| 444 |
select * from test.t2 order by a; |
| 445 |
|
| 446 |
--connection master |
| 447 |
update test.t1 set b="Initial data 1" where a=1; |
| 448 |
update test.t1 set b="Initial data 2" where a=2; |
| 449 |
update test.t2 set b="Initial data 3" where a=3; |
| 450 |
--echo Sync all changes |
| 451 |
--echo --------------------------------------- |
| 452 |
--sync_slave_with_master slave |
| 453 |
--sync_slave_with_master master |
| 454 |
delete from test.t1$EX; |
| 455 |
delete from test.t2$EX; |
| 456 |
|
| 457 |
-- echo Test 5, read-update conflict with read tracking on unique secondary index |
| 458 |
|
| 459 |
create table test.t3$EX |
| 460 |
(NDB$SERVER_ID int unsigned, |
| 461 |
NDB$MASTER_SERVER_ID int unsigned, |
| 462 |
NDB$MASTER_EPOCH bigint unsigned, |
| 463 |
NDB$COUNT int unsigned, |
| 464 |
a int not null, |
| 465 |
b$old varchar(2000), |
| 466 |
b$new varchar(2000), |
| 467 |
c$old int, |
| 468 |
c$new int, |
| 469 |
d$old int, |
| 470 |
d$new int, |
| 471 |
NDB$OP_TYPE ENUM('WRITE_ROW','UPDATE_ROW','DELETE_ROW','REFRESH_ROW','READ_ROW') NOT NULL, |
| 472 |
NDB$CFT_CAUSE ENUM('ROW_DOES_NOT_EXIST','ROW_ALREADY_EXISTS','DATA_IN_CONFLICT','TRANS_IN_CONFLICT') NOT NULL, |
| 473 |
NDB$ORIG_TRANSID BIGINT UNSIGNED NOT NULL, |
| 474 |
primary key(NDB$SERVER_ID, NDB$MASTER_SERVER_ID, NDB$MASTER_EPOCH, NDB$COUNT)) |
| 475 |
ENGINE=NDB CHARACTER SET latin1; |
| 476 |
|
| 477 |
--echo Populate ndb_replication table as necessary |
| 478 |
eval replace into mysql.ndb_replication values |
| 479 |
("test", "t3", $SLAVE_SERVER_ID, 7, NULL), |
| 480 |
("test", "t3", $MASTER_SERVER_ID, 7, "NDB\$EPOCH_TRANS()"); |
| 481 |
|
| 482 |
create table test.t3 ( |
| 483 |
a int primary key, |
| 484 |
b varchar(2000), |
| 485 |
c int not null unique, |
| 486 |
d int, |
| 487 |
key(d)) engine=ndb character set latin1; |
| 488 |
|
| 489 |
--sync_slave_with_master slave |
| 490 |
|
| 491 |
--connection master |
| 492 |
--echo Add some data |
| 493 |
|
| 494 |
insert into test.t3 values |
| 495 |
(1, "Initial data 1", 1, 1), |
| 496 |
(2, "Initial data 2", 2, 2), |
| 497 |
(3, "Initial data 3", 3, 3), |
| 498 |
(4, "Initial data 4", 4, 4), |
| 499 |
(5, "Initial data 5", 5, 5), |
| 500 |
(6, "Initial data 6", 6, 6), |
| 501 |
(7, "Initial data 7", 7, 7), |
| 502 |
(8, "Initial data 8", 8, 8), |
| 503 |
(9, "Initial data 9", 9, 9), |
| 504 |
(10, "Initial data 10", 10, 10); |
| 505 |
|
| 506 |
--echo Show basic read tracking |
| 507 |
--echo --------------------------------------- |
| 508 |
--sync_slave_with_master slave |
| 509 |
|
| 510 |
--connection slave |
| 511 |
--echo Stopping secondary replica |
| 512 |
stop replica; |
| 513 |
|
| 514 |
--connection master |
| 515 |
--echo Stopping primary replica |
| 516 |
stop replica; |
| 517 |
|
| 518 |
begin; |
| 519 |
update test.t3 set b="Primary first change 1" where a=1; |
| 520 |
update test.t3 set b="Primary first change 2" where a=2; |
| 521 |
commit; |
| 522 |
|
| 523 |
--connection slave |
| 524 |
SET ndb_log_exclusive_reads= 1; |
| 525 |
begin; |
| 526 |
select * from test.t3 where c = 1 for update; |
| 527 |
update test.t2 set b="Secondary first change 3" where a=3; |
| 528 |
commit; |
| 529 |
|
| 530 |
--echo Checking tables before conflict resolution |
| 531 |
--echo --------------------------------------- |
| 532 |
--connection master |
| 533 |
--echo **** Primary **** |
| 534 |
select * from test.t2 order by a; |
| 535 |
select * from test.t3 order by a; |
| 536 |
|
| 537 |
--echo Starting primary replica |
| 538 |
start replica; |
| 539 |
|
| 540 |
--connection slave |
| 541 |
--echo **** Secondary **** |
| 542 |
select * from test.t2 order by a; |
| 543 |
select * from test.t3 order by a; |
| 544 |
|
| 545 |
--sync_slave_with_master master |
| 546 |
|
| 547 |
--echo Primary should have rejected change from Secondary, keeping its value |
| 548 |
|
| 549 |
select * from test.t2 order by a; |
| 550 |
select * from test.t3 order by a; |
| 551 |
|
| 552 |
--source suite/ndb_rpl/t/ndb_trans_conflict_info.inc |
| 553 |
|
| 554 |
--source suite/ndb_rpl/t/ndb_trans_conflict_info_init.inc |
| 555 |
|
| 556 |
select NDB$OP_TYPE, b$old, b$new, c$old, c$new, NDB$CFT_CAUSE from test.t3$EX |
| 557 |
order by a; |
| 558 |
|
| 559 |
--connection slave |
| 560 |
-- Echo starting secondary replica |
| 561 |
start replica; |
| 562 |
|
| 563 |
--connection master |
| 564 |
--sync_slave_with_master slave |
| 565 |
|
| 566 |
--connection slave |
| 567 |
|
| 568 |
--echo Secondary should have been realigned to Primary |
| 569 |
--connection master |
| 570 |
--echo **** Primary **** |
| 571 |
select * from test.t2 order by a; |
| 572 |
select * from test.t3 order by a; |
| 573 |
|
| 574 |
--connection slave |
| 575 |
--echo **** Secondary **** |
| 576 |
select * from test.t2 order by a; |
| 577 |
select * from test.t3 order by a; |
| 578 |
|
| 579 |
--connection master |
| 580 |
update test.t2 set b="Initial data 3" where a=3; |
| 581 |
update test.t3 set b="Initial data 1" where a=1; |
| 582 |
update test.t3 set b="Initial data 2" where a=2; |
| 583 |
--echo Sync all changes |
| 584 |
--echo --------------------------------------- |
| 585 |
--sync_slave_with_master slave |
| 586 |
--sync_slave_with_master master |
| 587 |
delete from test.t2$EX; |
| 588 |
delete from test.t3$EX; |
| 589 |
|
| 590 |
-- echo Test 6, read-update conflict with read tracking on ordered secondary index |
| 591 |
|
| 592 |
--echo Show basic read tracking |
| 593 |
--echo --------------------------------------- |
| 594 |
--sync_slave_with_master slave |
| 595 |
|
| 596 |
--connection slave |
| 597 |
--echo Stopping secondary replica |
| 598 |
stop replica; |
| 599 |
|
| 600 |
--connection master |
| 601 |
--echo Stopping primary replica |
| 602 |
stop replica; |
| 603 |
|
| 604 |
begin; |
| 605 |
update test.t3 set b="Primary first change 1" where a=1; |
| 606 |
update test.t3 set b="Primary first change 2" where a=2; |
| 607 |
commit; |
| 608 |
|
| 609 |
--connection slave |
| 610 |
SET ndb_log_exclusive_reads= 1; |
| 611 |
begin; |
| 612 |
select * from test.t3 where d = 1 for update; |
| 613 |
update test.t2 set b="Secondary first change 3" where a=3; |
| 614 |
commit; |
| 615 |
|
| 616 |
--echo Checking tables before conflict resolution |
| 617 |
--echo --------------------------------------- |
| 618 |
--connection master |
| 619 |
--echo **** Primary **** |
| 620 |
select * from test.t2 order by a; |
| 621 |
select * from test.t3 order by a; |
| 622 |
|
| 623 |
--echo Starting primary replica |
| 624 |
start replica; |
| 625 |
|
| 626 |
--connection slave |
| 627 |
--echo **** Secondary **** |
| 628 |
select * from test.t2 order by a; |
| 629 |
select * from test.t3 order by a; |
| 630 |
|
| 631 |
--sync_slave_with_master master |
| 632 |
|
| 633 |
--echo Primary should have rejected change from Secondary, keeping its value |
| 634 |
|
| 635 |
select * from test.t2 order by a; |
| 636 |
select * from test.t3 order by a; |
| 637 |
|
| 638 |
--source suite/ndb_rpl/t/ndb_trans_conflict_info.inc |
| 639 |
|
| 640 |
--source suite/ndb_rpl/t/ndb_trans_conflict_info_init.inc |
| 641 |
|
| 642 |
select NDB$OP_TYPE, b$old, b$new, c$old, c$new, NDB$CFT_CAUSE from test.t3$EX |
| 643 |
order by a; |
| 644 |
|
| 645 |
--connection slave |
| 646 |
-- Echo starting secondary replica |
| 647 |
start replica; |
| 648 |
|
| 649 |
--connection master |
| 650 |
--sync_slave_with_master slave |
| 651 |
|
| 652 |
--connection slave |
| 653 |
|
| 654 |
--echo Secondary should have been realigned to Primary |
| 655 |
--connection master |
| 656 |
--echo **** Primary **** |
| 657 |
select * from test.t2 order by a; |
| 658 |
select * from test.t3 order by a; |
| 659 |
|
| 660 |
--connection slave |
| 661 |
--echo **** Secondary **** |
| 662 |
select * from test.t2 order by a; |
| 663 |
select * from test.t3 order by a; |
| 664 |
|
| 665 |
--connection master |
| 666 |
update test.t2 set b="Initial data 3" where a=3; |
| 667 |
update test.t3 set b="Initial data 1" where a=1; |
| 668 |
update test.t3 set b="Initial data 2" where a=2; |
| 669 |
--echo Sync all changes |
| 670 |
--echo --------------------------------------- |
| 671 |
--sync_slave_with_master slave |
| 672 |
--sync_slave_with_master master |
| 673 |
delete from test.t2$EX; |
| 674 |
delete from test.t3$EX; |
| 675 |
|
| 676 |
-- echo Test 7, read-update conflict with read tracking on table scan |
| 677 |
|
| 678 |
--echo Show basic read tracking |
| 679 |
--echo --------------------------------------- |
| 680 |
--sync_slave_with_master slave |
| 681 |
|
| 682 |
--connection slave |
| 683 |
--echo Stopping secondary replica |
| 684 |
stop replica; |
| 685 |
|
| 686 |
--connection master |
| 687 |
--echo Stopping primary replica |
| 688 |
stop replica; |
| 689 |
|
| 690 |
begin; |
| 691 |
update test.t3 set b="Primary first change 1" where a=1; |
| 692 |
update test.t3 set b="Primary first change 2" where a=2; |
| 693 |
commit; |
| 694 |
|
| 695 |
--connection slave |
| 696 |
SET ndb_log_exclusive_reads= 1; |
| 697 |
begin; |
| 698 |
select * from test.t3 where b like "Initial data 1" for update; |
| 699 |
update test.t2 set b="Secondary first change 3" where a=3; |
| 700 |
commit; |
| 701 |
|
| 702 |
--echo Checking tables before conflict resolution |
| 703 |
--echo --------------------------------------- |
| 704 |
--connection master |
| 705 |
--echo **** Primary **** |
| 706 |
select * from test.t2 order by a; |
| 707 |
select * from test.t3 order by a; |
| 708 |
|
| 709 |
--echo Starting primary replica |
| 710 |
start replica; |
| 711 |
|
| 712 |
--connection slave |
| 713 |
--echo **** Secondary **** |
| 714 |
select * from test.t2 order by a; |
| 715 |
select * from test.t3 order by a; |
| 716 |
|
| 717 |
--sync_slave_with_master master |
| 718 |
|
| 719 |
--echo Primary should have rejected change from Secondary, keeping its value |
| 720 |
|
| 721 |
select * from test.t2 order by a; |
| 722 |
select * from test.t3 order by a; |
| 723 |
|
| 724 |
--source suite/ndb_rpl/t/ndb_trans_conflict_info.inc |
| 725 |
|
| 726 |
--source suite/ndb_rpl/t/ndb_trans_conflict_info_init.inc |
| 727 |
|
| 728 |
select NDB$OP_TYPE, b$old, b$new, c$old, c$new, NDB$CFT_CAUSE from test.t3$EX |
| 729 |
order by a; |
| 730 |
|
| 731 |
--connection slave |
| 732 |
-- Echo starting secondary replica |
| 733 |
start replica; |
| 734 |
|
| 735 |
--connection master |
| 736 |
--sync_slave_with_master slave |
| 737 |
|
| 738 |
--connection slave |
| 739 |
|
| 740 |
--echo Secondary should have been realigned to Primary |
| 741 |
--connection master |
| 742 |
--echo **** Primary **** |
| 743 |
select * from test.t2 order by a; |
| 744 |
select * from test.t3 order by a; |
| 745 |
|
| 746 |
--connection slave |
| 747 |
--echo **** Secondary **** |
| 748 |
select * from test.t2 order by a; |
| 749 |
select * from test.t3 order by a; |
| 750 |
|
| 751 |
--connection master |
| 752 |
update test.t2 set b="Initial data 3" where a=3; |
| 753 |
update test.t3 set b="Initial data 1" where a=1; |
| 754 |
update test.t3 set b="Initial data 2" where a=2; |
| 755 |
--echo Sync all changes |
| 756 |
--echo --------------------------------------- |
| 757 |
--sync_slave_with_master slave |
| 758 |
--sync_slave_with_master master |
| 759 |
delete from test.t2$EX; |
| 760 |
delete from test.t3$EX; |
| 761 |
|
| 762 |
# Cleanup |
| 763 |
--connection master |
| 764 |
drop table mysql.ndb_replication; |
| 765 |
drop table test.t1, test.t2, test.t3; |
| 766 |
drop table test.t1$EX, test.t2$EX, test.t3$EX; |
| 767 |
|
| 768 |
--sync_slave_with_master slave |
| 769 |
|
| 770 |
--connection slave |
| 771 |
SET ndb_log_exclusive_reads= 0; |
| 772 |
flush logs; |
| 773 |
--sync_slave_with_master master |
| 774 |
stop replica; |
| 775 |
reset replica; |
| 776 |
--source include/rpl_end.inc |