forked from mysql/mysql-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrpl_check_gtid.inc
157 lines (151 loc) · 4.87 KB
/
rpl_check_gtid.inc
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
################################################################################
# This file aims to check if a log, either binary or relay log, has correctly
# stored the Previous_gtids_log_event and Gtid_log_event events.
#
# Options:
# (Type of the log: binlog or relaylog)
# --let $binlog= <type_log>
# (Check in the current log has <set_ini>-<set_end> in Previous GTIDs)
# $gtid_set_ini= <set_ini>
# $gtid_set_end= <set_end>
# (Check in the current log has GTIDs from <gtid_ini> to <gtid_end>)
# $gtid_ini= <gtid_ini>
# $gtid_end= <gtid_end>
# (Enable or disable debug)
# --let $debug= <enabled>
#
# Usage:
# --let $binlog= <type_log>
# --let $gtid_set_ini= <set_ini>
# --let $gtid_set_end= <set_end>
# --let $gtid_ini= <gtid_ini>
# --let $gtid_end= <gtid_end>
# --source extra/rpl_tests/rpl_check_gtid.inc
#
# Example (Checking both Previous GTIDs and current Gtids in the master's
# current binary log):
# --connection master
# --let $binlog= binlog
# --let $gtid_set_ini= <set_ini>
# --let $gtid_set_end= <set_end>
# --let $gtid_ini= <gtid_ini>
# --let $gtid_end= <gtid_end>
# --source extra/rpl_tests/rpl_check_gtid.inc
#
# Example (Checking Previous GTIDs in the slave's current binary log):
# --connection slave
# --let $binlog= binlog
# --let $gtid_set_ini= <set_ini>
# --let $gtid_set_end= <set_end>
# --let $gtid_ini=
# --let $gtid_end=
# --source extra/rpl_tests/rpl_check_gtid.inc
#
# Example (Checking GTIDs in the slave's current relay log):
# --connection slave
# --let $binlog= relaylog
# --let $gtid_set_ini=
# --let $gtid_set_end=
# --let $gtid_ini= <gtid_ini>
# --let $gtid_end= <gtid_end>
# --source extra/rpl_tests/rpl_check_gtid.inc
################################################################################
--echo extra/rpl_tests/rpl_check_gtid.inc
if (`SELECT "$binlog" = "binlog"`)
{
--let $command_set= SHOW MASTER STATUS
--let $command_set_info= File
--let $command_show= SHOW BINLOG EVENTS
}
if (`SELECT "$binlog" = "relaylog"`)
{
--let $command_set= SHOW SLAVE STATUS
--let $command_set_info= Relay_Log_File
--let $command_show= SHOW RELAYLOG EVENTS
}
if (`SELECT "$binlog" <> "" and "$gtid_set_end" <> "" and "$gtid_set_ini" <> ""`)
{
--let $server_log= query_get_value($command_set, $command_set_info, 1)
if (`SELECT "$debug" <> ""`)
{
--eval $command_show in "$server_log"
}
--let $type= query_get_value($command_show in "$server_log", Event_type, 2)
--let $info= query_get_value($command_show in "$server_log", Info, 2)
if ($type != Previous_gtids)
{
--source include/show_rpl_debug_info.inc
--echo $type $info --- Type should be Previous_gtids.
--echo log='$server_log'
--eval $command_show in "$server_log"
--die
}
if ($gtid_set_end == 0 && $gtid_set_ini == 0)
{
if (`SELECT "$info" <> ""`)
{
--source include/show_rpl_debug_info.inc
--echo $type $info -- Info should be empty.
--let $datadir= `select @@datadir`
--echo log='$server_log'
--exec $MYSQL_BINLOG $datadir/$server_log
--eval $command_show in "$server_log"
--die
}
}
if (`SELECT $gtid_set_end <> 0 and $gtid_set_ini <> 0 and $gtid_set_end <> $gtid_set_ini`)
{
if (`SELECT NOT ("$info" REGEXP "$server_uuid:$gtid_set_ini-$gtid_set_end")`)
{
--source include/show_rpl_debug_info.inc
--echo $type $info -- Info should be $server_uuid:$gtid_set_ini-$gtid_set_end.
--let $datadir= `select @@datadir`
--echo log='$server_log'
--exec $MYSQL_BINLOG $datadir/$server_log
--eval $command_show in "$server_log"
--die
}
}
if ($gtid_set_end != 0 && $gtid_set_ini != 0 && $gtid_set_end == $gtid_set_ini)
{
if (`SELECT NOT ("$info" REGEXP "$server_uuid:$gtid_set_ini")`)
{
--source include/show_rpl_debug_info.inc
--echo $type $info -- Info should be $server_uuid:$gtid_set_ini.
--let $datadir= `select @@datadir`
--echo log='$server_log'
--exec $MYSQL_BINLOG $datadir/$server_log
--eval $command_show in "$server_log"
--die
}
}
}
if (`SELECT "$binlog" <> "" and "$gtid_end" <> "" and "$gtid_ini" <> ""`)
{
--let $type= unknown
--let $trans= `SELECT $gtid_ini`
--let $pos= 1
--let $info= unknown
--let $server_log= query_get_value($command_set, $command_set_info, 1)
while (`SELECT $trans <= $gtid_end AND "$type" <> "No such row"`)
{
--let $type= query_get_value($command_show in "$server_log", Event_type, $pos)
if ($type == Gtid)
{
--let $info= query_get_value($command_show in "$server_log", Info, $pos)
if (`SELECT "$info" REGEXP "^SET @@SESSION.GTID_NEXT= '$server_uuid:$trans'"`)
{
--let $trans= `SELECT $trans + 1`
}
}
--inc $pos
}
if ($trans <= $gtid_end)
{
--source include/show_rpl_debug_info.inc
--echo $type $info -- We should retrieve from $gtid_ini to $gtid_end.
--echo log='$server_log'
--eval $command_show in "$server_log"
--die
}
}