| 1 |
include/group_replication.inc [rpl_server_count=2] |
| 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 server1] |
| 6 |
|
| 7 |
# 1. Bootstrap group on server 1 and create table t1 |
| 8 |
include/start_and_bootstrap_group_replication.inc |
| 9 |
CREATE TABLE test.t1 (a INT PRIMARY KEY); |
| 10 |
|
| 11 |
# 2. Join server2 to group and lock tables t1 |
| 12 |
[connection server_2] |
| 13 |
include/start_group_replication.inc |
| 14 |
LOCK TABLES t1 READ; |
| 15 |
|
| 16 |
# 3. Execute transaction on primary server |
| 17 |
[connection server1] |
| 18 |
INSERT INTO t1 VALUES (1); |
| 19 |
|
| 20 |
# 4. Server2 will certify transaction but won't apply due lock tables |
| 21 |
[connection server2] |
| 22 |
|
| 23 |
# 5. Start a transaction on secondary that will be elected as primary |
| 24 |
SET @@SESSION.group_replication_consistency= BEFORE_ON_PRIMARY_FAILOVER; |
| 25 |
BEGIN; |
| 26 |
|
| 27 |
# 6. Execute group_replication_set_as_primary to appoint server2 as |
| 28 |
# primary |
| 29 |
[connection server1] |
| 30 |
SELECT group_replication_set_as_primary("MEMBER2_UUID"); |
| 31 |
|
| 32 |
# 7. Validate that primary election is executing |
| 33 |
[connection server2] |
| 34 |
|
| 35 |
# 8. Transaction started previous to primary election, it will not block |
| 36 |
# due hook only run once by transaction. |
| 37 |
SELECT * FROM t1; |
| 38 |
a |
| 39 |
|
| 40 |
# 9. A write will fail due SUPER_READ_ONLY=1 until primary election |
| 41 |
# finishes |
| 42 |
INSERT INTO t1 VALUES (2); |
| 43 |
ERROR HY000: The MySQL server is running with the --super-read-only option so it cannot execute this statement |
| 44 |
COMMIT; |
| 45 |
|
| 46 |
# 10. A start of a transaction to a new primary will be put on hold |
| 47 |
# until all backlog's are applied |
| 48 |
SET @@SESSION.group_replication_consistency= BEFORE_ON_PRIMARY_FAILOVER; |
| 49 |
BEGIN;; |
| 50 |
|
| 51 |
# 11. Validate statement is on hold |
| 52 |
[connection server_2] |
| 53 |
|
| 54 |
# 12. UNLOCK tables to allow backlog to be applied |
| 55 |
UNLOCK TABLES; |
| 56 |
|
| 57 |
# 12. Reap with success execution of set as primary server2 |
| 58 |
[connection server1] |
| 59 |
group_replication_set_as_primary("MEMBER2_UUID") |
| 60 |
Primary server switched to: MEMBER2_UUID |
| 61 |
|
| 62 |
# 13. Reap with success start of transaction and execute some statements |
| 63 |
[connection server2] |
| 64 |
SELECT * FROM t1; |
| 65 |
a |
| 66 |
1 |
| 67 |
COMMIT; |
| 68 |
SET @@SESSION.group_replication_consistency= DEFAULT; |
| 69 |
|
| 70 |
# 14. Cleanup |
| 71 |
DROP TABLE t1; |
| 72 |
include/group_replication_end.inc |