File: gr_wait_for_member_state.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 (76 lines) | stat: -rw-r--r-- 2,505 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
# ==== Purpose ====
#
# Wait for this server to reach a given state on the given group
#
#
# ==== Usage ====
#
# --let $group_replication_group_name= UUID
# --let $group_replication_member_state= STATE
# [--let $group_replication_member_id= UUID]
# [--let $wait_timeout= NUMBER]
# [--let $rpl_debug= 1]
# --source include/gr_wait_for_member_state.inc
#
# Parameters:
#   $group_replication_group_name
#     Group name
#
#   $group_replication_member_state
#     The state that the member should have
#
#   $group_replication_member_id
#     The member uuid that should have the given state
#     When not present, the test is done based on the current server uuid
#
#   $wait_timeout
#     See include/wait_condition.inc
#
#   $rpl_debug
#     See include/rpl_init.inc

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

if ($group_replication_group_name == '')
{
  --die ERROR IN TEST: the "group_replication_group_name" variable must be set
}

if ($group_replication_member_state == '')
{
  --die ERROR IN TEST: the "group_replication_member_state" variable must be set
}

if (!$rpl_debug)
{
  --disable_query_log
}

--let $_member_id= query_get_value(SELECT @@SERVER_UUID, @@SERVER_UUID, 1)
if ($group_replication_member_id != "")
{
  --let $_member_id= $group_replication_member_id
}

let $wait_condition= SELECT COUNT(*)=1 FROM performance_schema.replication_group_members
  WHERE member_id="$_member_id" AND
  member_state="$group_replication_member_state";
--source include/wait_condition_or_abort.inc

# Due to notify first the change to state ONLINE and after disable super read only
# when the lowest version servers are online we have two cases that need to
# wait for super read only= 0:
#   - when we are starting the primary in the single primary mode
#   - when we are starting a server on multiple primary

--let $_group_member_lowest_version= `SELECT member_version FROM performance_schema.replication_group_members ORDER BY member_version ASC LIMIT 1`

if (`SELECT COUNT(*)=1 FROM performance_schema.replication_group_members group_members WHERE group_members.member_id= "$_member_id" AND group_members.member_state="ONLINE" AND group_members.member_role = "PRIMARY" AND group_members.member_version = "$_group_member_lowest_version"`)
{
     --let $wait_condition= SELECT @@GLOBAL.read_only = '0'
     --source include/wait_condition_or_abort.inc
}

--let $include_filename= gr_wait_for_member_state.inc
--source include/end_include_file.inc