Compare commits

...

32 Commits

Author SHA1 Message Date
Dima
13d3650df9 Changing links in other scrits 2018-12-07 11:01:14 +03:00
Dima
c8cfebe299 PT-1605 fix with removing launchpad links 2018-12-06 14:49:08 +03:00
Carlos Salguero
cf5c661d46 Merge pull request #378 from percona/PT-1667
PT-1667 Added replication channels support to pt-archiver
2018-12-05 14:16:56 -03:00
Carlos Salguero
152712f799 PT-1667 Added replication channels support to pt-archiver 2018-12-05 14:15:51 -03:00
Carlos Salguero
d6b8863a3a Merge pull request #375 from percona/PXB-1615
PXB-1615 WIP Updates for Percona XtraBackup
2018-11-22 09:59:44 -03:00
Carlos Salguero
ae923ad61a Merge pull request #373 from percona/PT-1637_checksum__not_detecting_failing_slaves
PT-1637 Added --fail-on stopped-replication param to table checksum
2018-11-20 15:04:05 -03:00
Carlos Salguero
18b609e7a9 Merge pull request #374 from percona/PT_1638_pt-osc_mariadb
PT-1638 Fixed MariaDB support
2018-11-12 09:37:42 -03:00
Carlos Salguero
348c105639 PT-1638 Fixed MariaDB support
Because https://bugs.mysql.com/bug.php?id=89441 pt-osc with --drop-swap
doesn't work with MySQL 8.0+ (it will be fixed in MySQL 8.0.14) but it
should work with MariaDB 10.
Fixed version comparison to include the MySQL 'flavor'.
2018-11-12 09:34:40 -03:00
Carlos Salguero
1703ee58a4 PT-1637 Added tests and exit code 2018-11-08 15:35:25 -03:00
Carlos Salguero
c5ec28fcd6 PT-1637 Added --fail-on stopped-replication param to table checksum 2018-11-08 14:18:18 -03:00
Carlos Salguero
eb6beefd90 Merge pull request #366 from percona/PT-1616
PT-1616 pt-table-checksum fails to --resume on certain binary strings
2018-10-26 09:44:34 -03:00
Carlos Salguero
b8be202003 PT-1616 Added 1300 to the list of ignored warnings 2018-10-09 10:49:55 -03:00
Carlos Salguero
9d52a1b5e2 PT-1616 Added invalid utf-8 chars to the test 2018-10-07 14:00:39 -03:00
Carlos Salguero
ab92feb875 Merge pull request #351 from guriandoro/PT-1534
PT-1534 Support for --version
2018-10-07 10:21:33 -03:00
Carlos Salguero
7c927b6614 PXB-1615 WIP Updates for Percona XtraBackup
Changes made should be working but to properly test them, I need to set
up a development API with the new items for XtraBackup in the DB.
2018-09-26 14:40:11 -03:00
Carlos Salguero
5498a4da81 Merge pull request #371 from percona/PT-1618-b
PT-1618 Fixed documentation typos
2018-09-26 09:52:14 -03:00
Carlos Salguero
45a8579af7 PT-1618 Fixed documentation typos 2018-09-26 09:51:37 -03:00
Carlos Salguero
8ad1481c6c Merge pull request #370 from percona/PT-1573
PT-1573 Fixed General log parser regex
2018-09-26 09:29:45 -03:00
Carlos Salguero
2b5c8f69ab PT-1573 Fixed General log parser regex
The regexp to process log entries was not considering timestamps in +n,
it was only considering timestamps in -n hours
2018-09-26 09:25:33 -03:00
Carlos Salguero
91484a7bb5 Merge branch '3.0' into PT-1616 2018-09-25 17:34:28 -03:00
Carlos Salguero
eec92a7387 Updated Percona::Toolkit version to 3.0.13-dev 2018-09-25 17:33:01 -03:00
Carlos Salguero
07dd17f29c PT-1616 pt-table-checksum fails on --resume
pt-table-checksum is serializing the chunk boundaries before saving them
into the checksum table. On some cases, --resume was failing and it was
because it wasn't properly deserializing the values for the boundaries
for compound primary keys.
2018-09-25 17:26:31 -03:00
Carlos Salguero
97df37a94e PT-1616 Failing test case using plain varchar fields 2018-09-25 13:30:12 -03:00
Carlos Salguero
8f0c80891c PT-1616 Added failing test case 2018-09-24 19:12:19 -03:00
Carlos Salguero
d3741ca915 Merge pull request #363 from percona/release-3.0.12
RM-387 Updated version, changelog and release notes
2018-09-24 10:52:14 -03:00
Carlos Salguero
36088049cc Merge pull request #365 from percona/PT-1340
PT-1340 removed debug param from default mysqladmin command
2018-09-24 10:15:49 -03:00
Carlos Salguero
964ed4c05c PT-1340 removed debug param from default mysqladmin command 2018-09-24 10:10:18 -03:00
Dmitriy Kostiuk
3e0490dd3a Update rn.3-0-12.txt 2018-09-13 18:46:08 +03:00
guriandoro
8e90b31b3b PT-1534 Adding support for --version argument 2018-07-04 18:13:07 -04:00
guriandoro
57bb51f467 Changed pt-secure-data in readme file 2018-07-03 22:42:02 -04:00
guriandoro
d3644bd2e8 Refactored pt-secure-data to pt-secure-collect 2018-07-03 21:19:23 -04:00
guriandoro
9d8410c915 PT-1535 Changed tool name in --help output message 2018-07-03 20:53:18 -04:00
51 changed files with 614 additions and 90 deletions

14
Gopkg.lock generated
View File

@@ -73,6 +73,18 @@
packages = ["."]
revision = "bf9dde6d0d2c004a008c27aaee91170c786f6db8"
[[projects]]
name = "github.com/kr/pretty"
packages = ["."]
revision = "73f6ac0b30a98e433b289500d779f50c1a6f0712"
version = "v0.1.0"
[[projects]]
name = "github.com/kr/text"
packages = ["."]
revision = "e2ffdb16a802fe2bb95e2e35ff34f0e53aeef34f"
version = "v0.1.0"
[[projects]]
name = "github.com/mattn/go-shellwords"
packages = ["."]
@@ -195,6 +207,6 @@
[solve-meta]
analyzer-name = "dep"
analyzer-version = 1
inputs-digest = "6e2c1fd110c892297e79498479e87f7d4c63755a5a1d63d13c82eb42a7e5fbf2"
inputs-digest = "35a93d0003438bc707c085101ccfca910f349d201cd01edc986d0ed64ef2a12f"
solver-name = "gps-cdcl"
solver-version = 1

View File

@@ -1287,7 +1287,7 @@ reasonably new version of Perl.
For a list of known bugs, see L<http://www.percona.com/bugs/pt-align>.
Please report bugs at L<https://bugs.launchpad.net/percona-toolkit>.
Please report bugs at L<https://jira.percona.com/projects/PT>.
Include the following information in your bug report:
=over

