File: rpl_end.inc

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 (336 lines) | stat: -rw-r--r-- 9,273 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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
# ==== Purpose ====
#
# Shut down replication initialized by include/rpl_init.inc.
#
# This syncs all servers, executes STOP REPLICA on all servers, executes
# CHANGE REPLICATION SOURCE on all servers, and disconnects all connections
# configured by rpl_init.inc.
#
# It does not execute RESET MASTER or RESET REPLICA, because that would
# remove binlogs which are possibly useful debug information in case
# the test case later fails with a result mismatch.  If you need that,
# source include/rpl_reset.inc before you source this file.
#
#
# ==== Usage ====
#
# [--let $rpl_skip_sync = 1]
# [--let $rpl_skip_delete_channels = 1]
# [--let $rpl_skip_stop_slave = 1]
# [--let $rpl_only_running_threads = 1]
# [--let $rpl_debug = 1]
# [--let $rpl_group_replication = 1]
# [--let $rpl_gtid_utils = 1]
# [--let $rpl_assert_transaction_length = 1]
# --source include/rpl_end.inc
#
# Parameters:
#   $rpl_skip_sync
#     By default, all slaves are synced using rpl_sync.inc. Set this
#     option to 1 to disable this behavior (note that you must
#     manually sync all servers in this case). Normally you want to
#     sync, but you need to disable sync if you use multi-source.
#
#  $rpl_skip_delete_channels
#     In multi-source repliation, to restore the SHOW SLAVE STATUS state,
#     it is necessary to delete the channels that are created. By default,
#     channels are deleted in multi-source. set it to 1, if channel deletion
#     is not required.
#
#  $rpl_skip_stop_slave
#     If set to '1' the slaves are not stopped. Useful if the slaves are stopped
#     in the test case before sourcing this file.
#
#   $rpl_only_running_threads
#     If one or both of the IO and SQL threads is stopped, sync and
#     stop only the threads that are running.  See
#     include/rpl_sync.inc and include/stop_slave.inc for details.
#
#   $rpl_debug
#     See include/rpl_init.inc
#
#   $rpl_group_replication
#     This checks for whether we have Group Replication enabled or not. Based
#     on the check this parameter we execute CHANGE REPLICATION SOURCE or not in this
#     inc file.
#
#   $rpl_gtid_utils
#     Source include/gtid_utils_end.inc on every server.
#
#   $rpl_assert_transaction_length
#     Source include/assert_transaction_length_all_logs.inc on every server.
#
# Note:
#   This script will fail if Last_SQL_Error or Last_IO_Error is
#   nonempty.  If you expect an error in the SQL thread, you should
#   normally call this script as follows:
#
#     --source include/wait_for_slave_sql_error.inc
#     --source include/stop_slave_io.inc
#     RESET REPLICA;
#     --let $rpl_only_running_threads= 1
#     --source include/rpl_end.inc
#
#
# ==== Side effects ====
#
# Changes the current connection to 'default'.


--let $include_filename= rpl_end.inc
--source include/begin_include_file.inc


if (!$rpl_inited)
{
  --die ERROR IN TEST: rpl_end.inc was sourced when replication was not configured. Most likely, rpl_end.inc was sourced twice or rpl_init.inc has not been sourced.
}

# By default one shall delete channels to restore the state
if ($rpl_skip_delete_channels == '')
{
  --let $rpl_skip_delete_channels = 0
}

if ($rpl_debug)
{
  --echo ---- Check that no slave thread has an error ----
}

--let $_rpl_server= $rpl_server_count
while ($_rpl_server)
{
  --let $rpl_connection_name= server_$_rpl_server
  --source include/rpl_connection.inc

  # Only check slave threads for error on hosts that were at some
  # point configured as slave.
  --let $_tmp= query_get_value(SHOW SLAVE STATUS, Master_Host, 1)
  if ($_tmp != 'No such row')
  {
    --source include/check_slave_no_error.inc
  }

  --dec $_rpl_server
}

if (!$rpl_skip_sync)
{
  --source include/rpl_sync.inc
}

if ($rpl_assert_transaction_length)
{
  --let $skip_output= 1
  --let $_rpl_server= $rpl_server_count
  while ($_rpl_server)
  {
    --let $rpl_connection_name= server_$_rpl_server
    --source include/rpl_connection.inc
    --source include/assert_transaction_length_all_logs.inc
    --dec $_rpl_server
  }
}

if ($rpl_group_replication)
{
  --let $_rpl_server= $rpl_server_count
  while ($_rpl_server)
  {
    --let $rpl_connection_name= server_$_rpl_server
    --source include/rpl_connection.inc

    --let $_group_replication_member_state= `SELECT SERVICE_STATE FROM performance_schema.replication_connection_status connection_status WHERE connection_status.group_name="$group_replication_group_name"`
    if ($_group_replication_member_state == 'ON')
    {
      --source include/stop_group_replication.inc
    }
    --source include/stop_dump_threads.inc
    --dec $_rpl_server
  }
}

if (!$rpl_group_replication)
{
  if (!$rpl_skip_stop_slave)
  {
    --source include/rpl_stop_slaves.inc
  }
}

