Revert r49. Will handle s/slave/replica/ in another branch.

This commit is contained in:
Daniel Nichter
2011-07-21 14:27:59 -06:00
parent a98cba66be
commit 7108054565
4 changed files with 68 additions and 80 deletions

View File

@@ -2278,7 +2278,7 @@ sub info {
: print ts($now), " ", $message, "\n";
}
# Catches signals so pt-replica-delay can exit gracefully.
# Catches signals so pt-slave-delay can exit gracefully.
sub finish {
my ($signal) = @_;
print STDERR "Exiting on SIG$signal.\n";
@@ -2323,19 +2323,19 @@ if ( !caller ) { exit main(@ARGV); }
=head1 NAME
pt-replica-delay - Make a MySQL slave server lag behind its master.
pt-slave-delay - Make a MySQL slave server lag behind its master.
=head1 SYNOPSIS
Usage: pt-replica-delay [OPTION...] SLAVE-HOST [MASTER-HOST]
Usage: pt-slave-delay [OPTION...] SLAVE-HOST [MASTER-HOST]
pt-replica-delay starts and stops a slave server as needed to make it lag
pt-slave-delay starts and stops a slave server as needed to make it lag
behind the master. The SLAVE-HOST and MASTER-HOST use DSN syntax, and
values are copied from the SLAVE-HOST to the MASTER-HOST if omitted.
To hold slavehost one minute behind its master for ten minutes:
pt-replica-delay --delay 1m --interval 15s --run-time 10m slavehost
pt-slave-delay --delay 1m --interval 15s --run-time 10m slavehost
=head1 RISKS
@@ -2344,7 +2344,7 @@ whether known or unknown, of using this tool. The two main categories of risks
are those created by the nature of the tool (e.g. read-only tools vs. read-write
tools) and those created by bugs.
pt-replica-delay is generally very low-risk. It simply starts and stops the
pt-slave-delay is generally very low-risk. It simply starts and stops the
replication SQL thread. This might cause monitoring systems to think the slave
is having trouble.
@@ -2354,13 +2354,13 @@ users.
The authoritative source for updated information is always the online issue
tracking system. Issues that affect this tool will be marked as such. You can
see a list of such issues at the following URL:
L<http://www.percona.com/bugs/pt-replica-delay>.
L<http://www.percona.com/bugs/pt-slave-delay>.
See also L<"BUGS"> for more information on filing bugs and getting help.
=head1 DESCRIPTION
C<pt-replica-delay> watches a slave and starts and stops its replication SQL
C<pt-slave-delay> watches a slave and starts and stops its replication SQL
thread as necessary to hold it at least as far behind the master as you
request. In practice, it will typically cause the slave to lag between
L<"--delay"> and L<"--delay">+L<"--interval"> behind the master.
@@ -2369,11 +2369,11 @@ It bases the delay on binlog positions in the slave's relay logs by default,
so there is no need to connect to the master. This works well if the IO
thread doesn't lag the master much, which is typical in most replication
setups; the IO thread lag is usually milliseconds on a fast network. If your
IO thread's lag is too large for your purposes, C<pt-replica-delay> can also
IO thread's lag is too large for your purposes, C<pt-slave-delay> can also
connect to the master for information about binlog positions.
If the slave's I/O thread reports that it is waiting for the SQL thread to
free some relay log space, C<pt-replica-delay> will automatically connect to the
free some relay log space, C<pt-slave-delay> will automatically connect to the
master to find binary log positions. If L<"--ask-pass"> and L<"--daemonize">
are given, it is possible that this could cause it to ask for a password while
daemonized. In this case, it exits. Therefore, if you think your slave might
@@ -2382,23 +2382,23 @@ L<"--use-master"> explicitly when daemonizing, or don't specify L<"--ask-pass">.
The SLAVE-HOST and optional MASTER-HOST are both DSNs. See L<"DSN OPTIONS">.
Missing MASTER-HOST values are filled in with values from SLAVE-HOST, so you
don't need to specify them in both places. C<pt-replica-delay> reads all normal
don't need to specify them in both places. C<pt-slave-delay> reads all normal
MySQL option files, such as ~/.my.cnf, so you may not need to specify username,
password and other common options at all.
C<pt-replica-delay> tries to exit gracefully by trapping signals such as Ctrl-C.
C<pt-slave-delay> tries to exit gracefully by trapping signals such as Ctrl-C.
You cannot bypass L<"--[no]continue"> with a trappable signal.
=head1 PRIVILEGES
pt-replica-delay requires the following privileges: PROCESS, REPLICATION CLIENT,
pt-slave-delay requires the following privileges: PROCESS, REPLICATION CLIENT,
and SUPER.
=head1 OUTPUT
If you specify L<"--quiet">, there is no output. Otherwise, the normal output
is a status message consisting of a timestamp and information about what
C<pt-replica-delay> is doing: starting the slave, stopping the slave, or just
C<pt-slave-delay> is doing: starting the slave, stopping the slave, or just
observing.
=head1 OPTIONS
@@ -2436,7 +2436,7 @@ default: yes
Continue replication normally on exit. After exiting, restart the slave's SQL
thread with no UNTIL condition, so it will run as usual and catch up to the
master. This is enabled by default and works even if you terminate
C<pt-replica-delay> with Control-C.
C<pt-slave-delay> with Control-C.
=item --daemonize
@@ -2470,7 +2470,7 @@ Connect to host.
type: time; default: 1m
How frequently C<pt-replica-delay> should check whether the slave needs to be
How frequently C<pt-slave-delay> should check whether the slave needs to be
started or stopped.
=item --log
@@ -2511,7 +2511,7 @@ Don't print informational messages about operation. See L<OUTPUT> for details.
type: time
How long C<pt-replica-delay> should run before exiting. The default is to run
How long C<pt-slave-delay> should run before exiting. The default is to run
forever.
=item --set-vars
@@ -2532,10 +2532,10 @@ Socket file to use for connection.
Get binlog positions from master, not slave. Don't trust the binlog positions
in the slave's relay log. Connect to the master and get binlog positions
instead. If you specify this option without giving a MASTER-HOST on the command
line, C<pt-replica-delay> examines the slave's SHOW SLAVE STATUS to determine the
line, C<pt-slave-delay> examines the slave's SHOW SLAVE STATUS to determine the
hostname and port for connecting to the master.
C<pt-replica-delay> uses only the MASTER_HOST and MASTER_PORT values from SHOW
C<pt-slave-delay> uses only the MASTER_HOST and MASTER_PORT values from SHOW
SLAVE STATUS for the master connection. It does not use the MASTER_USER
value. If you want to specify a different username for the master than the
one you use to connect to the slave, you should specify the MASTER-HOST option
@@ -2636,7 +2636,7 @@ Replace C<TOOL> with the name of any tool.
The environment variable C<PTDEBUG> enables verbose debugging output to STDERR.
To enable debugging and capture all output to a file, run the tool like:
PTDEBUG=1 pt-replica-delay ... > FILE 2>&1
PTDEBUG=1 pt-slave-delay ... > FILE 2>&1
Be careful: debugging output is voluminous and can generate several megabytes
of output.
@@ -2648,7 +2648,7 @@ installed in any reasonably new version of Perl.
=head1 BUGS
For a list of known bugs, see L<http://www.percona.com/bugs/pt-replica-delay>.
For a list of known bugs, see L<http://www.percona.com/bugs/pt-slave-delay>.
Please report bugs at L<https://bugs.launchpad.net/percona-toolkit>.
Include the following information in your bug report:

View File

@@ -2796,17 +2796,17 @@ if ( !caller ) { exit main(@ARGV); }
=head1 NAME
pt-replica-find - Find and print replication hierarchy tree of MySQL slaves.
pt-slave-find - Find and print replication hierarchy tree of MySQL slaves.
=head1 SYNOPSIS
Usage: pt-replica-find [OPTION...] MASTER-HOST
Usage: pt-slave-find [OPTION...] MASTER-HOST
pt-replica-find finds and prints a hierarchy tree of MySQL slaves.
pt-slave-find finds and prints a hierarchy tree of MySQL slaves.
Examples:
pt-replica-find --host master-host
pt-slave-find --host master-host
=head1 RISKS
@@ -2815,7 +2815,7 @@ whether known or unknown, of using this tool. The two main categories of risks
are those created by the nature of the tool (e.g. read-only tools vs. read-write
tools) and those created by bugs.
pt-replica-find is read-only and very low-risk.
pt-slave-find is read-only and very low-risk.
At the time of this release, we know of no bugs that could cause serious harm to
users.
@@ -2823,13 +2823,13 @@ users.
The authoritative source for updated information is always the online issue
tracking system. Issues that affect this tool will be marked as such. You can
see a list of such issues at the following URL:
L<http://www.percona.com/bugs/pt-replica-find>.
L<http://www.percona.com/bugs/pt-slave-find>.
See also L<"BUGS"> for more information on filing bugs and getting help.
=head1 DESCRIPTION
pt-replica-find connects to a MySQL replication master and finds its slaves.
pt-slave-find connects to a MySQL replication master and finds its slaves.
Currently the only thing it can do is print a tree-like view of the replication
hierarchy.
@@ -2851,7 +2851,7 @@ C<1.2.3.4>), or a C<key=value,key=value> string. Keys are a single letter:
p Password to use when connecting
F Only read default options from the given file
C<pt-replica-find> reads all normal MySQL option files, such as ~/.my.cnf, so
C<pt-slave-find> reads all normal MySQL option files, such as ~/.my.cnf, so
you may not need to specify username, password and other common options at all.
=head1 EXIT STATUS
@@ -2959,7 +2959,7 @@ Possible methods are:
The processlist method is preferred because SHOW SLAVE HOSTS is not reliable.
However, the hosts method is required if the server uses a non-standard
port (not 3306). Usually pt-replica-find does the right thing and finds
port (not 3306). Usually pt-slave-find does the right thing and finds
the slaves, but you may give a preferred method and it will be used first.
If it doesn't find any slaves, the other methods will be tried.
@@ -3116,7 +3116,7 @@ Replace C<TOOL> with the name of any tool.
The environment variable C<PTDEBUG> enables verbose debugging output to STDERR.
To enable debugging and capture all output to a file, run the tool like:
PTDEBUG=1 pt-replica-find ... > FILE 2>&1
PTDEBUG=1 pt-slave-find ... > FILE 2>&1
Be careful: debugging output is voluminous and can generate several megabytes
of output.
@@ -3128,7 +3128,7 @@ installed in any reasonably new version of Perl.
=head1 BUGS
For a list of known bugs, see L<http://www.percona.com/bugs/pt-replica-find>.
For a list of known bugs, see L<http://www.percona.com/bugs/pt-slave-find>.
Please report bugs at L<https://bugs.launchpad.net/percona-toolkit>.
Include the following information in your bug report:

