1# ==== Purpose ====
2#
3# Wait until the slave has reached a certain GTID position.
4# Similar to --sync_with_master, but using GTID instead of old-style
5# binlog file/offset coordinates.
6#
7#
8# ==== Usage ====
9#
10# --let $master_pos= `SELECT @@GLOBAL.gtid_binlog_pos`
11# [--let $slave_timeout= NUMBER]
12# [--let $rpl_debug= 1]
13# --source include/sync_with_master_gtid.inc
14#
15# Syncs slave to the specified GTID position.
16#
17# Must be called on the slave.
18#
19# Parameters:
20#   $master_pos
21#     The GTID position to sync to. Typically obtained from
22#      @@GLOBAL.gtid_binlog_pos on the master.
23#
24#   $slave_timeout
25#      Timeout in seconds. The default is 2 minutes.
26#
27#   $rpl_debug
28#      See include/rpl_init.inc
29
30--let $include_filename= sync_with_master_gtid.inc
31--source include/begin_include_file.inc
32
33let $_slave_timeout= $slave_timeout;
34if (!$_slave_timeout)
35{
36  let $_slave_timeout= 120;
37  if ($VALGRIND_TEST)
38  {
39    let $_slave_timeout= 1200;
40  }
41}
42
43--let $_result= `SELECT master_gtid_wait('$master_pos', $_slave_timeout)`
44if ($_result == -1)
45{
46  --let $_current_gtid_pos= `SELECT @@GLOBAL.gtid_slave_pos`
47  --echo Timeout in master_gtid_wait('$master_pos', $_slave_timeout), current slave GTID position is: $_current_gtid_pos.
48  --die Failed to sync with master
49}
50
51--let $include_filename= sync_with_master_gtid.inc
52--source include/end_include_file.inc
53