File: gr_single_primary_double_change.test

package info (click to toggle)
mysql-8.0 8.0.43-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,273,924 kB
  • sloc: cpp: 4,684,605; ansic: 412,450; pascal: 108,398; java: 83,641; perl: 30,221; cs: 27,067; sql: 26,594; sh: 24,181; python: 21,816; yacc: 17,169; php: 11,522; xml: 7,388; javascript: 7,076; makefile: 2,194; lex: 1,075; awk: 670; asm: 520; objc: 183; ruby: 97; lisp: 86
file content (181 lines) | stat: -rw-r--r-- 6,262 bytes parent folder | download
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
###############################################################################
# This test validates that when the primary has some load from the old primary
# to apply, it wont unset the read mode.
#
# Test:
# 0. Test requires 3 servers.
# 1. Configure server 3 recovery user, so it is the only viable donor for
#    server1 on step #4
# 2. Lock the table on server 2 and insert data server 1. This will prevent
#    server2 from applying the old data when it is elected as primary.
# 3. Stop server 1 (primary) and validate thar server 2 is the new primary.
# 4. Configure server 1 with recovery credentials from server 3 and start group
#    replication.
# 5. Try to do a transaction on server 2. Since the server is still in read mode,
#    the insert will fail.
# 6. Clean up.
#
###############################################################################

--source include/have_group_replication_xcom_communication_stack.inc
--source include/have_group_replication_plugin.inc
--let $rpl_server_count= 3
--let $rpl_skip_group_replication_start= 1
--let $rpl_group_replication_single_primary_mode=1
--source include/group_replication.inc

--let $recovery_user= recovery_user
--let $recovery_password= recovery_password

--let $rpl_connection_name= server1
--source include/rpl_connection.inc

set session sql_log_bin=0;
call mtr.add_suppression("There was an error when connecting to the donor*");
call mtr.add_suppression("For details please check performance_schema.replication_connection_status table and error log messages of Replica I/O for channel group_replication_recovery.");
set session sql_log_bin=1;

--let $member1_uuid= query_get_value(SELECT @@SERVER_UUID, @@SERVER_UUID, 1)

--source include/start_and_bootstrap_group_replication.inc

--let $rpl_connection_name= server2
--source include/rpl_connection.inc

# next primary should be server2 in step3, so setting member weight as 70
# higher then default member_weight value of 50.
--eval SET GLOBAL group_replication_member_weight= 70
--let $member2_uuid= query_get_value(SELECT @@SERVER_UUID, @@SERVER_UUID, 1)

--source include/start_group_replication.inc

--echo
--echo ############################################################
--echo # 1. Configure server 3 recovery user, so it is the only
--echo # viable donor for server1 on step #4

--let $rpl_connection_name= server3
--source include/rpl_connection.inc

SET SESSION sql_log_bin= 0;
--eval CREATE USER "$recovery_user" IDENTIFIED BY "$recovery_password"
--eval GRANT REPLICATION SLAVE ON *.* TO "$recovery_user"
SET SESSION sql_log_bin= 1;

--let $member3_uuid= query_get_value(SELECT @@SERVER_UUID, @@SERVER_UUID, 1)

--source include/start_group_replication.inc

--let $rpl_connection_name= server1
--source include/rpl_connection.inc

# Making sure this is the primary server
--let $group_replication_expected_uuid= $member1_uuid
--source include/gr_wait_primary_member_uuid.inc

CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY, c2 INT) ENGINE=InnoDB;

--source include/rpl_sync.inc

--echo
--echo ###########################################################
--echo # 2. Lock the table on server 2 and insert data server 1.
--echo # This will prevent server2 from  from applying the old data
--echo # once it is elected as primary.

--let $rpl_connection_name= server_2
--source include/rpl_connection.inc

LOCK TABLE t1 READ;

--let $rpl_connection_name= server1
--source include/rpl_connection.inc

INSERT INTO t1 VALUES(1,1);

--echo
--echo ###########################################################
--echo # 3. Stop server 1 (primary) and validate thar server 2 is
--echo # the new primary.

--source include/stop_group_replication.inc

--let $rpl_connection_name= server2
--source include/rpl_connection.inc

# server1 is stopped, so only server2 and 3 should be in the group
--let $group_replication_number_of_members= 2
--source include/gr_wait_for_number_of_members.inc

# Make sure server2 is the primary now
--let $assert_text= Verify group_replication_primary_member is SERVER_UUID
--let $assert_cond= "[SELECT VARIABLE_VALUE FROM performance_schema.global_status WHERE VARIABLE_NAME= \'group_replication_primary_member\', VARIABLE_VALUE, 1]" = "$member2_uuid"
--source include/assert.inc


--echo
--echo ###########################################################
--echo # 4. Configure server 1 with recovery credentials from server
--echo # 3 and start group replication.


--let $rpl_connection_name= server1
--source include/rpl_connection.inc

--disable_warnings
--eval CHANGE REPLICATION SOURCE TO SOURCE_USER='$recovery_user', SOURCE_PASSWORD='$recovery_password' FOR CHANNEL 'group_replication_recovery'
--enable_warnings

--source include/start_group_replication.inc

--echo
--echo ###########################################################
--echo # 5. Insert a transaction on server 2. Since the server is
--echo #  still in read mode, it shall fail.

--let $rpl_connection_name= server2
--source include/rpl_connection.inc

--error 1290
INSERT INTO t1 VALUES(1,2);

--let $rpl_connection_name= server_2
--source include/rpl_connection.inc

UNLOCK TABLES;

#Waiting for the data to be applied
--let $wait_condition= SELECT COUNT(*)=1 FROM t1
--source include/wait_condition.inc

--let $negatively_certified= query_get_value(SELECT Count_conflicts_detected FROM performance_schema.replication_group_member_stats where member_id in (SELECT @@server_uuid), Count_conflicts_detected, 1)
--let $assert_text= 'The value of Count_conflicts_detected should be 0 on server 2'
--let $assert_cond= $negatively_certified = 0
--source include/assert.inc

#Now table is unlocked, wait for member to reset read_only
--let $wait_condition= SELECT @@GLOBAL.read_only = '0'
--source include/wait_condition_or_abort.inc

--echo
--echo ###########################################################
--echo # 6. Clean up.

--let $rpl_connection_name= server3
--source include/rpl_connection.inc

SET SESSION sql_log_bin= 0;
SET GLOBAL read_only= 0;
--eval DROP USER $recovery_user
SET GLOBAL super_read_only= 1;
SET SESSION sql_log_bin= 1;

--let $rpl_connection_name= server2
--source include/rpl_connection.inc

DROP TABLE t1;

SET GLOBAL group_replication_member_weight= DEFAULT;

--source include/group_replication_end.inc