| 1 |
include/master-slave.inc |
| 2 |
Warnings: |
| 3 |
Note #### Sending passwords in plain text without SSL/TLS is extremely insecure. |
| 4 |
Note #### Storing MySQL user name or password information in the connection metadata repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START REPLICA; see the 'START REPLICA Syntax' in the MySQL Manual for more information. |
| 5 |
[connection master] |
| 6 |
CREATE TABLE t1 (c1 CHAR(15), c2 CHAR(15), c3 INT, PRIMARY KEY (c3)) ENGINE = NDB ; |
| 7 |
STOP REPLICA; |
| 8 |
RESET MASTER; |
| 9 |
RESET REPLICA; |
| 10 |
START REPLICA; |
| 11 |
INSERT INTO t1 VALUES ("row1","will go away",1); |
| 12 |
SELECT * FROM t1 ORDER BY c3; |
| 13 |
c1 c2 c3 |
| 14 |
row1 will go away 1 |
| 15 |
SELECT MAX(epoch) FROM mysql.ndb_apply_status into @the_epoch; |
| 16 |
SELECT @the_epoch; |
| 17 |
@the_epoch |
| 18 |
<the_epoch> |
| 19 |
SELECT * FROM t1 ORDER BY c3; |
| 20 |
c1 c2 c3 |
| 21 |
row1 will go away 1 |
| 22 |
INSERT INTO t1 VALUES ("row2","will go away",2),("row3","will change",3),("row4","D",4); |
| 23 |
DELETE FROM t1 WHERE c3 = 1; |
| 24 |
UPDATE t1 SET c2="should go away" WHERE c3 = 2; |
| 25 |
UPDATE t1 SET c2="C" WHERE c3 = 3; |
| 26 |
DELETE FROM t1 WHERE c3 = 2; |
| 27 |
SELECT * FROM t1 ORDER BY c3; |
| 28 |
c1 c2 c3 |
| 29 |
row3 C 3 |
| 30 |
row4 D 4 |
| 31 |
SELECT * FROM t1 ORDER BY c3; |
| 32 |
c1 c2 c3 |
| 33 |
row3 C 3 |
| 34 |
row4 D 4 |
| 35 |
include/check_slave_is_running.inc |
| 36 |
STOP REPLICA; |
| 37 |
include/check_slave_no_error.inc |
| 38 |
START REPLICA; |
| 39 |
SELECT * FROM t1 ORDER BY c3; |
| 40 |
c1 c2 c3 |
| 41 |
row3 C 3 |
| 42 |
row4 D 4 |
| 43 |
SELECT * FROM t1 ORDER BY c3; |
| 44 |
c1 c2 c3 |
| 45 |
row3 C 3 |
| 46 |
row4 D 4 |
| 47 |
STOP REPLICA; |
| 48 |
DROP TABLE t1; |
| 49 |
RESET master; |
| 50 |
DROP TABLE t1; |
| 51 |
RESET REPLICA; |
| 52 |
START REPLICA; |
| 53 |
CREATE TABLE t1 (c1 CHAR(15) NOT NULL, c2 CHAR(15) NOT NULL, c3 INT NOT NULL, PRIMARY KEY (c3)) ENGINE = NDB ; |
| 54 |
INSERT INTO t1 VALUES ("row1","remove on slave",1); |
| 55 |
DELETE FROM t1; |
| 56 |
BEGIN; |
| 57 |
UPDATE t1 SET c2="does not exist" WHERE c3=1; |
| 58 |
INSERT INTO t1 VALUES ("row2","new on slave",2); |
| 59 |
COMMIT; |
| 60 |
SELECT * FROM t1; |
| 61 |
c1 c2 c3 |
| 62 |
row2 new on slave 2 |
| 63 |
include/check_slave_is_running.inc |
| 64 |
DROP TABLE IF EXISTS t1; |
| 65 |
STOP REPLICA; |
| 66 |
RESET MASTER; |
| 67 |
RESET REPLICA; |
| 68 |
START REPLICA; |
| 69 |
Let's interleave some DDL and DML in the Binlog |
| 70 |
Some DDL |
| 71 |
create table t1(a int primary key) engine=ndb; |
| 72 |
First epoch transaction |
| 73 |
begin; |
| 74 |
insert into t1 values (1), (2), (3); |
| 75 |
commit; |
| 76 |
Sync slave and retrieve epoch |
| 77 |
SELECT MAX(epoch) FROM mysql.ndb_apply_status into @first_epoch; |
| 78 |
SELECT @first_epoch; |
| 79 |
@first_epoch |
| 80 |
<first_epoch> |
| 81 |
Slave contents |
| 82 |
select * from t1 ORDER by a; |
| 83 |
a |
| 84 |
1 |
| 85 |
2 |
| 86 |
3 |
| 87 |
Get the next master binlog pos from the epoch |
| 88 |
Now let's do some more DDL and DML |
| 89 |
create table t2 (a int primary key) engine=ndb; |
| 90 |
begin; |
| 91 |
insert into t2 values (1), (2), (3); |
| 92 |
commit; |
| 93 |
include/check_slave_is_running.inc |
| 94 |
Stop slave and reset position to start of the applied epoch |
| 95 |
STOP REPLICA; |
| 96 |
include/check_slave_no_error.inc |
| 97 |
call mtr.add_suppression("Table \'t2\' already exists.*"); |
| 98 |
call mtr.add_suppression("Worker 1 failed executing transaction.*"); |
| 99 |
START REPLICA; |
| 100 |
include/wait_for_slave_sql_error.inc [errno=1050] |
| 101 |
SELECT COUNT(*) as FOUND_ERROR_MESSAGE |
| 102 |
FROM performance_schema.replication_applier_status_by_worker |
| 103 |
WHERE LAST_ERROR_NUMBER=1050 AND channel_name = '' AND |
| 104 |
LAST_ERROR_MESSAGE LIKE "%Table 't2' already exists%"; |
| 105 |
FOUND_ERROR_MESSAGE |
| 106 |
1 |
| 107 |
STOP REPLICA; |
| 108 |
RESET MASTER; |
| 109 |
RESET REPLICA; |
| 110 |
START REPLICA; |
| 111 |
DROP TABLE t1; |
| 112 |
DROP TABLE t2; |
| 113 |
include/rpl_end.inc |