MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
rpl_check_gtid.inc
1 ################################################################################
2 # This file aims to check if a log, either binary or relay log, has correctly
3 # stored the Previous_gtids_log_event and Gtid_log_event events.
4 #
5 # Options:
6 # (Type of the log: binlog or relaylog)
7 # --let $binlog= <type_log>
8 # (Check in the current log has <set_ini>-<set_end> in Previous GTIDs)
9 # $gtid_set_ini= <set_ini>
10 # $gtid_set_end= <set_end>
11 # (Check in the current log has GTIDs from <gtid_ini> to <gtid_end>)
12 # $gtid_ini= <gtid_ini>
13 # $gtid_end= <gtid_end>
14 # (Enable or disable debug)
15 # --let $debug= <enabled>
16 #
17 # Usage:
18 # --let $binlog= <type_log>
19 # --let $gtid_set_ini= <set_ini>
20 # --let $gtid_set_end= <set_end>
21 # --let $gtid_ini= <gtid_ini>
22 # --let $gtid_end= <gtid_end>
23 # --source extra/rpl_tests/rpl_check_gtid.inc
24 #
25 # Example (Checking both Previous GTIDs and current Gtids in the master's
26 # current binary log):
27 # --connection master
28 # --let $binlog= binlog
29 # --let $gtid_set_ini= <set_ini>
30 # --let $gtid_set_end= <set_end>
31 # --let $gtid_ini= <gtid_ini>
32 # --let $gtid_end= <gtid_end>
33 # --source extra/rpl_tests/rpl_check_gtid.inc
34 #
35 # Example (Checking Previous GTIDs in the slave's current binary log):
36 # --connection slave
37 # --let $binlog= binlog
38 # --let $gtid_set_ini= <set_ini>
39 # --let $gtid_set_end= <set_end>
40 # --let $gtid_ini=
41 # --let $gtid_end=
42 # --source extra/rpl_tests/rpl_check_gtid.inc
43 #
44 # Example (Checking GTIDs in the slave's current relay log):
45 # --connection slave
46 # --let $binlog= relaylog
47 # --let $gtid_set_ini=
48 # --let $gtid_set_end=
49 # --let $gtid_ini= <gtid_ini>
50 # --let $gtid_end= <gtid_end>
51 # --source extra/rpl_tests/rpl_check_gtid.inc
52 ################################################################################
53 
54 --echo extra/rpl_tests/rpl_check_gtid.inc
55 
56 if (`SELECT "$binlog" = "binlog"`)
57 {
58  --let $command_set= SHOW MASTER STATUS
59  --let $command_set_info= File
60  --let $command_show= SHOW BINLOG EVENTS
61 }
62 
63 if (`SELECT "$binlog" = "relaylog"`)
64 {
65  --let $command_set= SHOW SLAVE STATUS
66  --let $command_set_info= Relay_Log_File
67  --let $command_show= SHOW RELAYLOG EVENTS
68 }
69 
70 
71 if (`SELECT "$binlog" <> "" and "$gtid_set_end" <> "" and "$gtid_set_ini" <> ""`)
72 {
73  --let $server_log= query_get_value($command_set, $command_set_info, 1)
74  if (`SELECT "$debug" <> ""`)
75  {
76  --eval $command_show in "$server_log"
77  }
78  --let $type= query_get_value($command_show in "$server_log", Event_type, 2)
79  --let $info= query_get_value($command_show in "$server_log", Info, 2)
80  if ($type != Previous_gtids)
81  {
82  --source include/show_rpl_debug_info.inc
83  --echo $type $info --- Type should be Previous_gtids.
84  --echo log='$server_log'
85  --eval $command_show in "$server_log"
86  --die
87  }
88  if ($gtid_set_end == 0 && $gtid_set_ini == 0)
89  {
90  if (`SELECT "$info" <> ""`)
91  {
92  --source include/show_rpl_debug_info.inc
93  --echo $type $info -- Info should be empty.
94  --let $datadir= `select @@datadir`
95  --echo log='$server_log'
96  --exec $MYSQL_BINLOG $datadir/$server_log
97  --eval $command_show in "$server_log"
98  --die
99  }
100  }
101  if (`SELECT $gtid_set_end <> 0 and $gtid_set_ini <> 0 and $gtid_set_end <> $gtid_set_ini`)
102  {
103  if (`SELECT NOT ("$info" REGEXP "$server_uuid:$gtid_set_ini-$gtid_set_end")`)
104  {
105  --source include/show_rpl_debug_info.inc
106  --echo $type $info -- Info should be $server_uuid:$gtid_set_ini-$gtid_set_end.
107  --let $datadir= `select @@datadir`
108  --echo log='$server_log'
109  --exec $MYSQL_BINLOG $datadir/$server_log
110  --eval $command_show in "$server_log"
111  --die
112  }
113  }
114  if ($gtid_set_end != 0 && $gtid_set_ini != 0 && $gtid_set_end == $gtid_set_ini)
115  {
116  if (`SELECT NOT ("$info" REGEXP "$server_uuid:$gtid_set_ini")`)
117  {
118  --source include/show_rpl_debug_info.inc
119  --echo $type $info -- Info should be $server_uuid:$gtid_set_ini.
120  --let $datadir= `select @@datadir`
121  --echo log='$server_log'
122  --exec $MYSQL_BINLOG $datadir/$server_log
123  --eval $command_show in "$server_log"
124  --die
125  }
126  }
127 }
128 
129 if (`SELECT "$binlog" <> "" and "$gtid_end" <> "" and "$gtid_ini" <> ""`)
130 {
131  --let $type= unknown
132  --let $trans= `SELECT $gtid_ini`
133  --let $pos= 1
134  --let $info= unknown
135  --let $server_log= query_get_value($command_set, $command_set_info, 1)
136  while (`SELECT $trans <= $gtid_end AND "$type" <> "No such row"`)
137  {
138  --let $type= query_get_value($command_show in "$server_log", Event_type, $pos)
139  if ($type == Gtid)
140  {
141  --let $info= query_get_value($command_show in "$server_log", Info, $pos)
142  if (`SELECT "$info" REGEXP "^SET @@SESSION.GTID_NEXT= '$server_uuid:$trans'"`)
143  {
144  --let $trans= `SELECT $trans + 1`
145  }
146  }
147  --inc $pos
148  }
149  if ($trans <= $gtid_end)
150  {
151  --source include/show_rpl_debug_info.inc
152  --echo $type $info -- We should retrieve from $gtid_ini to $gtid_end.
153  --echo log='$server_log'
154  --eval $command_show in "$server_log"
155  --die
156  }
157 }