| 1 |
include/group_replication.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 server1] |
| 6 |
|
| 7 |
# 1. Start group in single primary mode. |
| 8 |
# Server1 will be primary and server2 secondary. |
| 9 |
[connection server1] |
| 10 |
CREATE TABLE test.t1(c1 int primary key); |
| 11 |
include/start_and_bootstrap_group_replication.inc |
| 12 |
[connection server2] |
| 13 |
include/start_group_replication.inc |
| 14 |
|
| 15 |
# 2. Start a read-only transaction on server1. |
| 16 |
# It should succeed with primary change initiated from server2(secondary). |
| 17 |
[connection server2] |
| 18 |
|
| 19 |
# Start a transaction on server1 and block it. |
| 20 |
[connection server1] |
| 21 |
SET DEBUG_SYNC="before_reset_query_plan SIGNAL before_reset_query_ongoing WAIT_FOR after_reset_query_finished"; |
| 22 |
SELECT * FROM test.t1;;; |
| 23 |
[connection server_1] |
| 24 |
SET DEBUG_SYNC="now WAIT_FOR before_reset_query_ongoing"; |
| 25 |
|
| 26 |
# Begin change of primary on server2. |
| 27 |
[connection server2] |
| 28 |
SELECT group_replication_set_as_primary("MEMBER_UUID", 1); |
| 29 |
group_replication_set_as_primary("MEMBER_UUID", 1) |
| 30 |
Primary server switched to: MEMBER_UUID |
| 31 |
|
| 32 |
# Assert primary changed. |
| 33 |
[connection server2] |
| 34 |
include/gr_assert_primary_member.inc |
| 35 |
|
| 36 |
# Reap the transaction. |
| 37 |
[connection server_1] |
| 38 |
SET DEBUG_SYNC="now SIGNAL after_reset_query_finished"; |
| 39 |
SET DEBUG_SYNC="now SIGNAL after_reset_query_finished"; |
| 40 |
[connection server1] |
| 41 |
c1 |
| 42 |
SET DEBUG_SYNC="RESET"; |
| 43 |
|
| 44 |
# 3. Assert primary changed. |
| 45 |
[connection server2] |
| 46 |
include/gr_assert_primary_member.inc |
| 47 |
[connection server1] |
| 48 |
include/gr_assert_secondary_member.inc |
| 49 |
|
| 50 |
# 4. Start a read-only transaction on server2. |
| 51 |
# It should succeed with primary change initiated from server2(primary). |
| 52 |
[connection server1] |
| 53 |
|
| 54 |
# Start a transaction on server2 and block it. |
| 55 |
[connection server2] |
| 56 |
SET DEBUG_SYNC="before_reset_query_plan SIGNAL before_reset_query_ongoing WAIT_FOR after_reset_query_finished"; |
| 57 |
SELECT * FROM test.t1;;; |
| 58 |
[connection server_2] |
| 59 |
SET DEBUG_SYNC="now WAIT_FOR before_reset_query_ongoing"; |
| 60 |
|
| 61 |
# Begin change of primary on server_2_1. |
| 62 |
[connection server_2_1] |
| 63 |
SELECT group_replication_set_as_primary("MEMBER_UUID", 1); |
| 64 |
group_replication_set_as_primary("MEMBER_UUID", 1) |
| 65 |
Primary server switched to: MEMBER_UUID |
| 66 |
|
| 67 |
# Assert primary changed. |
| 68 |
[connection server1] |
| 69 |
include/gr_assert_primary_member.inc |
| 70 |
|
| 71 |
# Reap the transaction. |
| 72 |
[connection server_2] |
| 73 |
SET DEBUG_SYNC="now SIGNAL after_reset_query_finished"; |
| 74 |
SET DEBUG_SYNC="now SIGNAL after_reset_query_finished"; |
| 75 |
[connection server2] |
| 76 |
c1 |
| 77 |
SET DEBUG_SYNC="RESET"; |
| 78 |
|
| 79 |
# 5. Assert primary changed. |
| 80 |
[connection server1] |
| 81 |
include/gr_assert_primary_member.inc |
| 82 |
[connection server2] |
| 83 |
include/gr_assert_secondary_member.inc |
| 84 |
|
| 85 |
# 6. Start a write transaction on server1. |
| 86 |
# Client connection will be dropped. |
| 87 |
# Primary change initiated from server2(secondary). |
| 88 |
[connection server2] |
| 89 |
|
| 90 |
# Start a transaction on server1 and block it. |
| 91 |
[connection server1] |
| 92 |
SET DEBUG_SYNC="before_reset_query_plan SIGNAL before_reset_query_ongoing WAIT_FOR after_reset_query_finished"; |
| 93 |
INSERT INTO test.t1 values (1);;; |
| 94 |
[connection server_1] |
| 95 |
SET DEBUG_SYNC="now WAIT_FOR before_reset_query_ongoing"; |
| 96 |
|
| 97 |
# Begin change of primary on server2. |
| 98 |
[connection server2] |
| 99 |
SELECT group_replication_set_as_primary("MEMBER_UUID", 1); |
| 100 |
group_replication_set_as_primary("MEMBER_UUID", 1) |
| 101 |
Primary server switched to: MEMBER_UUID |
| 102 |
|
| 103 |
# Assert primary changed. |
| 104 |
[connection server2] |
| 105 |
include/gr_assert_primary_member.inc |
| 106 |
|
| 107 |
# Reap the transaction. |
| 108 |
[connection server_1] |
| 109 |
SET DEBUG_SYNC="now SIGNAL after_reset_query_finished"; |
| 110 |
SET DEBUG_SYNC="now SIGNAL after_reset_query_finished"; |
| 111 |
[connection server1] |
| 112 |
ERROR HY000: Lost connection to MySQL server during query |
| 113 |
SET DEBUG_SYNC="RESET"; |
| 114 |
|
| 115 |
# 7. Assert primary changed. |
| 116 |
[connection server2] |
| 117 |
include/gr_assert_primary_member.inc |
| 118 |
[connection server1] |
| 119 |
include/gr_assert_secondary_member.inc |
| 120 |
include/assert.inc ['There is no value 1 in table t1'] |
| 121 |
include/diff_tables.inc [server1:test.t1, server2:test.t1] |
| 122 |
|
| 123 |
# 8. Start a write transaction on server2. |
| 124 |
# Client connection will be dropped. |
| 125 |
# Primary change initiated from server2(primary). |
| 126 |
[connection server1] |
| 127 |
|
| 128 |
# Start a transaction on server2 and block it. |
| 129 |
[connection server2] |
| 130 |
SET DEBUG_SYNC="before_reset_query_plan SIGNAL before_reset_query_ongoing WAIT_FOR after_reset_query_finished"; |
| 131 |
INSERT INTO test.t1 values (2);;; |
| 132 |
[connection server_2] |
| 133 |
SET DEBUG_SYNC="now WAIT_FOR before_reset_query_ongoing"; |
| 134 |
|
| 135 |
# Begin change of primary on server_2_1. |
| 136 |
[connection server_2_1] |
| 137 |
SELECT group_replication_set_as_primary("MEMBER_UUID", 1); |
| 138 |
group_replication_set_as_primary("MEMBER_UUID", 1) |
| 139 |
Primary server switched to: MEMBER_UUID |
| 140 |
|
| 141 |
# Assert primary changed. |
| 142 |
[connection server1] |
| 143 |
include/gr_assert_primary_member.inc |
| 144 |
|
| 145 |
# Reap the transaction. |
| 146 |
[connection server_2] |
| 147 |
SET DEBUG_SYNC="now SIGNAL after_reset_query_finished"; |
| 148 |
SET DEBUG_SYNC="now SIGNAL after_reset_query_finished"; |
| 149 |
[connection server2] |
| 150 |
ERROR HY000: Lost connection to MySQL server during query |
| 151 |
SET DEBUG_SYNC="RESET"; |
| 152 |
|
| 153 |
# 9. Assert primary changed. |
| 154 |
[connection server1] |
| 155 |
include/gr_assert_primary_member.inc |
| 156 |
[connection server2] |
| 157 |
include/gr_assert_secondary_member.inc |
| 158 |
include/assert.inc ['There is no value 2 in table t1'] |
| 159 |
include/diff_tables.inc [server1:test.t1, server2:test.t1] |
| 160 |
|
| 161 |
# 10. Cleanup. |
| 162 |
[connection server1] |
| 163 |
DROP TABLE test.t1; |
| 164 |
include/group_replication_end.inc |