MasterSlave handles common tasks related to master-slave setups.
MasterSlave | MasterSlave handles common tasks related to master-slave setups. |
Functions | |
new | |
recurse_to_slaves | Descend to slaves by examining SHOW SLAVE HOSTS. |
find_slave_hosts | |
_find_slaves_by_processlist | |
_find_slaves_by_hosts | |
get_connected_slaves | |
is_master_of | |
get_master_dsn | |
get_slave_status | |
get_master_status | |
wait_for_master | Execute MASTER_POS_WAIT() to make slave wait for its master. |
stop_slave | |
start_slave | |
catchup_to_master | |
catchup_to_same_pos | |
slave_is_running | |
has_slave_updates | |
repl_posn | |
get_slave_lag | |
pos_cmp | |
short_host | Simplify a hostname as much as possible. |
is_replication_thread | Determine if a processlist item is a replication thread. |
get_replication_filters | Get any replication filters set on the host. |
pos_to_string | Stringify a position in a way that’s string-comparable. |
reset_known_replication_threads | |
_d |
sub recurse_to_slaves
Descend to slaves by examining SHOW SLAVE HOSTS. The callback gets the slave’s DSN, dbh, parent, and the recursion level as args. The recursion is tail recursion.
$args | Hashref of arguments |
$level | Recursion level |
dsn | The DSN to connect to; if no dbh arg, connect using this. |
recurse | How many levels to recurse. 0 = none, undef = infinite. |
callback | Code to execute after finding a new slave. |
dsn_parser | DSNParser object |
dbh | dbh |
skip_callback | Execute with slaves that will be skipped. |
method | Whether to prefer HOSTS over PROCESSLIST |
parent | The DSN from which this call descended. |
sub wait_for_master
Execute MASTER_POS_WAIT() to make slave wait for its master.
%args | Arguments |
Hashref with result of waiting, like:
{ result => the result returned by MASTER_POS_WAIT: -1, undef, 0+ waited => the number of seconds waited, might be zero }
sub short_host
Simplify a hostname as much as possible. For purposes of replication, a hostname is really just the combination of hostname and port, since replication always uses TCP connections (it does not work via sockets). If the port is the default 3306, it is omitted. As a convenience, this sub accepts either SHOW SLAVE STATUS or a DSN.
$dsn | DSN hashref |
Short hostname string
sub is_replication_thread
Determine if a processlist item is a replication thread.
$query | Hashref of a processlist item |
%args | Arguments |
type | Which kind of repl thread to match: all, binlog_dump (master), slave_io, or slave_sql (default: all) |
check_known_ids | Check known replication thread IDs (default: yes) |
True if the proclist item is the given type of replication thread.
sub new
Descend to slaves by examining SHOW SLAVE HOSTS.
sub recurse_to_slaves
sub find_slave_hosts
sub _find_slaves_by_processlist
sub _find_slaves_by_hosts
sub get_connected_slaves
sub is_master_of
sub get_master_dsn
sub get_slave_status
sub get_master_status
Execute MASTER_POS_WAIT() to make slave wait for its master.
sub wait_for_master
sub stop_slave
sub start_slave
sub catchup_to_master
sub catchup_to_same_pos
sub slave_is_running
sub has_slave_updates
sub repl_posn
sub get_slave_lag
sub pos_cmp
Simplify a hostname as much as possible.
sub short_host
Determine if a processlist item is a replication thread.
sub is_replication_thread
Get any replication filters set on the host.
sub get_replication_filters
Stringify a position in a way that’s string-comparable.
sub pos_to_string
sub reset_known_replication_threads
sub _d