View File

@@ -2408,7 +2408,7 @@ sub main {
MKDEBUG && _d('Creating sentinel file', $sentinel);
my $file = IO::File->new($sentinel, ">>")
or die "Cannot open $sentinel: $OS_ERROR\n";
print $file "Remove this file to permit pt-replica-restart to run\n"
print $file "Remove this file to permit pt-slave-restart to run\n"
or die "Cannot write to $sentinel: $OS_ERROR\n";
close $file
or die "Cannot close $sentinel: $OS_ERROR\n";
@@ -2722,8 +2722,8 @@ sub watch_server {
# Errors are very likely to follow each other in quick succession. NOTE:
# this policy has a side effect with respect to $sleep. Suppose $sleep is
# 512 and pt-replica-restart finds an error; now $sleep is 256, but
# pt-replica-restart sleeps only 1 (the initial value of --sleep). Suppose
# 512 and pt-slave-restart finds an error; now $sleep is 256, but
# pt-slave-restart sleeps only 1 (the initial value of --sleep). Suppose
# there is no error when it wakes up after 1 second, because 1 was too
# short. Now it doubles $sleep, back to 512. $sleep has the same value
# it did before the error was ever found.
@@ -2797,13 +2797,13 @@ if ( !caller ) { exit main(@ARGV); }
=head1 NAME
pt-replica-restart - Watch and restart MySQL replication after errors.
pt-slave-restart - Watch and restart MySQL replication after errors.
=head1 SYNOPSIS
Usage: pt-replica-restart [OPTION...] [DSN]
Usage: pt-slave-restart [OPTION...] [DSN]
pt-replica-restart watches one or more MySQL replication slaves for
pt-slave-restart watches one or more MySQL replication slaves for
errors, and tries to restart replication if it stops.
=head1 RISKS
@@ -2813,7 +2813,7 @@ whether known or unknown, of using this tool. The two main categories of risks
are those created by the nature of the tool (e.g. read-only tools vs. read-write
tools) and those created by bugs.
pt-replica-restart is a brute-force way to try to keep a slave server running when
pt-slave-restart is a brute-force way to try to keep a slave server running when
it is having problems with replication. Don't be too hasty to use it unless you
need to. If you use this tool carelessly, you might miss the chance to really
solve the slave server's problems.
@@ -2824,13 +2824,13 @@ C<CHANGE MASTER TO> statement to be executed.
The authoritative source for updated information is always the online issue
tracking system. Issues that affect this tool will be marked as such. You can
see a list of such issues at the following URL:
L<http://www.percona.com/bugs/pt-replica-restart>.
L<http://www.percona.com/bugs/pt-slave-restart>.
See also L<"BUGS"> for more information on filing bugs and getting help.
=head1 DESCRIPTION
pt-replica-restart watches one or more MySQL replication slaves and tries to skip
pt-slave-restart watches one or more MySQL replication slaves and tries to skip
statements that cause errors. It polls slaves intelligently with an
exponentially varying sleep time. You can specify errors to skip and run the
slaves until a certain binlog position.
@@ -2844,12 +2844,12 @@ when I have an error I know I just need to skip past.
=head1 OUTPUT
If you specify L<"--verbose">, pt-replica-restart prints a line every time it sees
If you specify L<"--verbose">, pt-slave-restart prints a line every time it sees
the slave has an error. See L<"--verbose"> for details.
=head1 SLEEP
pt-replica-restart sleeps intelligently between polling the slave. The current
pt-slave-restart sleeps intelligently between polling the slave. The current
sleep time varies.
=over
@@ -2873,7 +2873,7 @@ L<"--max-sleep">.
=item *
Immediately after finding an error, pt-replica-restart assumes another error is
Immediately after finding an error, pt-slave-restart assumes another error is
very likely to happen next, so it sleeps the current sleep time or the initial
sleep time, whichever is less.
@@ -2888,7 +2888,7 @@ servers to monitor.
=head1 COMPATIBILITY
pt-replica-restart should work on many versions of MySQL. Lettercase of many
pt-slave-restart should work on many versions of MySQL. Lettercase of many
output columns from SHOW SLAVE STATUS has changed over time, so it treats them
all as lowercase.
@@ -2902,7 +2902,7 @@ L<"SYNOPSIS"> and usage information for details.
=item --always
Start slaves even when there is no error. With this option enabled,
pt-replica-restart will not let you stop the slave manually if you want to!
pt-slave-restart will not let you stop the slave manually if you want to!
=item --ask-pass
@@ -2924,7 +2924,7 @@ default: yes
Check the last relay log file and position before checking for slave errors.
By default pt-replica-restart will not doing anything (it will just sleep)
By default pt-slave-restart will not doing anything (it will just sleep)
if neither the relay log file nor the relay log position have changed since
the last check. This prevents infinite loops (i.e. restarting the same
error in the same relay log file at the same relay log position).
@@ -2970,7 +2970,7 @@ length. This can be useful to prevent wrapping on the terminal.
type: hash
Only restart this comma-separated list of errors. Makes pt-replica-restart only
Only restart this comma-separated list of errors. Makes pt-slave-restart only
try to restart if the error number is in this comma-separated list of errors.
If it sees an error not in the list, it will exit.
@@ -2982,8 +2982,8 @@ type: string
Only restart errors that match this pattern. A Perl regular expression against
which the error text, if any, is matched. If the error text exists and matches,
pt-replica-restart will try to restart the slave. If it exists but doesn't match,
pt-replica-restart will exit.
pt-slave-restart will try to restart the slave. If it exists but doesn't match,
pt-slave-restart will exit.
The error text is in the C<last_error> column of C<SHOW SLAVE STATUS>.
@@ -3009,8 +3009,8 @@ type: float; default: 64
Maximum sleep seconds.
The maximum time pt-replica-restart will sleep before polling the slave again.
This is also the time that pt-replica-restart will wait for all other running
The maximum time pt-slave-restart will sleep before polling the slave again.
This is also the time that pt-slave-restart will wait for all other running
instances to quit if both L<"--stop"> and L<"--monitor"> are specified.
See L<"SLEEP">.
@@ -3019,7 +3019,7 @@ See L<"SLEEP">.
type: float; default: 0.015625
The minimum time pt-replica-restart will sleep before polling the slave again.
The minimum time pt-slave-restart will sleep before polling the slave again.
See L<"SLEEP">.
=item --monitor
@@ -3063,11 +3063,11 @@ Watch slaves of the specified server, up to the specified number of servers deep
in the hierarchy. The default depth of 0 means "just watch the slave
specified."
pt-replica-restart examines C<SHOW PROCESSLIST> and tries to determine which
pt-slave-restart examines C<SHOW PROCESSLIST> and tries to determine which
connections are from slaves, then connect to them. See L<"--recursion-method">.
Recursion works by finding all slaves when the program starts, then watching
them. If there is more than one slave, C<pt-replica-restart> uses C<fork()> to
them. If there is more than one slave, C<pt-slave-restart> uses C<fork()> to
monitor them.
This also works if you have configured your slaves to show up in C<SHOW SLAVE
@@ -3090,7 +3090,7 @@ Possible methods are:
The processlist method is preferred because SHOW SLAVE HOSTS is not reliable.
However, the hosts method is required if the server uses a non-standard
port (not 3306). Usually pt-replica-restart does the right thing and finds
port (not 3306). Usually pt-slave-restart does the right thing and finds
the slaves, but you may give a preferred method and it will be used first.
If it doesn't find any slaves, the other methods will be tried.
@@ -3098,13 +3098,13 @@ If it doesn't find any slaves, the other methods will be tried.
type: time
Time to run before exiting. Causes pt-replica-restart to stop after the specified
Time to run before exiting. Causes pt-slave-restart to stop after the specified
time has elapsed. Optional suffix: s=seconds, m=minutes, h=hours, d=days; if no
suffix, s is used.
=item --sentinel
type: string; default: /tmp/pt-replica-restart-sentinel
type: string; default: /tmp/pt-slave-restart-sentinel
Exit if this file exists.
@@ -3139,20 +3139,20 @@ Socket file to use for connection.
Stop running instances by creating the sentinel file.
Causes C<pt-replica-restart> to create the sentinel file specified by
Causes C<pt-slave-restart> to create the sentinel file specified by
L<"--sentinel">. This should have the effect of stopping all running
instances which are watching the same sentinel file. If L<"--monitor"> isn't
specified, C<pt-replica-restart> will exit after creating the file. If it is
specified, C<pt-replica-restart> will wait the interval given by
specified, C<pt-slave-restart> will exit after creating the file. If it is
specified, C<pt-slave-restart> will wait the interval given by
L<"--max-sleep">, then remove the file and continue working.
You might find this handy to stop cron jobs gracefully if necessary, or to
replace one running instance with another. For example, if you want to stop
and restart C<pt-replica-restart> every hour (just to make sure that it is
and restart C<pt-slave-restart> every hour (just to make sure that it is
restarted every hour, in case of a server crash or some other problem), you
could use a C<crontab> line like this:
0 * * * * pt-replica-restart --monitor --stop --sentinel /tmp/pt-replica-restartup
0 * * * * pt-slave-restart --monitor --stop --sentinel /tmp/pt-slave-restartup
The non-default L<"--sentinel"> will make sure the hourly C<cron> job stops
only instances previously started with the same options (that is, from the
@@ -3172,7 +3172,7 @@ the filename and position with a single comma and no space.
This will also cause an UNTIL clause to be given to START SLAVE.
After reaching this point, the slave should be stopped and pt-replica-restart
After reaching this point, the slave should be stopped and pt-slave-restart
will exit.
=item --until-relay
@@ -3196,7 +3196,7 @@ short form: -v; cumulative: yes; default: 1
Be verbose; can specify multiple times. Verbosity 1 outputs connection
information, a timestamp, relay_log_file, relay_log_pos, and last_errno.
Verbosity 2 adds last_error. See also L<"--error-length">. Verbosity 3 prints
the current sleep time each time pt-replica-restart sleeps.
the current sleep time each time pt-slave-restart sleeps.
=item --version
@@ -3287,7 +3287,7 @@ Replace C<TOOL> with the name of any tool.
The environment variable C<PTDEBUG> enables verbose debugging output to STDERR.
To enable debugging and capture all output to a file, run the tool like:
PTDEBUG=1 pt-replica-restart ... > FILE 2>&1
PTDEBUG=1 pt-slave-restart ... > FILE 2>&1
Be careful: debugging output is voluminous and can generate several megabytes
of output.
@@ -3299,7 +3299,7 @@ installed in any reasonably new version of Perl.
=head1 BUGS
For a list of known bugs, see L<http://www.percona.com/bugs/pt-replica-restart>.
For a list of known bugs, see L<http://www.percona.com/bugs/pt-slave-restart>.
Please report bugs at L<https://bugs.launchpad.net/percona-toolkit>.
Include the following information in your bug report:

View File

@@ -33,19 +33,7 @@ else {
$sb->create_dbs($master_dbh, ['test']);
$master_dbh->do('CREATE TABLE test.t (a INT)');
my $i = 0;
PerconaTest::wait_until(
sub {
my $r;
eval {
$r = $slave_dbh->selectrow_arrayref('SHOW TABLES FROM test LIKE "t"');
};
return 1 if ($r->[0] || '') eq 't';
diag('Waiting for CREATE TABLE to replicate...') unless $i++;
return 0;
},
0.5,
30,
);
PerconaTest::wait_for_table($slave_dbh, 'test.t');
# Bust replication
$slave_dbh->do('DROP TABLE test.t');