1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189
|
include/group_replication.inc
Warnings:
Note #### Sending passwords in plain text without SSL/TLS is extremely insecure.
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.
[connection server1]
############################################################
# 01. Create two tables on each server before start the group.
[connection server1]
SET SESSION sql_log_bin = 0;
CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY);
CREATE TABLE t2 (c1 INT NOT NULL PRIMARY KEY);
SET SESSION sql_log_bin = 1;
[connection server2]
SET SESSION sql_log_bin = 0;
CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY);
CREATE TABLE t2 (c1 INT NOT NULL PRIMARY KEY);
INSERT INTO t2 VALUES (1);
call mtr.add_suppression("Replica SQL for channel 'group_replication_applier': Could not execute Write_rows event on table");
call mtr.add_suppression("Replica SQL for channel 'group_replication_applier': Worker [0-9] failed executing transaction*");
call mtr.add_suppression("Replica SQL for channel 'group_replication_applier': ... The replica coordinator and worker threads are stopped,*");
call mtr.add_suppression("The applier thread execution was aborted. Unable to process more transactions, this member will now leave the group.");
call mtr.add_suppression("Fatal error during execution on the Applier process of Group Replication. The server will now leave the group.");
call mtr.add_suppression("The server was automatically set into read only mode after an error was detected.");
call mtr.add_suppression("Skipping leave operation: concurrent attempt to leave the group is on-going.");
SET SESSION sql_log_bin = 1;
############################################################
# 02. Lock table t1 on server2 to block a future update.
[connection server_2]
LOCK table t1 READ;
############################################################
# 03. Bootstrap group on server1.
[connection server1]
include/start_and_bootstrap_group_replication.inc
############################################################
# 04. Execute transactions T1 on server1.
# T1 will block server2 on RECOVERING state.
[connection server1]
INSERT INTO t1 VALUES (1);
############################################################
# 05. Start group on server2, it will be on RECOVERING state.
[connection server2]
include/start_group_replication.inc
SET @@SESSION.group_replication_consistency= 'BEFORE';
SELECT COUNT(*) AS count FROM t1;
ERROR HY000: The option group_replication_consistency cannot be used on the current member state.
BEGIN;
ERROR HY000: The option group_replication_consistency cannot be used on the current member state.
SELECT COUNT(*) AS count FROM t1;
ERROR HY000: The option group_replication_consistency cannot be used on the current member state.
COMMIT;
ERROR HY000: The option group_replication_consistency cannot be used on the current member state.
SET @@SESSION.group_replication_consistency= 'AFTER';
SELECT COUNT(*) AS count FROM t1;
ERROR HY000: The option group_replication_consistency cannot be used on the current member state.
BEGIN;
ERROR HY000: The option group_replication_consistency cannot be used on the current member state.
SELECT COUNT(*) AS count FROM t1;
ERROR HY000: The option group_replication_consistency cannot be used on the current member state.
COMMIT;
ERROR HY000: The option group_replication_consistency cannot be used on the current member state.
SET @@SESSION.group_replication_consistency= 'BEFORE_AND_AFTER';
SELECT COUNT(*) AS count FROM t1;
ERROR HY000: The option group_replication_consistency cannot be used on the current member state.
BEGIN;
ERROR HY000: The option group_replication_consistency cannot be used on the current member state.
SELECT COUNT(*) AS count FROM t1;
ERROR HY000: The option group_replication_consistency cannot be used on the current member state.
COMMIT;
ERROR HY000: The option group_replication_consistency cannot be used on the current member state.
############################################################
# 06. Unlock table t1 on server2.
# Member will move to ONLINE state.
[connection server_2]
UNLOCK TABLES;
[connection server2]
include/gr_wait_for_member_state.inc
SET @@SESSION.group_replication_consistency= 'BEFORE';
SELECT COUNT(*) AS count FROM t1;
count
1
BEGIN;
SELECT COUNT(*) AS count FROM t1;
count
1
COMMIT;
SET @@SESSION.group_replication_consistency= 'AFTER';
SELECT COUNT(*) AS count FROM t1;
count
1
BEGIN;
SELECT COUNT(*) AS count FROM t1;
count
1
COMMIT;
SET @@SESSION.group_replication_consistency= 'BEFORE_AND_AFTER';
SELECT COUNT(*) AS count FROM t1;
count
1
BEGIN;
SELECT COUNT(*) AS count FROM t1;
count
1
COMMIT;
############################################################
# 07. Execute transactions T2 on server1.
# T2 will make server2 move to ERROR state due to
# duplicate key.
[connection server1]
INSERT INTO t2 VALUES (1);
[connection server2]
include/gr_wait_for_member_state.inc
SET @@SESSION.group_replication_consistency= 'BEFORE';
SELECT COUNT(*) AS count FROM t1;
ERROR HY000: The option group_replication_consistency cannot be used on the current member state.
BEGIN;
ERROR HY000: The option group_replication_consistency cannot be used on the current member state.
SELECT COUNT(*) AS count FROM t1;
ERROR HY000: The option group_replication_consistency cannot be used on the current member state.
COMMIT;
ERROR HY000: The option group_replication_consistency cannot be used on the current member state.
SET @@SESSION.group_replication_consistency= 'AFTER';
SELECT COUNT(*) AS count FROM t1;
ERROR HY000: The option group_replication_consistency cannot be used on the current member state.
BEGIN;
ERROR HY000: The option group_replication_consistency cannot be used on the current member state.
SELECT COUNT(*) AS count FROM t1;
ERROR HY000: The option group_replication_consistency cannot be used on the current member state.
COMMIT;
ERROR HY000: The option group_replication_consistency cannot be used on the current member state.
SET @@SESSION.group_replication_consistency= 'BEFORE_AND_AFTER';
SELECT COUNT(*) AS count FROM t1;
ERROR HY000: The option group_replication_consistency cannot be used on the current member state.
BEGIN;
ERROR HY000: The option group_replication_consistency cannot be used on the current member state.
SELECT COUNT(*) AS count FROM t1;
ERROR HY000: The option group_replication_consistency cannot be used on the current member state.
COMMIT;
ERROR HY000: The option group_replication_consistency cannot be used on the current member state.
############################################################
# 08. Stop group on server2.
# Member will move to OFFLINE state.
include/stop_group_replication.inc
include/gr_wait_for_member_state.inc
SET @@SESSION.group_replication_consistency= 'BEFORE';
SELECT COUNT(*) AS count FROM t1;
count
1
BEGIN;
SELECT COUNT(*) AS count FROM t1;
count
1
COMMIT;
SET @@SESSION.group_replication_consistency= 'AFTER';
SELECT COUNT(*) AS count FROM t1;
count
1
BEGIN;
SELECT COUNT(*) AS count FROM t1;
count
1
COMMIT;
SET @@SESSION.group_replication_consistency= 'BEFORE_AND_AFTER';
SELECT COUNT(*) AS count FROM t1;
count
1
BEGIN;
SELECT COUNT(*) AS count FROM t1;
count
1
COMMIT;
SET @@SESSION.group_replication_consistency= DEFAULT;
############################################################
# 09. Clean up.
[connection server1]
DROP TABLE t1;
DROP TABLE t2;
[connection server2]
DROP TABLE t1;
DROP TABLE t2;
include/group_replication_end.inc
|