View File

@@ -45,7 +45,7 @@ BEGIN {
{
package Percona::Toolkit;
our $VERSION = '3.0.12';
our $VERSION = '3.0.13-dev';
use strict;
use warnings FATAL => 'all';
@@ -6275,6 +6275,7 @@ sub main {
OptionParser => $o,
DSNParser => $dp,
Quoter => $q,
channel => $o->get('channel'),
);
# we get each slave's connection handler (and its id, for debug and reporting)
for my $slave (@$lag_slaves_dsn) {
@@ -7472,6 +7473,18 @@ If C<LOAD DATA LOCAL INFILE> throws an error in the lines of C<The used
command is not allowed with this MySQL version>, refer to the documentation
for the C<L> DSN option.
=item --channel
type: string
Channel name used when connected to a server using replication channels.
Suppose you have two masters, master_a at port 12345, master_b at port 1236 and
a slave connected to both masters using channels chan_master_a and chan_master_b.
If you want to run pt-archiver to syncronize the slave against master_a, pt-archiver
won't be able to determine what's the correct master since SHOW SLAVE STATUS
will return 2 rows. In this case, you can use --channel=chan_master_a to specify
the channel name to use in the SHOW SLAVE STATUS command.
=item --charset
short form: -A; type: string
@@ -8517,7 +8530,7 @@ installed in any reasonably new version of Perl.
For a list of known bugs, see L<http://www.percona.com/bugs/pt-archiver>.
Please report bugs at L<https://bugs.launchpad.net/percona-toolkit>.
Please report bugs at L<https://jira.percona.com/projects/PT>.
Include the following information in your bug report:
=over

View File

@@ -43,7 +43,7 @@ BEGIN {
{
package Percona::Toolkit;
our $VERSION = '3.0.12';
our $VERSION = '3.0.13-dev';
use strict;
use warnings FATAL => 'all';
@@ -5819,7 +5819,7 @@ installed in any reasonably new version of Perl.
For a list of known bugs, see L<http://www.percona.com/bugs/pt-config-diff>.
Please report bugs at L<https://bugs.launchpad.net/percona-toolkit>.
Please report bugs at L<https://jira.percona.com/projects/PT>.
Include the following information in your bug report:
=over

View File

@@ -42,7 +42,7 @@ BEGIN {
{
package Percona::Toolkit;
our $VERSION = '3.0.12';
our $VERSION = '3.0.13-dev';
use strict;
use warnings FATAL => 'all';
@@ -5608,7 +5608,7 @@ installed in any reasonably new version of Perl.
For a list of known bugs, see L<http://www.percona.com/bugs/pt-deadlock-logger>.
Please report bugs at L<https://bugs.launchpad.net/percona-toolkit>.
Please report bugs at L<https://jira.percona.com/projects/PT>.
Include the following information in your bug report:
=over

View File

@@ -38,7 +38,7 @@ BEGIN {
{
package Percona::Toolkit;
our $VERSION = '3.0.12';
our $VERSION = '3.0.13-dev';
use strict;
use warnings FATAL => 'all';
@@ -5602,7 +5602,7 @@ reading from files.
For a list of known bugs, see L<http://www.percona.com/bugs/pt-diskstats>.
Please report bugs at L<https://bugs.launchpad.net/percona-toolkit>.
Please report bugs at L<https://jira.percona.com/projects/PT>.
Include the following information in your bug report:
=over

View File

@@ -39,7 +39,7 @@ BEGIN {
{
package Percona::Toolkit;
our $VERSION = '3.0.12';
our $VERSION = '3.0.13-dev';
use strict;
use warnings FATAL => 'all';
@@ -5671,7 +5671,7 @@ installed in any reasonably new version of Perl.
For a list of known bugs, see L<http://www.percona.com/bugs/pt-duplicate-key-checker>.
Please report bugs at L<https://bugs.launchpad.net/percona-toolkit>.
Please report bugs at L<https://jira.percona.com/projects/PT>.
Include the following information in your bug report:
=over

View File

@@ -1576,7 +1576,7 @@ installed in any reasonably new version of Perl.
For a list of known bugs, see L<http://www.percona.com/bugs/pt-fifo-split>.
Please report bugs at L<https://bugs.launchpad.net/percona-toolkit>.
Please report bugs at L<https://jira.percona.com/projects/PT>.
Include the following information in your bug report:
=over

View File

@@ -35,7 +35,7 @@ BEGIN {
{
package Percona::Toolkit;
our $VERSION = '3.0.12';
our $VERSION = '3.0.13-dev';
use strict;
use warnings FATAL => 'all';
@@ -5032,7 +5032,7 @@ installed in any reasonably new version of Perl.
For a list of known bugs, see L<http://www.percona.com/bugs/pt-find>.
Please report bugs at L<https://bugs.launchpad.net/percona-toolkit>.
Please report bugs at L<https://jira.percona.com/projects/PT>.
Include the following information in your bug report:
=over

View File

@@ -2168,7 +2168,7 @@ installed in any reasonably new version of Perl.
For a list of known bugs, see L<http://www.percona.com/bugs/pt-fingerprint>.
Please report bugs at L<https://bugs.launchpad.net/percona-toolkit>.
Please report bugs at L<https://jira.percona.com/projects/PT>.
Include the following information in your bug report:
=over

View File

@@ -37,7 +37,7 @@ BEGIN {
{
package Percona::Toolkit;
our $VERSION = '3.0.12';
our $VERSION = '3.0.13-dev';
use strict;
use warnings FATAL => 'all';
@@ -4595,7 +4595,7 @@ installed in any reasonably new version of Perl.
For a list of known bugs, see L<http://www.percona.com/bugs/pt-fk-error-logger>.
Please report bugs at L<https://bugs.launchpad.net/percona-toolkit>.
Please report bugs at L<https://jira.percona.com/projects/PT>.
Include the following information in your bug report:
=over

View File

@@ -44,7 +44,7 @@ BEGIN {
{
package Percona::Toolkit;
our $VERSION = '3.0.12';
our $VERSION = '3.0.13-dev';
use strict;
use warnings FATAL => 'all';
@@ -7271,7 +7271,7 @@ installed in any reasonably new version of Perl.
For a list of known bugs, see L<http://www.percona.com/bugs/pt-heartbeat>.
Please report bugs at L<https://bugs.launchpad.net/percona-toolkit>.
Please report bugs at L<https://jira.percona.com/projects/PT>.
Include the following information in your bug report:
=over

View File

@@ -45,7 +45,7 @@ BEGIN {
{
package Percona::Toolkit;
our $VERSION = '3.0.12';
our $VERSION = '3.0.13-dev';
use strict;
use warnings FATAL => 'all';
@@ -7601,7 +7601,7 @@ installed in any reasonably new version of Perl.
For a list of known bugs, see L<http://www.percona.com/bugs/pt-index-usage>.
Please report bugs at L<https://bugs.launchpad.net/percona-toolkit>.
Please report bugs at L<https://jira.percona.com/projects/PT>.
Include the following information in your bug report:
=over

View File

@@ -1055,7 +1055,7 @@ This tool requires the Bourne shell (F</bin/sh>).
For a list of known bugs, see L<http://www.percona.com/bugs/pt-ioprofile>.
Please report bugs at L<https://bugs.launchpad.net/percona-toolkit>.
Please report bugs at L<https://jira.percona.com/projects/PT>.
Include the following information in your bug report:
=over

View File

@@ -47,7 +47,7 @@ BEGIN {
{
package Percona::Toolkit;
our $VERSION = '3.0.12';
our $VERSION = '3.0.13-dev';
use strict;
use warnings FATAL => 'all';
@@ -8429,7 +8429,7 @@ installed in any reasonably new version of Perl.
For a list of known bugs, see L<http://www.percona.com/bugs/pt-kill>.
Please report bugs at L<https://bugs.launchpad.net/percona-toolkit>.
Please report bugs at L<https://jira.percona.com/projects/PT>.
Include the following information in your bug report:
=over

View File

@@ -732,7 +732,7 @@ This tool requires the Bourne shell (F</bin/sh>) and the seq program.
For a list of known bugs, see L<http://www.percona.com/bugs/pt-mext>.
Please report bugs at L<https://bugs.launchpad.net/percona-toolkit>.
Please report bugs at L<https://jira.percona.com/projects/PT>.
Include the following information in your bug report:
=over

View File

@@ -3218,7 +3218,7 @@ On BSD systems, it may require a mounted procfs.
For a list of known bugs, see L<http://www.percona.com/bugs/pt-mysql-summary>.
Please report bugs at L<https://bugs.launchpad.net/percona-toolkit>.
Please report bugs at L<https://jira.percona.com/projects/PT>.
Include the following information in your bug report:
=over

View File

@@ -56,7 +56,7 @@ BEGIN {
{
package Percona::Toolkit;
our $VERSION = '3.0.12';
our $VERSION = '3.0.13-dev';
use strict;
use warnings FATAL => 'all';
@@ -4980,6 +4980,9 @@ sub wait {
. " seconds on $dsn_name. Waiting.\n";
}
else {
if ($self->{fail_on_stopped_replication}) {
die 'replication is stopped';
}
print STDERR "Replica $dsn_name is stopped. Waiting.\n";
}
return;
@@ -4989,6 +4992,9 @@ sub wait {
$pr_first_report = sub {
my $dsn_name = $worst->{cxn}->name();
if ( !defined $worst->{lag} ) {
if ($self->{fail_on_stopped_replication}) {
die 'replication is stopped';
}
print STDERR "Replica $dsn_name is stopped. Waiting.\n";
}
return;
@@ -5002,7 +5008,7 @@ sub wait {
my $lag = $get_lag->($lagged_slaves[$i]->{cxn});
PTDEBUG && _d($lagged_slaves[$i]->{cxn}->name(),
'slave lag:', $lag);
if ( defined $lag && $lag > $max_lag ) {
if ( !defined $lag || $lag > $max_lag ) {
$lagged_slaves[$i]->{lag} = $lag;
}
else {
@@ -9817,7 +9823,8 @@ sub main {
}
}
if ($server_version >= '8.0' && $alter_fk_method eq 'drop_swap') {
my $vp = VersionParser->new($cxn->dbh());
if ($vp->cmp('8.0') > -1 && $vp->flavor() !~ m/maria/i && $alter_fk_method eq 'drop_swap') {
my $msg = "--alter-foreign-keys-method=drop_swap doesn't work with MySQL 8.0+\n".
"See https://bugs.mysql.com/bug.php?id=89441";
die($msg);

View File

@@ -825,7 +825,7 @@ on the command line.
For a list of known bugs, see L<http://www.percona.com/bugs/pt-pmp>.
Please report bugs at L<https://bugs.launchpad.net/percona-toolkit>.
Please report bugs at L<https://jira.percona.com/projects/PT>.
Include the following information in your bug report:
=over

View File

@@ -64,7 +64,7 @@ BEGIN {
{
package Percona::Toolkit;
our $VERSION = '3.0.12';
our $VERSION = '3.0.13-dev';
use strict;
use warnings FATAL => 'all';
@@ -9928,7 +9928,7 @@ sub new {
my $genlog_line_1= qr{
\A
(?:(\d{6}\s+\d{1,2}:\d\d:\d\d|\d{4}-\d{1,2}-\d{1,2}T\d\d:\d\d:\d\d\.\d+(?:Z|-?\d\d:\d\d)?))? # Timestamp
(?:(\d{6}\s+\d{1,2}:\d\d:\d\d|\d{4}-\d{1,2}-\d{1,2}T\d\d:\d\d:\d\d\.\d+(?:Z|[-+]?\d\d:\d\d)?))? # Timestamp
\s+
(?:\s*(\d+)) # Thread ID
\s
@@ -16715,7 +16715,7 @@ installed in any reasonably new version of Perl.
For a list of known bugs, see L<http://www.percona.com/bugs/pt-query-digest>.
Please report bugs at L<https://bugs.launchpad.net/percona-toolkit>.
Please report bugs at L<https://jira.percona.com/projects/PT>.
Include the following information in your bug report:
=over

View File

@@ -1173,7 +1173,7 @@ they will be fetched from the Internet if curl is available.
For a list of known bugs, see L<http://www.percona.com/bugs/pt-sift>.
Please report bugs at L<https://bugs.launchpad.net/percona-toolkit>.
Please report bugs at L<https://jira.percona.com/projects/PT>.
Include the following information in your bug report:
=over

View File

@@ -40,7 +40,7 @@ BEGIN {
{
package Percona::Toolkit;
our $VERSION = '3.0.12';
our $VERSION = '3.0.13-dev';
use strict;
use warnings FATAL => 'all';
@@ -4894,7 +4894,7 @@ installed in any reasonably new version of Perl.
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>.
Please report bugs at L<https://jira.percona.com/projects/PT>.
Include the following information in your bug report:
=over

View File

@@ -4410,7 +4410,7 @@ installed in any reasonably new version of Perl.
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>.
Please report bugs at L<https://jira.percona.com/projects/PT>.
Include the following information in your bug report:
=over

View File

@@ -41,7 +41,7 @@ BEGIN {
{
package Percona::Toolkit;
our $VERSION = '3.0.12';
our $VERSION = '3.0.13-dev';
use strict;
use warnings FATAL => 'all';
@@ -6046,7 +6046,7 @@ installed in any reasonably new version of Perl.
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>.
Please report bugs at L<https://jira.percona.com/projects/PT>.
Include the following information in your bug report:
=over

View File

@@ -833,7 +833,7 @@ collect() {
tail -f "$mysql_error_log" >"$d/$p-log_error" &
tail_error_log_pid=$!
$CMD_MYSQLADMIN $EXT_ARGV debug
$CMD_MYSQLADMIN $EXT_ARGV
else
log "Could not find the MySQL error log"
fi
@@ -2282,6 +2282,10 @@ of editing the source, you can call pt-stalk as
which will do exactly what you need. Combined with the plugin hooks, this
gives you a fine-grained control of what the tool does.
It is possible to enable C<debug> mode in mysqladmin specifying:
C<CMD_MYSQLADMIN='mysqladmin debug' pt-stalk params ...>
=head1 SYSTEM REQUIREMENTS
This tool requires Bash v3 or newer. Certain options require other programs:
@@ -2302,7 +2306,7 @@ This tool requires Bash v3 or newer. Certain options require other programs:
For a list of known bugs, see L<http://www.percona.com/bugs/pt-stalk>.
Please report bugs at L<https://bugs.launchpad.net/percona-toolkit>.
Please report bugs at L<https://jira.percona.com/projects/PT>.
Include the following information in your bug report:
=over

View File

@@ -2651,7 +2651,7 @@ This tool requires the Bourne shell (F</bin/sh>).
For a list of known bugs, see L<http://www.percona.com/bugs/pt-summary>.
Please report bugs at L<https://bugs.launchpad.net/percona-toolkit>.
Please report bugs at L<https://jira.percona.com/projects/PT>.
Include the following information in your bug report:
=over

View File

@@ -58,7 +58,7 @@ BEGIN {
{
package Percona::Toolkit;
our $VERSION = '3.0.12';
our $VERSION = '3.0.13-dev';
use strict;
use warnings FATAL => 'all';
@@ -469,11 +469,11 @@ sub _split_url {
sub write_header_lines {
(@_ == 2 && ref $_[1] eq 'HASH') || croak(q/Usage: $handle->write_header_lines(headers)/);
my($self, $headers) = @_;
my($self, $headers) = @_;
my $buf = '';
while (my ($k, $v) = each %$headers) {
my $field_name = lc $k;
my $field_name = lc $k;
$field_name =~ /\A [\x21\x23-\x27\x2A\x2B\x2D\x2E\x30-\x39\x41-\x5A\x5E-\x7A\x7C\x7E]+ \z/x
or croak(q/Invalid HTTP header field name: / . $Printable->($field_name));
$field_name =~ s/\b(\w)/\u$1/g;
@@ -6591,7 +6591,6 @@ sub next {
}
$self->{rowno} = 0;
$self->{have_rows} = 0;
}
PTDEBUG && _d('Done nibbling');
@@ -6890,7 +6889,7 @@ sub _get_bounds {
if ( defined $nibble->{lower_boundary}
&& defined $nibble->{upper_boundary} ) {
my $sth = $dbh->prepare($self->{resume_lb_sql});
my @ub = split ',', $nibble->{upper_boundary};
my @ub = $self->{Quoter}->deserialize_list($nibble->{upper_boundary});
PTDEBUG && _d($sth->{Statement}, 'params:', @ub);
$sth->execute(@ub);
$self->{next_lower} = $sth->fetchrow_arrayref();
@@ -8596,6 +8595,9 @@ sub wait {
. " seconds on $dsn_name. Waiting.\n";
}
else {
if ($self->{fail_on_stopped_replication}) {
die 'replication is stopped';
}
print STDERR "Replica $dsn_name is stopped. Waiting.\n";
}
return;
@@ -8605,6 +8607,9 @@ sub wait {
$pr_first_report = sub {
my $dsn_name = $worst->{cxn}->name();
if ( !defined $worst->{lag} ) {
if ($self->{fail_on_stopped_replication}) {
die 'replication is stopped';
}
print STDERR "Replica $dsn_name is stopped. Waiting.\n";
}
return;
@@ -9878,14 +9883,15 @@ my $original_qrt_plugin_master_status = undef;
# http://www.tldp.org/LDP/abs/html/exitcodes.html
our %PTC_EXIT_STATUS = (
# General flags:
ERROR => 1,
ALREADY_RUNNING => 2,
CAUGHT_SIGNAL => 4,
NO_SLAVES_FOUND => 8,
ERROR => 1,
ALREADY_RUNNING => 2,
CAUGHT_SIGNAL => 4,
NO_SLAVES_FOUND => 8,
# Tool-specific flags:
TABLE_DIFF => 16,
SKIP_CHUNK => 32,
SKIP_TABLE => 64,
TABLE_DIFF => 16,
SKIP_CHUNK => 32,
SKIP_TABLE => 64,
REPLICATION_STOPPED => 128,
);
# The following two hashes are used in exec_nibble().
@@ -9899,6 +9905,7 @@ my %ignore_code = (
# Ignore this warning because we have purposely set statement-based
# replication.
1592 => 1,
1300 => 1,
);
# Warn once per-table for these error codes if the error message
@@ -10718,6 +10725,7 @@ sub main {
oktorun => sub { return $oktorun && $have_time->(); },
get_lag => $get_lag,
sleep => $sleep,
fail_on_stopped_replication => $o->get('fail-on-stopped-replication'),
);
my $get_status;
@@ -11501,6 +11509,9 @@ sub main {
}
};
if ( $EVAL_ERROR ) {
if ($EVAL_ERROR =~ m/replication/) {
exit($PTC_EXIT_STATUS{REPLICATION_STOPPED});
}
# This should not happen. If it does, it's probably some bug
# or error that we're not catching.
warn ts(($oktorun ? "Error " : "Fatal error ")
@@ -13273,6 +13284,11 @@ L<"--[no]empty-replicate-table">). If specified twice, the tool actually
iterates through the chunking algorithm, printing the upper and lower boundary
values for each chunk, but not executing the checksum queries.
=item --fail-on-stopped-replication
If replication is stopped, fail with an error (exit status 128) instead of waiting
until replication is restarted.
=item --float-precision
type: int
@@ -14007,7 +14023,7 @@ installed in any reasonably new version of Perl.
For a list of known bugs, see L<http://www.percona.com/bugs/pt-table-checksum>.
Please report bugs at L<https://bugs.launchpad.net/percona-toolkit>.
Please report bugs at L<https://jira.percona.com/projects/PT>.
Include the following information in your bug report:
=over

View File

@@ -55,7 +55,7 @@ BEGIN {
{
package Percona::Toolkit;
our $VERSION = '3.0.12';
our $VERSION = '3.0.13-dev';
use strict;
use warnings FATAL => 'all';
@@ -12926,7 +12926,7 @@ installed in any reasonably new version of Perl.
For a list of known bugs, see L<http://www.percona.com/bugs/pt-table-sync>.
Please report bugs at L<https://bugs.launchpad.net/percona-toolkit>.
Please report bugs at L<https://jira.percona.com/projects/PT>.
Include the following information in your bug report:
=over

View File

@@ -8416,7 +8416,7 @@ installed in any reasonably new version of Perl.
For a list of known bugs, see L<http://www.percona.com/bugs/pt-table-usage>.
Please report bugs at L<https://bugs.launchpad.net/percona-toolkit>.
Please report bugs at L<https://jira.percona.com/projects/PT>.
Include the following information in your bug report:
=over

View File

@@ -61,7 +61,7 @@ BEGIN {
{
package Percona::Toolkit;
our $VERSION = '3.0.12';
our $VERSION = '3.0.13-dev';
use strict;
use warnings FATAL => 'all';
@@ -6930,7 +6930,7 @@ sub new {
my $genlog_line_1= qr{
\A
(?:(\d{6}\s+\d{1,2}:\d\d:\d\d|\d{4}-\d{1,2}-\d{1,2}T\d\d:\d\d:\d\d\.\d+(?:Z|-?\d\d:\d\d)?))? # Timestamp
(?:(\d{6}\s+\d{1,2}:\d\d:\d\d|\d{4}-\d{1,2}-\d{1,2}T\d\d:\d\d:\d\d\.\d+(?:Z|[-+]?\d\d:\d\d)?))? # Timestamp
\s+
(?:\s*(\d+)) # Thread ID
\s
@@ -11348,7 +11348,7 @@ installed in any reasonably new version of Perl.
For a list of known bugs, see L<http://www.percona.com/bugs/pt-upgrade>.
Please report bugs at L<https://bugs.launchpad.net/percona-toolkit>.
Please report bugs at L<https://jira.percona.com/projects/PT>.
Include the following information in your bug report:
=over

View File

@@ -44,7 +44,7 @@ BEGIN {
{
package Percona::Toolkit;
our $VERSION = '3.0.12';
our $VERSION = '3.0.13-dev';
use strict;
use warnings FATAL => 'all';
@@ -6164,7 +6164,7 @@ installed in any reasonably new version of Perl.
For a list of known bugs, see L<http://www.percona.com/bugs/pt-variable-advisor>.
Please report bugs at L<https://bugs.launchpad.net/percona-toolkit>.
Please report bugs at L<https://jira.percona.com/projects/PT>.
Include the following information in your bug report:
=over

View File

@@ -3209,7 +3209,7 @@ installed in any reasonably new version of Perl.
For a list of known bugs, see L<http://www.percona.com/bugs/pt-visual-explain>.
Please report bugs at L<https://bugs.launchpad.net/percona-toolkit>.
Please report bugs at L<https://jira.percona.com/projects/PT>.
Include the following information in your bug report:
=over

View File

@@ -3,8 +3,7 @@ Fixed bugs
* :jirabug:`PT-1611`: ``pt-archiver`` failed to output UTF-8 characters.
* :jirabug:`PT-1574`: ``pt-online-schema-change`` failed on tables with a nullable unique key and a row with NULL values.
* :jirabug:`PT-1572`: ENUM fields usage in keys was improved, resulting in higher speed for expressions with sorted ENUM items.
* :jirabug:`PT-1422`: ``pt-mysql-summary`` could hung up in case of NULL values in a processlist Time column
* :jirabug:`PT-1422`: ``pt-mysql-summary`` could hang when NULL values appear in the processlist Time column.
Documentation changes
* :jirabug:`PT-1321`: The required MySQL privileges were detailed in `pt-online-schema-change`` documentation

View File

@@ -43,7 +43,7 @@ sub new {
my $genlog_line_1= qr{
\A
(?:(\d{6}\s+\d{1,2}:\d\d:\d\d|\d{4}-\d{1,2}-\d{1,2}T\d\d:\d\d:\d\d\.\d+(?:Z|-?\d\d:\d\d)?))? # Timestamp
(?:(\d{6}\s+\d{1,2}:\d\d:\d\d|\d{4}-\d{1,2}-\d{1,2}T\d\d:\d\d:\d\d\.\d+(?:Z|[-+]?\d\d:\d\d)?))? # Timestamp
\s+
(?:\s*(\d+)) # Thread ID
\s

View File

@@ -18,7 +18,7 @@
# ###########################################################################
package Percona::Toolkit;
our $VERSION = '3.0.12';
our $VERSION = '3.0.13-dev';
use strict;
use warnings FATAL => 'all';

View File

@@ -91,6 +91,9 @@ sub wait {
. " seconds on $dsn_name. Waiting.\n";
}
else {
if ($self->{fail_on_stopped_replication}) {
die 'replication is stopped';
}
print STDERR "Replica $dsn_name is stopped. Waiting.\n";
}
return;
@@ -103,6 +106,9 @@ sub wait {
$pr_first_report = sub {
my $dsn_name = $worst->{cxn}->name();
if ( !defined $worst->{lag} ) {
if ($self->{fail_on_stopped_replication}) {
die 'replication is stopped';
}
print STDERR "Replica $dsn_name is stopped. Waiting.\n";
}
return;

View File

@@ -67,6 +67,7 @@ my %port_for = (
chan_master1 => 2900,
chan_master2 => 2901,
chan_slave1 => 2902,
chan_slave2 => 2903,
);
my %server_type = (

View File

@@ -153,14 +153,16 @@ sub version_check {
return;
}
PTDEBUG && _d('Using', $protocol);
my $url = $args{url} # testing
|| $ENV{PERCONA_VERSION_CHECK_URL} # testing
|| "$protocol://v.percona.com";
PTDEBUG && _d('API URL:', $url);
# Get list of programs to check from Percona.
my $advice = pingback(
instances => $instances_to_check,
protocol => $protocol,
url => $args{url} # testing
|| $ENV{PERCONA_VERSION_CHECK_URL} # testing
|| "$protocol://v.percona.com",
url => $url,
);
if ( $advice ) {
PTDEBUG && _d('Advice:', Dumper($advice));
@@ -342,9 +344,14 @@ sub get_uuid {
my $filename = $ENV{"HOME"} . $uuid_file;
my $uuid = _generate_uuid();
open(my $fh, '>', $filename) or die "Could not open file '$filename' $!";
print $fh $uuid;
close $fh;
my $fh;
eval {
open($fh, '>', $filename);
};
if (!$EVAL_ERROR) {
print $fh $uuid;
close $fh;
}
return $uuid;
}
@@ -434,8 +441,9 @@ sub pingback {
general_id => get_uuid(),
);
my $tool_name = $ENV{XTRABACKUP_VERSION} ? "Percona XtraBackup" : File::Basename::basename($0);
my $client_response = {
headers => { "X-Percona-Toolkit-Tool" => File::Basename::basename($0) },
headers => { "X-Percona-Toolkit-Tool" => $tool_name },
content => $client_content,
};
PTDEBUG && _d('Client response:', Dumper($client_response));
@@ -528,6 +536,7 @@ my %sub_for_type = (
perl_version => \&get_perl_version,
perl_module_version => \&get_perl_module_version,
mysql_variable => \&get_mysql_variable,
xtrabackup => \&get_xtrabackup_version,
);
sub valid_item {
@@ -659,6 +668,10 @@ sub get_perl_version {
return $version;
}
sub get_xtrabackup_version {
return $ENV{XTRABACKUP_VERSION};
}
sub get_perl_module_version {
my (%args) = @_;
my $item = $args{item};

Binary file not shown.

View File

@@ -10,7 +10,7 @@ GOPATH ?=${HOME}/go
MAKE_TARS = ''
CUR_DIR=$(shell pwd)
BIN_DIR=${CUR_DIR}/build
SOURCES=collect encryptor pt-secure-data
SOURCES=collect encryptor pt-secure-collect
LDFLAGS="-X main.Version=${VERSION} -X main.Build=${BUILD} -X main.Commit=${COMMIT} -X main.Branch=${BRANCH} -X main.GoVersion=${GOVERSION} -s -w"
ifeq (${GOPATH},)
@@ -22,7 +22,7 @@ $(error Invalid GOPATH. There is no src dir in the GOPATH)
endif
ifeq ($(findstring ${GOPATH},${CUR_DIR}), )
$(error Wrong directorry for the project. It must be in $GOPATH/github/Percona-Lab/pt-secure-data)
$(error Wrong directorry for the project. It must be in $GOPATH/github/Percona-Lab/pt-secure-collect)
endif
$(info )
@@ -37,7 +37,7 @@ default: prepare
@rm -f ${BIN_DIR}/collect_*.tar.gz
@echo
@$(info Building in ${BIN_DIR})
@go build -ldflags ${LDFLAGS} -o ${BIN_DIR}/pt-secure-data *.go
@go build -ldflags ${LDFLAGS} -o ${BIN_DIR}/pt-secure-collect *.go
prepare:
@$(info Checking if ${BIN_DIR} exists)
@@ -47,31 +47,31 @@ all: clean darwin-amd64-tar linux-amd64-tar windows-amd64-tar
clean: prepare
@$(info Cleaning binaries and tar.gz files in dir ${BIN_DIR})
@rm -f ${BIN_DIR}/pt-secure-data
@rm -f ${BIN_DIR}/pt-secure-data.exe
@rm -f ${BIN_DIR}/pt-secure-data_*.tar.gz
@rm -f ${BIN_DIR}/pt-secure-collect
@rm -f ${BIN_DIR}/pt-secure-collect.exe
@rm -f ${BIN_DIR}/pt-secure-collect_*.tar.gz
linux-amd64: prepare
@echo "Building linux/amd64 binaries in ${BIN_DIR}"
@GOOS=linux GOARCH=amd64 go build -ldflags ${LDFLAGS} -o ${BIN_DIR}/pt-secure-data *.go
@GOOS=linux GOARCH=amd64 go build -ldflags ${LDFLAGS} -o ${BIN_DIR}/pt-secure-collect *.go
linux-amd64-tar: linux-amd64
@tar cvzf ${BIN_DIR}/pt-secure-data_linux_amd64.tar.gz -C ${BIN_DIR} pt-secure-data
@tar cvzf ${BIN_DIR}/pt-secure-collect_linux_amd64.tar.gz -C ${BIN_DIR} pt-secure-collect
darwin-amd64:
@echo "Building darwin/amd64 binaries in ${BIN_DIR}"
@mkdir -p ${BIN_DIR}
@GOOS=darwin GOARCH=amd64 go build -ldflags ${LDFLAGS} -o ${BIN_DIR}/pt-secure-data *.go
@GOOS=darwin GOARCH=amd64 go build -ldflags ${LDFLAGS} -o ${BIN_DIR}/pt-secure-collect *.go
darwin-amd64-tar: darwin-amd64
@tar cvzf ${BIN_DIR}/pt-secure-data_darwin_amd64.tar.gz -C ${BIN_DIR} pt-secure-data
@tar cvzf ${BIN_DIR}/pt-secure-collect_darwin_amd64.tar.gz -C ${BIN_DIR} pt-secure-collect
windows-amd64: prepare
@echo "Building windows/amd64 binaries in ${BIN_DIR}"
@GOOS=windows GOARCH=amd64 go build -ldflags ${LDFLAGS} -o ${BIN_DIR}/pt-secure-data.exe *.go
@GOOS=windows GOARCH=amd64 go build -ldflags ${LDFLAGS} -o ${BIN_DIR}/pt-secure-collect.exe *.go
windows-amd64-tar: windows-amd64
@tar cvzf ${BIN_DIR}/pt-secure-data_windows_amd64.tar.gz -C ${BIN_DIR} pt-secure-data.exe
@tar cvzf ${BIN_DIR}/pt-secure-collect_windows_amd64.tar.gz -C ${BIN_DIR} pt-secure-collect.exe
style:
@echo ">> checking code style"

View File

@@ -9,7 +9,7 @@ Internal variables placeholders will be replaced with the corresponding flag va
Usage:
```
pt-secure-data [<flags>] <command> [<args> ...]
pt-secure-collect [<flags>] <command> [<args> ...]
```

View File

@@ -67,6 +67,8 @@ type myDefaults struct {
}
const (
TOOLNAME = "pt-secure-collect"
decryptCmd = "decrypt"
encryptCmd = "encrypt"
collectCmd = "collect"
@@ -81,6 +83,10 @@ var (
"pt-summary",
"pt-mysql-summary --host=$mysql-host --port=$mysql-port --user=$mysql-user --password=$mysql-pass",
}
Build string = "01-01-1980"
GoVersion string = "1.8"
Version string = "3.0.1"
)
func main() {
@@ -164,12 +170,15 @@ func processCliParams(baseTempPath string, usageWriter io.Writer) (*cliOptions,
}
msg += "\n "
app := kingpin.New("pt-secure-data", msg)
app := kingpin.New(TOOLNAME, msg)
if usageWriter != nil {
app.UsageWriter(usageWriter)
app.Terminate(nil)
}
// Add support for --version flag
app.Version(TOOLNAME + "\nVersion " + Version + "\nBuild: " + Build + " using " + GoVersion)
opts := &cliOptions{
CollectCommand: app.Command(collectCmd, "Collect, sanitize, pack and encrypt data from pt-tools."),
DecryptCommand: app.Command(decryptCmd, "Decrypt an encrypted file. The password will be requested from the terminal."),

View File

@@ -270,6 +270,61 @@ test_log_parser(
],
);
# Customer issue from Ernie.
test_log_parser(
parser => $p,
file => $sample.'pt-1573-general-log-system.log',
oktorun => sub { $oktorun = $_[0]; },
result => [
{
Query_time => 0,
Thread_id => '257426',
arg => 'administrator command: Connect',
bytes => 30,
cmd => 'Admin',
host => '127.0.0.1',
pos_in_log => 0,
ts => '2018-09-07T18:45:40.098124+08:00',
user => 'mysqlha_common'
},
{
Query_time => 0,
Thread_id => '257426',
arg => 'set autocommit=0',
bytes => 16,
cmd => 'Query',
pos_in_log => 285,
ts => '2018-09-07T18:45:40.098511+08:00'
},
{
Query_time => 0,
Thread_id => '257426',
arg => 'set autocommit=1',
bytes => 16,
cmd => 'Query',
pos_in_log => 411,
ts => '2018-09-07T18:45:40.098613+08:00'
},
{
Query_time => 0,
Thread_id => '257426',
arg => 'show global status like \'Threads_connected\'',
bytes => 43,
cmd => 'Query',
pos_in_log => 501,
ts => '2018-09-07T18:45:40.098769+08:00'
},
{
Query_time => 0,
Thread_id => '257426',
arg => 'administrator command: Quit',
bytes => 27,
cmd => 'Admin',
pos_in_log => 547,
ts => '2018-09-07T18:45:40.101009+08:00'
}
],
);
# #############################################################################
# Done.
# #############################################################################

View File

@@ -0,0 +1,8 @@
/usr/local/mysql-5.7.21/bin/mysqld, Version: 5.7.21-log (MySQL Community Server (GPL)). started with:
Tcp port: 5721 Unix socket: /tmp/mysql5721.sock
Time Id Command Argument
2018-09-07T18:45:40.098124+08:00 257426 Connect mysqlha_common@127.0.0.1 on using TCP/IP
2018-09-07T18:45:40.098511+08:00 257426 Query set autocommit=0
2018-09-07T18:45:40.098613+08:00 257426 Query set autocommit=1
2018-09-07T18:45:40.098769+08:00 257426 Query show global status like 'Threads_connected'
2018-09-07T18:45:40.101009+08:00 257426 Quit

View File

@@ -0,0 +1,113 @@
#!/usr/bin/env perl
BEGIN {
die "The PERCONA_TOOLKIT_BRANCH environment variable is not set.\n"
unless $ENV{PERCONA_TOOLKIT_BRANCH} && -d $ENV{PERCONA_TOOLKIT_BRANCH};
unshift @INC, "$ENV{PERCONA_TOOLKIT_BRANCH}/lib";
};
use strict;
use warnings FATAL => 'all';
use English qw(-no_match_vars);
use Test::More;
use PerconaTest;
use Sandbox;
require "$trunk/bin/pt-archiver";
my $dp = new DSNParser(opts=>$dsn_opts);
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
my $master_dbh = $sb->get_dbh_for('master');
my $slave_dbh = $sb->get_dbh_for('slave1');
if ( !$master_dbh ) {
plan skip_all => 'Cannot connect to sandbox master';
}
elsif ( !$slave_dbh ) {
plan skip_all => 'Cannot connect to sandbox slave';
} elsif ($sandbox_version lt '5.7') {
plan skip_all => 'Only on MySQL 5.7+';
} else {
plan tests => 5;
}
my ($master1_dbh, $master1_dsn) = $sb->start_sandbox(
server => 'chan_master1',
type => 'master',
);
my ($master2_dbh, $master2_dsn) = $sb->start_sandbox(
server => 'chan_master2',
type => 'master',
);
my ($slave1_dbh, $slave1_dsn) = $sb->start_sandbox(
server => 'chan_slave1',
type => 'master',
);
my $slave1_port = $sb->port_for('chan_slave1');
$sb->load_file('chan_master1', "sandbox/gtid_on.sql", undef, no_wait => 1);
$sb->load_file('chan_master2', "sandbox/gtid_on.sql", undef, no_wait => 1);
$sb->load_file('chan_slave1', "sandbox/slave_channels.sql", undef, no_wait => 1);
my $master1_port = $sb->port_for('chan_master1');
my $num_rows = 40000;
# Load some rows into masters 1 & 2.
$sb->load_file('chan_master1', "t/pt-archiver/samples/channels.sql", undef, no_wait => 1);
diag("Loading $num_rows into the test.t1 table on first master. This might take some time.");
diag(`util/mysql_random_data_load --host=127.0.0.1 --port=$master1_port --user=msandbox --password=msandbox test t1 $num_rows`);
diag("$num_rows rows loaded. Starting tests.");
$master_dbh->do("FLUSH TABLES");
my $rows = $master1_dbh->selectrow_arrayref('SELECT COUNT(*) FROM test.t1 ');
is(
@$rows[0],
$num_rows,
"All rows were loaded into master 1",
);
my @args = ('--source', $master1_dsn.',D=test,t=t1', '--purge', '--where', sprintf('id >= %d', $num_rows / 2), '--check-slave-lag', $slave1_dsn);
my ($exit_status, $output);
$output = output(
sub { $exit_status = pt_archiver::main(@args) },
stderr => 1,
);
isnt(
$exit_status,
0,
'Must specify a channel name',
);
like (
$output,
qr/"channel" was not specified/,
'Message saying channel name must be specified'
);
push @args, ('--channel', 'masterchan1');
output(
sub { $exit_status = pt_archiver::main(@args, '--channel', 'masterchan1') },
stderr => 1,
);
is(
$exit_status,
0,
'Ok if channel name was specified',
);
$sb->stop_sandbox(qw(chan_master1 chan_master2 chan_slave1));
# #############################################################################
# Done.
# #############################################################################
$sb->wipe_clean($master_dbh);
ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox");
exit;

View File

@@ -0,0 +1,6 @@
DROP DATABASE IF EXISTS test;
CREATE DATABASE test;
CREATE TABLE test.t1 (
id INT PRIMARY KEY AUTO_INCREMENT,
f2 VARCHAR(25)
) Engine=InnoDB;

View File

@@ -0,0 +1,105 @@
#!/usr/bin/env perl
BEGIN {
die "The PERCONA_TOOLKIT_BRANCH environment variable is not set.\n"
unless $ENV{PERCONA_TOOLKIT_BRANCH} && -d $ENV{PERCONA_TOOLKIT_BRANCH};
unshift @INC, "$ENV{PERCONA_TOOLKIT_BRANCH}/lib";
};
use strict;
use warnings FATAL => 'all';
use English qw(-no_match_vars);
use Test::More;
use PerconaTest;
use Sandbox;
use SqlModes;
require "$trunk/bin/pt-table-checksum";
my $dp = new DSNParser(opts=>$dsn_opts);
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
my $dbh = $sb->get_dbh_for('master');
if ( !$dbh ) {
plan skip_all => 'Cannot connect to sandbox master';
}
else {
plan tests => 4;
}
diag("loading samples");
$sb->load_file('master', 't/pt-table-checksum/samples/pt-1616.sql');
my $num_rows = 50000;
diag("Loading $num_rows rows into the table. This might take some time.");
# diag(`util/mysql_random_data_load --host=127.0.0.1 --port=12345 --user=msandbox --password=msandbox junk pt_test_100 $num_rows`);
my $sql = "INSERT INTO junk.pt_test_100 (id1, id2) VALUES (?, ?)";
my $sth = $dbh->prepare($sql);
my @chars = ("A".."Z", "a".."z");
# Generate some random data haivng commas
for (my $i=0; $i < $num_rows; $i++) {
# Generate random strings having commas
my ($id1, $id2) = (",,,,", ",,,,");
$id1 .= $chars[rand @chars] for 1..10;
$id2 .= $chars[rand @chars] for 1..10;
$sth->execute($id1, $id2);
}
$sth->finish();
$dbh->do('INSERT INTO junk.pt_test_100 (id1, id2) VALUES(UNHEX("F96DD7"), UNHEX("F96DD7"))');
# The sandbox servers run with lock_wait_timeout=3 and it's not dynamic
# so we need to specify --set-vars innodb_lock_wait_timeout=3 else the tool will die.
my $master_dsn = $sb->dsn_for('master');
my @args = ($master_dsn, "--set-vars", "innodb_lock_wait_timeout=50",
"--ignore-databases", "mysql", "--no-check-binlog-format",
"--chunk-size", "1",
"--empty-replicate-table", "--run-time", "2s"
);
my $output;
my $exit_status;
$output = output(
sub { $exit_status = pt_table_checksum::main(@args) },
stderr => 1,
);
is(
$exit_status,
0,
"PT-1616 pt-table-cheksum before --resume with binary fields exit status",
);
@args = ("--set-vars", "innodb_lock_wait_timeout=50",
"--ignore-databases", "mysql", "--no-check-binlog-format",
"--chunk-size", "1",
"--resume", "--run-time", "5s", $master_dsn
);
$output = output(
sub { $exit_status = pt_table_checksum::main(@args) },
stderr => 1,
);
is(
$exit_status,
0,
"PT-1616 pt-table-cheksum --resume with binary fields exit status",
);
unlike(
$output,
qr/called with \d+ bind variables when \d+ are needed/,
"PT-1616 pt-table-cheksum --resume parameters binding error",
) or die($output);
# #############################################################################
# Done.
# #############################################################################
$sb->wipe_clean($dbh);
ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox");
exit;

View File

@@ -0,0 +1,90 @@
#!/usr/bin/env perl
BEGIN {
die "The PERCONA_TOOLKIT_BRANCH environment variable is not set.\n"
unless $ENV{PERCONA_TOOLKIT_BRANCH} && -d $ENV{PERCONA_TOOLKIT_BRANCH};
unshift @INC, "$ENV{PERCONA_TOOLKIT_BRANCH}/lib";
};
use strict;
use warnings FATAL => 'all';
use English qw(-no_match_vars);
use Test::More;
use PerconaTest;
use Sandbox;
use SqlModes;
require "$trunk/bin/pt-table-checksum";
my $dp = new DSNParser(opts=>$dsn_opts);
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
diag ('Starting second sandbox master');
my ($master1_dbh, $master1_dsn) = $sb->start_sandbox(
server => 'chan_master1',
type => 'master',
);
diag ('Starting second sandbox slave 1');
my ($slave1_dbh, $slave1_dsn) = $sb->start_sandbox(
server => 'chan_slave1',
type => 'slave',
master => 'chan_master1',
);
diag ('Starting second sandbox slave 2');
my ($slave2_dbh, $slave2_dsn) = $sb->start_sandbox(
server => 'chan_slave2',
type => 'slave',
master => 'chan_master1',
);
my $dbh = $sb->get_dbh_for('master');
if ( !$dbh ) {
plan skip_all => 'Cannot connect to sandbox master';
}
else {
plan tests => 2;
}
diag("loading samples");
$sb->load_file('chan_master1', 't/pt-table-checksum/samples/pt-1637.sql');
my @args = ($master1_dsn,
"--set-vars", "innodb_lock_wait_timeout=50",
"--ignore-databases", "mysql", "--no-check-binlog-format",
"--recursion-method", "dsn=h=127.0.0.1,D=test,t=dsns",
"--run-time", "5", "--fail-on-stopped-replication",
);
# The sandbox servers run with lock_wait_timeout=3 and it's not dynamic
# so we need to specify --set-vars innodb_lock_wait_timeout=3 else the tool will die.
$sb->do_as_root("chan_slave1", 'stop slave IO_thread;');
my $output;
my $exit_status;
($output, $exit_status) = full_output(
sub { $exit_status = pt_table_checksum::main(@args) },
stderr => 1,
);
is(
$exit_status,
128,
"PT-1637 exist status 128 if replication is stopped and --fail-on-replication-stopped",
);
$sb->do_as_root("chan_slave1", 'start slave IO_thread;');
sleep(2);
$sb->stop_sandbox(qw(chan_master1 chan_slave2 chan_slave1));
# #############################################################################
# Done.
# #############################################################################
$sb->wipe_clean($dbh);
ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox");
exit;

View File

@@ -0,0 +1,30 @@
DROP DATABASE IF EXISTS junk;
CREATE DATABASE junk;
CREATE TABLE junk.pt_test_100 (
id1 binary(16),
id2 binary(16),
PRIMARY KEY(id1, id2)
);
CREATE DATABASE IF NOT EXISTS percona;
CREATE TABLE IF NOT EXISTS percona.checksums (
db CHAR(64) NOT NULL,
tbl CHAR(64) NOT NULL,
chunk INT NOT NULL,
chunk_time FLOAT NULL,
chunk_index VARCHAR(200) NULL,
lower_boundary TEXT NULL,
upper_boundary TEXT NULL,
this_crc CHAR(40) NOT NULL,
this_cnt INT NOT NULL,
master_crc CHAR(40) NULL,
master_cnt INT NULL,
ts TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (db, tbl, chunk),
INDEX ts_db_tbl (ts, db, tbl)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
TRUNCATE TABLE percona.checksums;
ALTER TABLE percona.checksums MODIFY upper_boundary BLOB, MODIFY lower_boundary BLOB;

View File

@@ -0,0 +1,37 @@
CREATE DATABASE IF NOT EXISTS `percona`;
CREATE TABLE `percona`.`checksums` (
db CHAR(64) NOT NULL,
tbl CHAR(64) NOT NULL,
chunk INT NOT NULL,
chunk_time FLOAT NULL,
chunk_index VARCHAR(200) NULL,
lower_boundary TEXT NULL,
upper_boundary TEXT NULL,
this_crc CHAR(40) NOT NULL,
this_cnt INT NOT NULL,
master_crc CHAR(40) NULL,
master_cnt INT NULL,
ts TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (db, tbl, chunk),
INDEX ts_db_tbl (ts, db, tbl)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE DATABASE IF NOT EXISTS test;
CREATE TABLE `test`.`dsns` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`parent_id` int(11) DEFAULT NULL,
`dsn` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
);
-- From Sandbox.pm
-- chan_master1 => 2900,
-- chan_master2 => 2901,
-- chan_slave1 => 2902,
-- chan_slave2 => 2903,
INSERT INTO `test`.`dsns` VALUES
(1, NULL, "h=127.0.0.1,P=2902,u=msandbox,p=msandbox"),
(2, NULL, "h=127.0.0.1,P=2903,u=msandbox,p=msandbox");

Binary file not shown.