# Clear the configuration of privilege_checks_user account
if (!$rpl_group_replication)
{
  --let $_rpl_server= $rpl_server_count
  while ($_rpl_server)
  {
    if ($rpl_privilege_checks_user != '')
    {
      --let $rpl_server_number= $_rpl_server
      --source include/rpl_get_instance_priv_checks_user.inc
      if ($rpl_instance_privilege_checks_user != NULL)
      {
        --disable_query_log
        --let $rpl_connection_name= server_$_rpl_server
        --source include/rpl_connection.inc

        if (!$rpl_multi_source)
        {
          CHANGE REPLICATION SOURCE TO PRIVILEGE_CHECKS_USER=NULL;
        }
        if ($rpl_multi_source)
        {
          if($rpl_channel_name)
          {
            eval CHANGE REPLICATION SOURCE TO PRIVILEGE_CHECKS_USER=NULL FOR CHANNEL $rpl_channel_name;
          }
          if(!$rpl_channel_name)
          {
            CHANGE REPLICATION SOURCE TO PRIVILEGE_CHECKS_USER=NULL FOR CHANNEL '';
          }
        }
        --enable_query_log
        --source include/rpl_clear_priv_checks_user_configuration.inc
      }
    }
    --dec $_rpl_server
  }
  --let $rpl_privilege_checks_user=
  --let $rpl_change_topology_user_created=
}

# Clear replication asynchronous failover configuration tables
if (!$rpl_group_replication)
{
  --let $_rpl_server= $rpl_server_count
  while ($_rpl_server)
  {
    --let $rpl_connection_name= server_$_rpl_server
    --source include/rpl_connection.inc

    --source include/rpl_clear_asynchronous_failover_configuration.inc

    --dec $_rpl_server
  }
}

# Restore the server state by deleting all channels
if ($rpl_multi_source)
{
  if (!$rpl_skip_delete_channels)
  {
    --let $rpl_reset_slave_all= 1
    --let $rpl_source_file= include/rpl_reset_slave_helper.inc
    --source include/rpl_for_each_connection.inc
    --let $rpl_reset_slave_all= 0
  }
}

# mtr configures server 2 to be a slave before it runs the test. We
# have to restore that state now, so we change topology to 1->2.

# rpl_change_topology executes CHANGE REPLICATION SOURCE for each connection.
# we restore the gtid state by sourcing rpl_change_topology below

# Restore state for GTID_ONLY

if ($rpl_gtid_only)
{
  --let $_rpl_server= $rpl_server_count
  while ($_rpl_server)
  {
    --let $rpl_connection_name= server_$_rpl_server
    --source include/rpl_connection.inc

    --disable_query_log
    if (!$rpl_multi_source)
    {
      CHANGE REPLICATION SOURCE TO GTID_ONLY = 0;
    }
    if ($rpl_multi_source)
    {
      if($rpl_channel_name)
      {
        eval CHANGE REPLICATION SOURCE TO GTID_ONLY = 0 FOR CHANNEL $rpl_channel_name;
      }
      if(!$rpl_channel_name)
      {
        CHANGE REPLICATION SOURCE TO GTID_ONLY = 0 FOR CHANNEL '';
      }
    }
    --enable_query_log
    --dec $_rpl_server
  }
}

--let $use_gtids= 0
--let $rpl_group_replication= 0

--source include/rpl_change_topology.inc

--let $rpl_topology=none
--source include/rpl_change_topology.inc


--connection default
--let $_rpl_server= $rpl_server_count
--let $_rpl_one= _1
while ($_rpl_server)
{
  if ($rpl_gtid_utils)
  {
    # Drop gtid_utils
    --let $rpl_connection_name= server_$_rpl_server
    --source include/rpl_connection.inc
    --source include/gtid_utils_end.inc
    --connection default
  }
  # Stop the Binlog Dump thread
  --let $rpl_connection_name= server_$_rpl_server
  --source include/rpl_connection.inc
  --source include/stop_dump_threads.inc

  # Restore state for REQUIRE_ROW_FORMAT
  if ($rpl_require_row_format)
  {
    --disable_query_log
    if (!$rpl_multi_source)
    {
      CHANGE REPLICATION SOURCE TO REQUIRE_ROW_FORMAT=0;
    }
    if ($rpl_multi_source)
    {
      if($rpl_channel_name)
      {
        eval CHANGE REPLICATION SOURCE TO REQUIRE_ROW_FORMAT = 0 FOR CHANNEL $rpl_channel_name;
      }
      if(!$rpl_channel_name)
      {
        CHANGE REPLICATION SOURCE TO REQUIRE_ROW_FORMAT = 0 FOR CHANNEL '';
      }
    }
    --enable_query_log
  }

  --connection default

  # Unconfigure connections
  --disconnect server_$_rpl_server
  --disconnect server_$_rpl_server$_rpl_one
  --dec $_rpl_server
}

# reset as next test can be any of rpl or group_replication
--let $using_rpl_group_replication_default_connections= 0

--let $rpl_inited= 0
--let $_rpl_server_count=
--let $rpl_multi_source= 0

# cleanup any files created by JSON iterators
--source include/destroy_json_functions.inc

# Do not restore connection, because we have disconnected it.
--let $skip_restore_connection= 1
--let $include_filename= rpl_end.inc
--source include/end_include_file.inc