| 1 |
include/master-slave.inc |
| 2 |
[connection master] |
| 3 |
connection server_2; |
| 4 |
call mtr.add_suppression("Timeout waiting for reply of binlog"); |
| 5 |
# Master server_1 and Slave server_2 initialization ... |
| 6 |
connection server_2; |
| 7 |
include/stop_slave.inc |
| 8 |
connection server_1; |
| 9 |
RESET MASTER; |
| 10 |
set @@session.gtid_domain_id=10; |
| 11 |
set @@global.rpl_semi_sync_master_enabled = 1; |
| 12 |
set @@global.rpl_semi_sync_master_wait_point=AFTER_SYNC; |
| 13 |
connection server_2; |
| 14 |
RESET MASTER; |
| 15 |
ALTER TABLE mysql.gtid_slave_pos ENGINE=InnoDB; |
| 16 |
set @@session.gtid_domain_id=20; |
| 17 |
set @@global.rpl_semi_sync_slave_enabled = 1; |
| 18 |
# a 1948 warning is expected |
| 19 |
set @@global.gtid_slave_pos = ""; |
| 20 |
Warnings: |
| 21 |
Warning 1948 Specified value for @@gtid_slave_pos contains no value for replication domain 0. This conflicts with the binary log which contains GTID 0-2-1. If MASTER_GTID_POS=CURRENT_POS is used, the binlog position will override the new value of @@gtid_slave_pos |
| 22 |
CHANGE MASTER TO master_use_gtid= slave_pos; |
| 23 |
include/start_slave.inc |
| 24 |
# server_1 -> server_2 semisync link is set up. |
| 25 |
connection server_1; |
| 26 |
CREATE TABLE t1 (a INT PRIMARY KEY, b INT default 0) ENGINE=Innodb; |
| 27 |
INSERT INTO t1(a) VALUES (1); |
| 28 |
include/save_master_gtid.inc |
| 29 |
connection server_2; |
| 30 |
include/sync_with_master_gtid.inc |
| 31 |
# Circular configuration server_1 -> server_2 -> server_1 ... |
| 32 |
connection server_1; |
| 33 |
set @@global.gtid_strict_mode = true; |
| 34 |
set @@global.rpl_semi_sync_slave_enabled = 1; |
| 35 |
CHANGE MASTER TO master_host='127.0.0.1', master_port=$SERVER_MYPORT_2, master_user='root', master_ssl_verify_server_cert=0, master_use_gtid=SLAVE_POS; |
| 36 |
include/start_slave.inc |
| 37 |
... is done. |
| 38 |
## A. no out-of-order gtid error for own transaction made round trip |
| 39 |
connection server_2; |
| 40 |
set @@global.gtid_strict_mode = true; |
| 41 |
set @@global.rpl_semi_sync_master_enabled = 1; |
| 42 |
INSERT INTO t1(a) VALUES (2); |
| 43 |
include/save_master_gtid.inc |
| 44 |
connection server_1; |
| 45 |
include/stop_slave.inc |
| 46 |
include/start_slave.inc |
| 47 |
# |
| 48 |
# the successful sync is a required proof |
| 49 |
# |
| 50 |
include/sync_with_master_gtid.inc |
| 51 |
update t1 set b=b+1 where a=2; |
| 52 |
include/save_master_gtid.inc |
| 53 |
connection server_2; |
| 54 |
include/sync_with_master_gtid.inc |
| 55 |
# Post-execution state check on both servers synchronized with each other |
| 56 |
connection server_1; |
| 57 |
# ... the gtid states on server_1 |
| 58 |
SHOW VARIABLES LIKE 'gtid_slave_pos'; |
| 59 |
Variable_name Value |
| 60 |
gtid_slave_pos 0-2-1,10-1-3,20-2-1 |
| 61 |
SHOW VARIABLES LIKE 'gtid_binlog_pos'; |
| 62 |
Variable_name Value |
| 63 |
gtid_binlog_pos 0-2-1,10-1-3,20-2-1 |
| 64 |
SELECT * from t1; |
| 65 |
a b |
| 66 |
1 0 |
| 67 |
2 1 |
| 68 |
connection server_2; |
| 69 |
# The gtid states on server_2 must be equal to ... |
| 70 |
SHOW VARIABLES LIKE 'gtid_binlog_pos'; |
| 71 |
Variable_name Value |
| 72 |
gtid_binlog_pos 0-2-1,10-1-3,20-2-1 |
| 73 |
SHOW VARIABLES LIKE 'gtid_slave_pos'; |
| 74 |
Variable_name Value |
| 75 |
gtid_slave_pos 0-2-1,10-1-3,20-2-1 |
| 76 |
SELECT * from t1; |
| 77 |
a b |
| 78 |
1 0 |
| 79 |
2 1 |
| 80 |
## B. out-of-order gtid error for a "foreign" server-id transaction |
| 81 |
connection server_1; |
| 82 |
set statement sql_log_bin=0 for call mtr.add_suppression("Slave: An attempt was made to binlog GTID 10-2-4"); |
| 83 |
set @@session.server_id=2; |
| 84 |
INSERT INTO t1(a) VALUES (3); |
| 85 |
set @@session.server_id=default; |
| 86 |
include/save_master_gtid.inc |
| 87 |
connection server_2; |
| 88 |
include/sync_with_master_gtid.inc |
| 89 |
INSERT INTO t1(a) VALUES (4); |
| 90 |
include/save_master_gtid.inc |
| 91 |
connection server_1; |
| 92 |
include/wait_for_slave_sql_error.inc [errno=1950] |
| 93 |
set sql_slave_skip_counter=1; |
| 94 |
include/start_slave.inc |
| 95 |
include/sync_with_master_gtid.inc |
| 96 |
connection server_2; |
| 97 |
set statement sql_log_bin=0 for call mtr.add_suppression("Slave: An attempt was made to binlog GTID 20-1-3"); |
| 98 |
set @@session.server_id=1; |
| 99 |
INSERT INTO t1(a) VALUES (5); |
| 100 |
set @@session.server_id=default; |
| 101 |
include/save_master_gtid.inc |
| 102 |
connection server_1; |
| 103 |
include/sync_with_master_gtid.inc |
| 104 |
INSERT INTO t1(a) VALUES (6); |
| 105 |
include/save_master_gtid.inc |
| 106 |
connection server_2; |
| 107 |
include/wait_for_slave_sql_error.inc [errno=1950] |
| 108 |
set sql_slave_skip_counter=1; |
| 109 |
include/start_slave.inc |
| 110 |
include/sync_with_master_gtid.inc |
| 111 |
# Post-execution state check on both servers synchronized with each other |
| 112 |
connection server_1; |
| 113 |
# ... the gtid states on server_1 |
| 114 |
SHOW VARIABLES LIKE 'gtid_slave_pos'; |
| 115 |
Variable_name Value |
| 116 |
gtid_slave_pos 0-2-1,10-1-5,20-1-3 |
| 117 |
SHOW VARIABLES LIKE 'gtid_binlog_pos'; |
| 118 |
Variable_name Value |
| 119 |
gtid_binlog_pos 0-2-1,10-1-5,20-1-3 |
| 120 |
SELECT * from t1; |
| 121 |
a b |
| 122 |
1 0 |
| 123 |
2 1 |
| 124 |
3 0 |
| 125 |
4 0 |
| 126 |
5 0 |
| 127 |
6 0 |
| 128 |
connection server_2; |
| 129 |
include/sync_with_master_gtid.inc |
| 130 |
# The gtid states on server_2 must be equal to ... |
| 131 |
SHOW VARIABLES LIKE 'gtid_binlog_pos'; |
| 132 |
Variable_name Value |
| 133 |
gtid_binlog_pos 0-2-1,10-1-5,20-1-3 |
| 134 |
SHOW VARIABLES LIKE 'gtid_slave_pos'; |
| 135 |
Variable_name Value |
| 136 |
gtid_slave_pos 0-2-1,10-1-5,20-1-3 |
| 137 |
SELECT * from t1; |
| 138 |
a b |
| 139 |
1 0 |
| 140 |
2 1 |
| 141 |
3 0 |
| 142 |
4 0 |
| 143 |
5 0 |
| 144 |
6 0 |
| 145 |
# |
| 146 |
# Cleanup |
| 147 |
# |
| 148 |
connection server_1; |
| 149 |
DROP TABLE t1; |
| 150 |
include/save_master_gtid.inc |
| 151 |
connection server_2; |
| 152 |
include/sync_with_master_gtid.inc |
| 153 |
connection server_1; |
| 154 |
include/stop_slave.inc |
| 155 |
set @@global.rpl_semi_sync_master_enabled = default; |
| 156 |
set @@global.rpl_semi_sync_slave_enabled = default; |
| 157 |
set @@global.rpl_semi_sync_master_wait_point=default; |
| 158 |
set @@global.gtid_ignore_duplicates = default; |
| 159 |
set @@global.gtid_strict_mode = default; |
| 160 |
connection server_2; |
| 161 |
include/stop_slave.inc |
| 162 |
set @@global.gtid_ignore_duplicates = default; |
| 163 |
set @@global.rpl_semi_sync_master_enabled = default; |
| 164 |
set @@global.rpl_semi_sync_slave_enabled = default; |
| 165 |
set @@global.gtid_strict_mode = default; |
| 166 |
include/start_slave.inc |
| 167 |
include/rpl_end.inc |