File: rpl_semi_sync_add_remove_slaves.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 (191 lines) | stat: -rw-r--r-- 5,725 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
182
183
184
185
186
187
188
189
190
191
#==== Purpose ====
#
# This test script purpose is to check semisync replication
# behaviour when there are semisync slaves getting added and
# removed while dml changes are happening.
#
#==== Implementation ====
#
# 1) Install semisync on one Master and 8 Slaves.
# 2) Using mysqlslap, keep inserting data in background on Master.
# 3) While the DMLs are going on, keep adding/removing semisync slaves.
# 4) At the end of the step-3, check that the data is synced without any
#    issues.
# 5) Check semisync is still enabled on Master and all slaves.
#
#==== References ====
#
# Bug#27610678 SEMI-SYNC REPLICATION DOESN'T WORK FOR MINUTES AFTER RESTART
#              REPLICATION
#
#========
#
# 9 servers + 1000 inserts involved in test. Hence marking it as big-test.
#
--source include/big_test.inc
--source include/not_group_replication_plugin.inc
--source include/have_binlog_format_statement.inc
--source include/have_debug.inc

#
# One Master and 8 Slaves in the semi sync topology.
#
--let rpl_topology=1->2, 1->3, 1->4, 1->5, 1->6, 1->7, 1->8, 1->9
--source include/rpl_init.inc

--echo #
--echo # 1. Initial data.
--echo #
call mtr.add_suppression("Timeout waiting for reply of binlog");
CREATE TABLE t1(c1 INT);
--source include/rpl_sync.inc

--echo #
--echo # 2. Install semisync on all the 9 servers.
--echo #
--let $i= 1
while ($i < 10)
{
  --let $rpl_connection_name= server_$i
  --source include/rpl_connection.inc
  if ( $i == 1)
  {
    --connect(server1_1, localhost,root,,,$MASTER_MYPORT)
    CALL mtr.add_suppression("Semi-sync source failed on net_flush.*");
    --source include/install_semisync_source.inc
  }
  if ( $i != 1 )
  {
    CALL mtr.add_suppression("Semi-sync replica net_flush.*");
    --source include/install_semisync_replica.inc
  }
  --inc $i
}

--echo #
--echo # 3. Make Master aware of 8 semisync slaves.
--echo #
--let $rpl_connection_name= server1_1
--source include/rpl_connection.inc
--let $slaves = 8
--eval SET GLOBAL rpl_semi_sync_source_wait_for_replica_count = $slaves

--echo #
--echo # 4. Insert 1000 tuples in background using 10 parallel connections.
--echo #
--exec_in_background $MYSQL_SLAP --create-schema=test --delimiter=";" --iterations=100 --query="INSERT INTO t1 values (1)" --concurrency=10 --silent 2>&1

--echo #
--echo # 5. While the insert operations are going in the background, keep
--echo #    adding/removing semisync slaves randomly.
--echo #
--let $rpl_connection_silent = 1
--let $include_silent= 1
--disable_result_log
--disable_query_log
--let $rpl_debug= 0
--let $iter= 1
while ( $iter < 50 )
{
  # Random server_id generator ( server_id will between [2-9]
  --let $server_id=`SELECT FLOOR(2 + ((RAND() * 100) % 8))`
  --let $rpl_connection_name= server_$server_id
  --source include/rpl_connection.inc
  --let $service_state= `SELECT service_state FROM performance_schema.replication_connection_status`
  if ($service_state == 'ON')
  {
    # If the replication state is ON, bring it down.
    --source include/stop_slave.inc
    --let $rpl_connection_name= server1_1
    --source include/rpl_connection.inc
    # Adjust rpl_semi_sync_source_wait_for_replica_count variable.
    --dec $slaves
    --eval SET GLOBAL rpl_semi_sync_source_wait_for_replica_count = $slaves
  }
  if ($service_state == 'OFF')
  {
    # If the replication state is OFF, bring it up.
    --source include/start_slave.inc
    --let $rpl_connection_name= server1_1
    --source include/rpl_connection.inc
    # Adjust rpl_semi_sync_source_wait_for_replica_count variable.
    --inc $slaves
    --eval SET GLOBAL rpl_semi_sync_source_wait_for_replica_count = $slaves
  }
  --inc $iter
  # Do it slowly while insertions on the master are happening in the background.
  sleep 1;
}

--echo #
--echo # 6. Add all 8 semisync slaves back to Master
--echo #     (if they were disconnected, in above step).
--echo #
--let $iter = 2
while ($iter <= 9)
{
  --let $rpl_connection_name= server_$iter
  --source include/rpl_connection.inc
  --let $service_state= `SELECT service_state FROM performance_schema.replication_connection_status`
  if ($service_state == 'OFF')
  {
    --source include/start_slave.inc
    --let $rpl_connection_name= server1_1
    --source include/rpl_connection.inc
    # Adjust rpl_semi_sync_source_wait_for_replica_count variable.
    --inc $slaves
    --eval SET GLOBAL rpl_semi_sync_source_wait_for_replica_count = $slaves
  }
  --inc $iter
}
--enable_result_log
--enable_query_log
--let $rpl_connection_silent = 0
--let $include_silent= 0


--echo #
--echo # 7. Make sure the data is synced on Master without any issues.
--echo #
--let $rpl_connection_name= server_1
--source include/rpl_connection.inc
--let $wait_timeout= 60
--let $wait_condition= SELECT count(*) = 1000 FROM t1
--source include/wait_condition.inc
--let $slave_timeout=600
--source include/rpl_sync.inc

--echo #
--echo # 8. Check on all servers semisync is enabled after the
--echo #    the experiment and then uninstall semisync pluging
--echo #    from it.
--echo #
--let $i= 9
while ($i >= 1)
{
  --let $rpl_connection_name= server_$i
  --source include/rpl_connection.inc
  if ( $i == 1)
  {
    --let $assert_variable_name= rpl_semi_sync_source_enabled
    --let $assert_variable_value= 1
    --source include/assert_variable.inc
    --source include/uninstall_semisync_source.inc
  }
  if ( $i != 1 )
  {
    --let $assert_variable_name= rpl_semi_sync_replica_enabled
    --let $assert_variable_value= 1
    --source include/assert_variable.inc
    --source include/uninstall_semisync_replica.inc
  }
  --dec $i
}

--echo #
--echo # 9. Cleanup time.
--echo #
--let $rpl_connection_name= server_1
--source include/rpl_connection.inc
DROP TABLE t1;
--source include/rpl_end.inc