| 1 |
include/group_replication.inc [rpl_server_count=3] |
| 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 |
# 0. Test starts in Single primary mode with server1 as the primary |
| 8 |
include/start_and_bootstrap_group_replication.inc |
| 9 |
include/gr_assert_primary_member.inc |
| 10 |
CREATE TABLE t1(a int primary key); |
| 11 |
[connection server2] |
| 12 |
include/start_group_replication.inc |
| 13 |
[connection server3] |
| 14 |
include/start_group_replication.inc |
| 15 |
|
| 16 |
# 1.1 Lock table on the new primary (server 2) and get a transaction stuck |
| 17 |
# Execute a primary change to server 2. |
| 18 |
# Check the new primary is in the applying buffered transactions stage |
| 19 |
# Others are in waiting on current primary transaction execution stage |
| 20 |
[connection server_2] |
| 21 |
SET @@GLOBAL.read_only= 0; |
| 22 |
LOCK TABLE t1 READ; |
| 23 |
[connection server1] |
| 24 |
INSERT INTO t1 VALUES (1); |
| 25 |
SELECT group_replication_set_as_primary("MEMBER2_UUID"); |
| 26 |
[connection server2] |
| 27 |
include/assert.inc [The stage should be "Primary Election: applying buffered transactions"] |
| 28 |
include/assert.inc [The estimated work is 1] |
| 29 |
include/assert.inc [The completed work is 0] |
| 30 |
[connection server_1] |
| 31 |
include/assert.inc [The stage should be "Primary Election: waiting on current primary transaction execution"] |
| 32 |
include/assert.inc [The estimated work is 1] |
| 33 |
include/assert.inc [The completed work is 0] |
| 34 |
|
| 35 |
# 1.2 Lock a table on the old primary (server1) and execute a transaction |
| 36 |
# This will block the read mode enabling query on the now secondary |
| 37 |
# Unblock the table on the new primary (server2) |
| 38 |
# Check they are on Waiting for members to enable super_read_only |
| 39 |
[connection server_1] |
| 40 |
LOCK TABLE t1 READ; |
| 41 |
[connection server_1_1] |
| 42 |
INSERT INTO t1 VALUES (2); |
| 43 |
[connection server_2] |
| 44 |
UNLOCK TABLES; |
| 45 |
include/assert.inc [The stage should be "Primary Election: waiting for members to enable super_read_only"] |
| 46 |
include/assert.inc [The estimated work is 3] |
| 47 |
include/assert.inc [The completed work is 2] |
| 48 |
[connection server3] |
| 49 |
include/assert.inc [The stage should be "Primary Election: waiting for members to enable super_read_only"] |
| 50 |
include/assert.inc [The estimated work is 3] |
| 51 |
include/assert.inc [The completed work is 2] |
| 52 |
|
| 53 |
# 1.3 Lock table on the new primary (server 2) |
| 54 |
# Unlock the table on the secondary (server1) that will block on server2 |
| 55 |
# Check election is on Stabilizing transactions from former primaries stage |
| 56 |
[connection server_2] |
| 57 |
LOCK TABLE t1 READ; |
| 58 |
[connection server_1] |
| 59 |
UNLOCK TABLES; |
| 60 |
[connection server_1_1] |
| 61 |
[connection server2] |
| 62 |
include/assert.inc [The stage should be "Primary Election: stabilizing transactions from former primaries"] |
| 63 |
include/assert.inc [The estimated work is 1] |
| 64 |
include/assert.inc [The completed work is 0] |
| 65 |
[connection server_1] |
| 66 |
include/assert.inc [The stage should be "Primary Election: stabilizing transactions from former primaries"] |
| 67 |
include/assert.inc [The estimated work is 1] |
| 68 |
include/assert.inc [The completed work is 0] |
| 69 |
|
| 70 |
# 1.4 Unblock to end the action. |
| 71 |
[connection server_2] |
| 72 |
UNLOCK TABLES; |
| 73 |
[connection server1] |
| 74 |
group_replication_set_as_primary("MEMBER2_UUID") |
| 75 |
Primary server switched to: MEMBER2_UUID |
| 76 |
|
| 77 |
# 2.0 Set the weights so server 1 is the new primary when server 2 leaves. |
| 78 |
# Lock a table on the new primary (server1) |
| 79 |
[connection server1] |
| 80 |
SET GLOBAL group_replication_member_weight= 100; |
| 81 |
SET @@GLOBAL.read_only= 0; |
| 82 |
LOCK TABLE t1 READ; |
| 83 |
[connection server3] |
| 84 |
SET GLOBAL group_replication_member_weight= 1; |
| 85 |
|
| 86 |
# 2.1 Execute a transaction that will be stuck on server1 |
| 87 |
# Stop server 2 so it leaves the group and a new election happens |
| 88 |
# Check the election stage on the new primary: applying buffered transactions |
| 89 |
# Check the election stage on secondary: waiting on current primary transaction execution |
| 90 |
[connection server2] |
| 91 |
INSERT INTO t1 VALUES (3); |
| 92 |
include/stop_group_replication.inc |
| 93 |
[connection server_1] |
| 94 |
include/assert.inc [The stage should be "Primary Election: applying buffered transactions"] |
| 95 |
include/assert.inc [The estimated work is 1] |
| 96 |
include/assert.inc [The completed work is 0] |
| 97 |
[connection server3] |
| 98 |
include/assert.inc [The stage should be "Primary Election: waiting on current primary transaction execution"] |
| 99 |
include/assert.inc [The estimated work is 1] |
| 100 |
include/assert.inc [The completed work is 0] |
| 101 |
|
| 102 |
# 2.2 Unblock the table |
| 103 |
# Check the election ends and there are no more stages. |
| 104 |
[connection server1] |
| 105 |
UNLOCK TABLES; |
| 106 |
include/gr_assert_primary_member.inc |
| 107 |
include/assert.inc [There is no stage present] |
| 108 |
[connection server3] |
| 109 |
include/assert.inc [There is no stage present] |
| 110 |
|
| 111 |
# 3. Clean up |
| 112 |
[connection server2] |
| 113 |
include/start_group_replication.inc |
| 114 |
[connection server1] |
| 115 |
SET @@GLOBAL.group_replication_member_weight= DEFAULT; |
| 116 |
DROP TABLE t1; |
| 117 |
[connection server3] |
| 118 |
SET @@GLOBAL.group_replication_member_weight= DEFAULT; |
| 119 |
include/group_replication_end.inc |