mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-16 16:23:30 +00:00
Fix MasterSlave::get_slave_lag(). Revert pt-table-checksum to use old SchemaIterator. Remove pt-table-usage tests. Fix use of var from another package in pt-query-digest. Remove reference to $VERSION from pt-show-grants. Change mk- to pt- in pt-variable-advisor sample.
This commit is contained in:
@@ -12337,7 +12337,7 @@ sub main {
|
|||||||
# We need to figure out what interval we're in and what
|
# We need to figure out what interval we're in and what
|
||||||
# interval is next. So first we need to parse the ts.
|
# interval is next. So first we need to parse the ts.
|
||||||
if ( my($y, $m, $d, $h, $i, $s)
|
if ( my($y, $m, $d, $h, $i, $s)
|
||||||
= $args->{event}->{ts} =~ m/^$mysql_ts$/ ) {
|
= $args->{event}->{ts} =~ m/^$Transformers::mysql_ts$/ ) {
|
||||||
my $rt = $o->get('run-time');
|
my $rt = $o->get('run-time');
|
||||||
if ( $run_time_interval == 60 ) {
|
if ( $run_time_interval == 60 ) {
|
||||||
MKDEBUG && _d("Run-time interval in seconds");
|
MKDEBUG && _d("Run-time interval in seconds");
|
||||||
|
@@ -1665,7 +1665,7 @@ sub main {
|
|||||||
|
|
||||||
my ( $version, $ts ) = $dbh->selectrow_array("SELECT VERSION(), NOW()");
|
my ( $version, $ts ) = $dbh->selectrow_array("SELECT VERSION(), NOW()");
|
||||||
print join("\n",
|
print join("\n",
|
||||||
"-- Grants dumped by pt-show-grants $VERSION",
|
"-- Grants dumped by pt-show-grants",
|
||||||
"-- Dumped from server " . ($dbh->{mysql_hostinfo} || '')
|
"-- Dumped from server " . ($dbh->{mysql_hostinfo} || '')
|
||||||
. ($o->get('timestamp') ? ", MySQL $version at $ts" : ", MySQL $version"),
|
. ($o->get('timestamp') ? ", MySQL $version at $ts" : ", MySQL $version"),
|
||||||
), "\n" if $o->get('header');
|
), "\n" if $o->get('header');
|
||||||
|
@@ -9,26 +9,26 @@ use warnings FATAL => 'all';
|
|||||||
use constant MKDEBUG => $ENV{MKDEBUG} || 0;
|
use constant MKDEBUG => $ENV{MKDEBUG} || 0;
|
||||||
|
|
||||||
# ###########################################################################
|
# ###########################################################################
|
||||||
# TableParser package
|
# TableParser package 7156
|
||||||
# This package is a copy without comments from the original. The original
|
# This package is a copy without comments from the original. The original
|
||||||
# with comments and its test file can be found in the Bazaar repository at,
|
# with comments and its test file can be found in the SVN repository at,
|
||||||
# lib/TableParser.pm
|
# trunk/common/TableParser.pm
|
||||||
# t/lib/TableParser.t
|
# trunk/common/t/TableParser.t
|
||||||
# See https://launchpad.net/percona-toolkit for more information.
|
# See http://code.google.com/p/maatkit/wiki/Developers for more information.
|
||||||
# ###########################################################################
|
# ###########################################################################
|
||||||
{
|
|
||||||
package TableParser;
|
package TableParser;
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings FATAL => 'all';
|
use warnings FATAL => 'all';
|
||||||
use English qw(-no_match_vars);
|
use English qw(-no_match_vars);
|
||||||
use constant MKDEBUG => $ENV{MKDEBUG} || 0;
|
|
||||||
|
|
||||||
use Data::Dumper;
|
use Data::Dumper;
|
||||||
$Data::Dumper::Indent = 1;
|
$Data::Dumper::Indent = 1;
|
||||||
$Data::Dumper::Sortkeys = 1;
|
$Data::Dumper::Sortkeys = 1;
|
||||||
$Data::Dumper::Quotekeys = 0;
|
$Data::Dumper::Quotekeys = 0;
|
||||||
|
|
||||||
|
use constant MKDEBUG => $ENV{MKDEBUG} || 0;
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
my ( $class, %args ) = @_;
|
my ( $class, %args ) = @_;
|
||||||
my @required_args = qw(Quoter);
|
my @required_args = qw(Quoter);
|
||||||
@@ -319,7 +319,6 @@ sub get_keys {
|
|||||||
|
|
||||||
sub get_fks {
|
sub get_fks {
|
||||||
my ( $self, $ddl, $opts ) = @_;
|
my ( $self, $ddl, $opts ) = @_;
|
||||||
my $q = $self->{Quoter};
|
|
||||||
my $fks = {};
|
my $fks = {};
|
||||||
|
|
||||||
foreach my $fk (
|
foreach my $fk (
|
||||||
@@ -329,22 +328,17 @@ sub get_fks {
|
|||||||
my ( $cols ) = $fk =~ m/FOREIGN KEY \(([^\)]+)\)/;
|
my ( $cols ) = $fk =~ m/FOREIGN KEY \(([^\)]+)\)/;
|
||||||
my ( $parent, $parent_cols ) = $fk =~ m/REFERENCES (\S+) \(([^\)]+)\)/;
|
my ( $parent, $parent_cols ) = $fk =~ m/REFERENCES (\S+) \(([^\)]+)\)/;
|
||||||
|
|
||||||
my ($db, $tbl) = $q->split_unquote($parent, $opts->{database});
|
|
||||||
my %parent_tbl = (tbl => $tbl);
|
|
||||||
$parent_tbl{db} = $db if $db;
|
|
||||||
|
|
||||||
if ( $parent !~ m/\./ && $opts->{database} ) {
|
if ( $parent !~ m/\./ && $opts->{database} ) {
|
||||||
$parent = $q->quote($opts->{database}) . ".$parent";
|
$parent = "`$opts->{database}`.$parent";
|
||||||
}
|
}
|
||||||
|
|
||||||
$fks->{$name} = {
|
$fks->{$name} = {
|
||||||
name => $name,
|
name => $name,
|
||||||
colnames => $cols,
|
colnames => $cols,
|
||||||
cols => [ map { s/[ `]+//g; $_; } split(',', $cols) ],
|
cols => [ map { s/[ `]+//g; $_; } split(',', $cols) ],
|
||||||
parent_tbl => \%parent_tbl,
|
parent_tbl => $parent,
|
||||||
parent_tblname => $parent,
|
|
||||||
parent_cols => [ map { s/[ `]+//g; $_; } split(',', $parent_cols) ],
|
|
||||||
parent_colnames=> $parent_cols,
|
parent_colnames=> $parent_cols,
|
||||||
|
parent_cols => [ map { s/[ `]+//g; $_; } split(',', $parent_cols) ],
|
||||||
ddl => $fk,
|
ddl => $fk,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -404,29 +398,28 @@ sub _d {
|
|||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
}
|
|
||||||
# ###########################################################################
|
# ###########################################################################
|
||||||
# End TableParser package
|
# End TableParser package
|
||||||
# ###########################################################################
|
# ###########################################################################
|
||||||
|
|
||||||
# ###########################################################################
|
# ###########################################################################
|
||||||
# TableChecksum package
|
# TableChecksum package 7080
|
||||||
# This package is a copy without comments from the original. The original
|
# This package is a copy without comments from the original. The original
|
||||||
# with comments and its test file can be found in the Bazaar repository at,
|
# with comments and its test file can be found in the SVN repository at,
|
||||||
# lib/TableChecksum.pm
|
# trunk/common/TableChecksum.pm
|
||||||
# t/lib/TableChecksum.t
|
# trunk/common/t/TableChecksum.t
|
||||||
# See https://launchpad.net/percona-toolkit for more information.
|
# See http://code.google.com/p/maatkit/wiki/Developers for more information.
|
||||||
# ###########################################################################
|
# ###########################################################################
|
||||||
{
|
|
||||||
package TableChecksum;
|
package TableChecksum;
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings FATAL => 'all';
|
use warnings FATAL => 'all';
|
||||||
use English qw(-no_match_vars);
|
use English qw(-no_match_vars);
|
||||||
use constant MKDEBUG => $ENV{MKDEBUG} || 0;
|
|
||||||
|
|
||||||
use List::Util qw(max);
|
use List::Util qw(max);
|
||||||
|
|
||||||
|
use constant MKDEBUG => $ENV{MKDEBUG} || 0;
|
||||||
|
|
||||||
our %ALGOS = (
|
our %ALGOS = (
|
||||||
CHECKSUM => { pref => 0, hash => 0 },
|
CHECKSUM => { pref => 0, hash => 0 },
|
||||||
BIT_XOR => { pref => 2, hash => 1 },
|
BIT_XOR => { pref => 2, hash => 1 },
|
||||||
@@ -787,28 +780,28 @@ sub _d {
|
|||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
}
|
|
||||||
# ###########################################################################
|
# ###########################################################################
|
||||||
# End TableChecksum package
|
# End TableChecksum package
|
||||||
# ###########################################################################
|
# ###########################################################################
|
||||||
|
|
||||||
# ###########################################################################
|
# ###########################################################################
|
||||||
# OptionParser package
|
# OptionParser package 7102
|
||||||
# This package is a copy without comments from the original. The original
|
# This package is a copy without comments from the original. The original
|
||||||
# with comments and its test file can be found in the Bazaar repository at,
|
# with comments and its test file can be found in the SVN repository at,
|
||||||
# lib/OptionParser.pm
|
# trunk/common/OptionParser.pm
|
||||||
# t/lib/OptionParser.t
|
# trunk/common/t/OptionParser.t
|
||||||
# See https://launchpad.net/percona-toolkit for more information.
|
# See http://code.google.com/p/maatkit/wiki/Developers for more information.
|
||||||
# ###########################################################################
|
# ###########################################################################
|
||||||
{
|
|
||||||
package OptionParser;
|
package OptionParser;
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings FATAL => 'all';
|
use warnings FATAL => 'all';
|
||||||
|
use List::Util qw(max);
|
||||||
use English qw(-no_match_vars);
|
use English qw(-no_match_vars);
|
||||||
use constant MKDEBUG => $ENV{MKDEBUG} || 0;
|
use constant MKDEBUG => $ENV{MKDEBUG} || 0;
|
||||||
|
|
||||||
use List::Util qw(max);
|
|
||||||
use Getopt::Long;
|
use Getopt::Long;
|
||||||
|
|
||||||
my $POD_link_re = '[LC]<"?([^">]+)"?>';
|
my $POD_link_re = '[LC]<"?([^">]+)"?>';
|
||||||
@@ -858,9 +851,9 @@ sub new {
|
|||||||
defaults_to => {}, # rule: opt defaults to value of other opt
|
defaults_to => {}, # rule: opt defaults to value of other opt
|
||||||
DSNParser => undef,
|
DSNParser => undef,
|
||||||
default_files => [
|
default_files => [
|
||||||
"/etc/percona-toolkit/percona-toolkit.conf",
|
"/etc/maatkit/maatkit.conf",
|
||||||
"/etc/percona-toolkit/$program_name.conf",
|
"/etc/maatkit/$program_name.conf",
|
||||||
"$home/.percona-toolkit.conf",
|
"$home/.maatkit.conf",
|
||||||
"$home/.$program_name.conf",
|
"$home/.$program_name.conf",
|
||||||
],
|
],
|
||||||
types => {
|
types => {
|
||||||
@@ -1808,20 +1801,20 @@ sub _d {
|
|||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
}
|
|
||||||
# ###########################################################################
|
# ###########################################################################
|
||||||
# End OptionParser package
|
# End OptionParser package
|
||||||
# ###########################################################################
|
# ###########################################################################
|
||||||
|
|
||||||
# ###########################################################################
|
# ###########################################################################
|
||||||
# DSNParser package
|
# DSNParser package 7388
|
||||||
# This package is a copy without comments from the original. The original
|
# This package is a copy without comments from the original. The original
|
||||||
# with comments and its test file can be found in the Bazaar repository at,
|
# with comments and its test file can be found in the SVN repository at,
|
||||||
# lib/DSNParser.pm
|
# trunk/common/DSNParser.pm
|
||||||
# t/lib/DSNParser.t
|
# trunk/common/t/DSNParser.t
|
||||||
# See https://launchpad.net/percona-toolkit for more information.
|
# See http://code.google.com/p/maatkit/wiki/Developers for more information.
|
||||||
# ###########################################################################
|
# ###########################################################################
|
||||||
{
|
|
||||||
package DSNParser;
|
package DSNParser;
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
@@ -1838,6 +1831,7 @@ eval {
|
|||||||
};
|
};
|
||||||
my $have_dbi = $EVAL_ERROR ? 0 : 1;
|
my $have_dbi = $EVAL_ERROR ? 0 : 1;
|
||||||
|
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
my ( $class, %args ) = @_;
|
my ( $class, %args ) = @_;
|
||||||
foreach my $arg ( qw(opts) ) {
|
foreach my $arg ( qw(opts) ) {
|
||||||
@@ -2034,8 +2028,8 @@ sub get_dbh {
|
|||||||
my $dbh;
|
my $dbh;
|
||||||
my $tries = 2;
|
my $tries = 2;
|
||||||
while ( !$dbh && $tries-- ) {
|
while ( !$dbh && $tries-- ) {
|
||||||
MKDEBUG && _d($cxn_string, ' ', $user, ' ', $pass,
|
MKDEBUG && _d($cxn_string, ' ', $user, ' ', $pass, ' {',
|
||||||
join(', ', map { "$_=>$defaults->{$_}" } keys %$defaults ));
|
join(', ', map { "$_=>$defaults->{$_}" } keys %$defaults ), '}');
|
||||||
|
|
||||||
eval {
|
eval {
|
||||||
$dbh = DBI->connect($cxn_string, $user, $pass, $defaults);
|
$dbh = DBI->connect($cxn_string, $user, $pass, $defaults);
|
||||||
@@ -2164,25 +2158,26 @@ sub _d {
|
|||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
}
|
|
||||||
# ###########################################################################
|
# ###########################################################################
|
||||||
# End DSNParser package
|
# End DSNParser package
|
||||||
# ###########################################################################
|
# ###########################################################################
|
||||||
|
|
||||||
# ###########################################################################
|
# ###########################################################################
|
||||||
# VersionParser package
|
# VersionParser package 6667
|
||||||
# This package is a copy without comments from the original. The original
|
# This package is a copy without comments from the original. The original
|
||||||
# with comments and its test file can be found in the Bazaar repository at,
|
# with comments and its test file can be found in the SVN repository at,
|
||||||
# lib/VersionParser.pm
|
# trunk/common/VersionParser.pm
|
||||||
# t/lib/VersionParser.t
|
# trunk/common/t/VersionParser.t
|
||||||
# See https://launchpad.net/percona-toolkit for more information.
|
# See http://code.google.com/p/maatkit/wiki/Developers for more information.
|
||||||
# ###########################################################################
|
# ###########################################################################
|
||||||
{
|
|
||||||
package VersionParser;
|
package VersionParser;
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings FATAL => 'all';
|
use warnings FATAL => 'all';
|
||||||
|
|
||||||
use English qw(-no_match_vars);
|
use English qw(-no_match_vars);
|
||||||
|
|
||||||
use constant MKDEBUG => $ENV{MKDEBUG} || 0;
|
use constant MKDEBUG => $ENV{MKDEBUG} || 0;
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
@@ -2247,25 +2242,26 @@ sub _d {
|
|||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
}
|
|
||||||
# ###########################################################################
|
# ###########################################################################
|
||||||
# End VersionParser package
|
# End VersionParser package
|
||||||
# ###########################################################################
|
# ###########################################################################
|
||||||
|
|
||||||
# ###########################################################################
|
# ###########################################################################
|
||||||
# MySQLDump package
|
# MySQLDump package 6345
|
||||||
# This package is a copy without comments from the original. The original
|
# This package is a copy without comments from the original. The original
|
||||||
# with comments and its test file can be found in the Bazaar repository at,
|
# with comments and its test file can be found in the SVN repository at,
|
||||||
# lib/MySQLDump.pm
|
# trunk/common/MySQLDump.pm
|
||||||
# t/lib/MySQLDump.t
|
# trunk/common/t/MySQLDump.t
|
||||||
# See https://launchpad.net/percona-toolkit for more information.
|
# See http://code.google.com/p/maatkit/wiki/Developers for more information.
|
||||||
# ###########################################################################
|
# ###########################################################################
|
||||||
{
|
|
||||||
package MySQLDump;
|
package MySQLDump;
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings FATAL => 'all';
|
use warnings FATAL => 'all';
|
||||||
|
|
||||||
use English qw(-no_match_vars);
|
use English qw(-no_match_vars);
|
||||||
|
|
||||||
use constant MKDEBUG => $ENV{MKDEBUG} || 0;
|
use constant MKDEBUG => $ENV{MKDEBUG} || 0;
|
||||||
|
|
||||||
( our $before = <<'EOF') =~ s/^ //gm;
|
( our $before = <<'EOF') =~ s/^ //gm;
|
||||||
@@ -2552,20 +2548,20 @@ sub _d {
|
|||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
}
|
|
||||||
# ###########################################################################
|
# ###########################################################################
|
||||||
# End MySQLDump package
|
# End MySQLDump package
|
||||||
# ###########################################################################
|
# ###########################################################################
|
||||||
|
|
||||||
# ###########################################################################
|
# ###########################################################################
|
||||||
# TableChunker package
|
# TableChunker package 7169
|
||||||
# This package is a copy without comments from the original. The original
|
# This package is a copy without comments from the original. The original
|
||||||
# with comments and its test file can be found in the Bazaar repository at,
|
# with comments and its test file can be found in the SVN repository at,
|
||||||
# lib/TableChunker.pm
|
# trunk/common/TableChunker.pm
|
||||||
# t/lib/TableChunker.t
|
# trunk/common/t/TableChunker.t
|
||||||
# See https://launchpad.net/percona-toolkit for more information.
|
# See http://code.google.com/p/maatkit/wiki/Developers for more information.
|
||||||
# ###########################################################################
|
# ###########################################################################
|
||||||
{
|
|
||||||
package TableChunker;
|
package TableChunker;
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
@@ -3485,25 +3481,26 @@ sub _d {
|
|||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
}
|
|
||||||
# ###########################################################################
|
# ###########################################################################
|
||||||
# End TableChunker package
|
# End TableChunker package
|
||||||
# ###########################################################################
|
# ###########################################################################
|
||||||
|
|
||||||
# ###########################################################################
|
# ###########################################################################
|
||||||
# Quoter package
|
# Quoter package 6850
|
||||||
# This package is a copy without comments from the original. The original
|
# This package is a copy without comments from the original. The original
|
||||||
# with comments and its test file can be found in the Bazaar repository at,
|
# with comments and its test file can be found in the SVN repository at,
|
||||||
# lib/Quoter.pm
|
# trunk/common/Quoter.pm
|
||||||
# t/lib/Quoter.t
|
# trunk/common/t/Quoter.t
|
||||||
# See https://launchpad.net/percona-toolkit for more information.
|
# See http://code.google.com/p/maatkit/wiki/Developers for more information.
|
||||||
# ###########################################################################
|
# ###########################################################################
|
||||||
{
|
|
||||||
package Quoter;
|
package Quoter;
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings FATAL => 'all';
|
use warnings FATAL => 'all';
|
||||||
use English qw(-no_match_vars);
|
use English qw(-no_match_vars);
|
||||||
|
|
||||||
use constant MKDEBUG => $ENV{MKDEBUG} || 0;
|
use constant MKDEBUG => $ENV{MKDEBUG} || 0;
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
@@ -3562,20 +3559,20 @@ sub join_quote {
|
|||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
}
|
|
||||||
# ###########################################################################
|
# ###########################################################################
|
||||||
# End Quoter package
|
# End Quoter package
|
||||||
# ###########################################################################
|
# ###########################################################################
|
||||||
|
|
||||||
# ###########################################################################
|
# ###########################################################################
|
||||||
# MasterSlave package
|
# MasterSlave package 7525
|
||||||
# This package is a copy without comments from the original. The original
|
# This package is a copy without comments from the original. The original
|
||||||
# with comments and its test file can be found in the Bazaar repository at,
|
# with comments and its test file can be found in the SVN repository at,
|
||||||
# lib/MasterSlave.pm
|
# trunk/common/MasterSlave.pm
|
||||||
# t/lib/MasterSlave.t
|
# trunk/common/t/MasterSlave.t
|
||||||
# See https://launchpad.net/percona-toolkit for more information.
|
# See http://code.google.com/p/maatkit/wiki/Developers for more information.
|
||||||
# ###########################################################################
|
# ###########################################################################
|
||||||
{
|
|
||||||
package MasterSlave;
|
package MasterSlave;
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
@@ -3583,6 +3580,11 @@ use warnings FATAL => 'all';
|
|||||||
use English qw(-no_match_vars);
|
use English qw(-no_match_vars);
|
||||||
use constant MKDEBUG => $ENV{MKDEBUG} || 0;
|
use constant MKDEBUG => $ENV{MKDEBUG} || 0;
|
||||||
|
|
||||||
|
use List::Util qw(min max);
|
||||||
|
use Data::Dumper;
|
||||||
|
$Data::Dumper::Quotekeys = 0;
|
||||||
|
$Data::Dumper::Indent = 0;
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
my ( $class, %args ) = @_;
|
my ( $class, %args ) = @_;
|
||||||
my $self = {
|
my $self = {
|
||||||
@@ -3848,7 +3850,7 @@ sub get_master_status {
|
|||||||
MKDEBUG && _d($dbh, 'SHOW MASTER STATUS');
|
MKDEBUG && _d($dbh, 'SHOW MASTER STATUS');
|
||||||
$sth->execute();
|
$sth->execute();
|
||||||
my ($ms) = @{$sth->fetchall_arrayref({})};
|
my ($ms) = @{$sth->fetchall_arrayref({})};
|
||||||
MKDEBUG && _d(@$ms);
|
MKDEBUG && _d(Dumper($ms));
|
||||||
|
|
||||||
if ( !$ms || scalar keys %$ms < 2 ) {
|
if ( !$ms || scalar keys %$ms < 2 ) {
|
||||||
MKDEBUG && _d('Server on dbh', $dbh, 'does not seem to be a master');
|
MKDEBUG && _d('Server on dbh', $dbh, 'does not seem to be a master');
|
||||||
@@ -3991,6 +3993,168 @@ sub catchup_to_same_pos {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub change_master_to {
|
||||||
|
my ( $self, $dbh, $master_dsn, $master_pos ) = @_;
|
||||||
|
$self->stop_slave($dbh);
|
||||||
|
MKDEBUG && _d(Dumper($master_dsn), Dumper($master_pos));
|
||||||
|
my $sql = "CHANGE MASTER TO MASTER_HOST='$master_dsn->{h}', "
|
||||||
|
. "MASTER_PORT= $master_dsn->{P}, MASTER_LOG_FILE='$master_pos->{file}', "
|
||||||
|
. "MASTER_LOG_POS=$master_pos->{position}";
|
||||||
|
MKDEBUG && _d($dbh, $sql);
|
||||||
|
$dbh->do($sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
sub make_sibling_of_master {
|
||||||
|
my ( $self, $slave_dbh, $slave_dsn, $dsn_parser, $timeout) = @_;
|
||||||
|
|
||||||
|
my $master_dsn = $self->get_master_dsn($slave_dbh, $slave_dsn, $dsn_parser)
|
||||||
|
or die "This server is not a slave";
|
||||||
|
my $master_dbh = $dsn_parser->get_dbh(
|
||||||
|
$dsn_parser->get_cxn_params($master_dsn), { AutoCommit => 1 });
|
||||||
|
my $gmaster_dsn
|
||||||
|
= $self->get_master_dsn($master_dbh, $master_dsn, $dsn_parser)
|
||||||
|
or die "This server's master is not a slave";
|
||||||
|
my $gmaster_dbh = $dsn_parser->get_dbh(
|
||||||
|
$dsn_parser->get_cxn_params($gmaster_dsn), { AutoCommit => 1 });
|
||||||
|
if ( $self->short_host($slave_dsn) eq $self->short_host($gmaster_dsn) ) {
|
||||||
|
die "The slave's master's master is the slave: master-master replication";
|
||||||
|
}
|
||||||
|
|
||||||
|
$self->stop_slave($master_dbh);
|
||||||
|
$self->catchup_to_master($slave_dbh, $master_dbh, $timeout);
|
||||||
|
$self->stop_slave($slave_dbh);
|
||||||
|
|
||||||
|
my $master_status = $self->get_master_status($master_dbh);
|
||||||
|
my $mslave_status = $self->get_slave_status($master_dbh);
|
||||||
|
my $slave_status = $self->get_slave_status($slave_dbh);
|
||||||
|
my $master_pos = $self->repl_posn($master_status);
|
||||||
|
my $slave_pos = $self->repl_posn($slave_status);
|
||||||
|
|
||||||
|
if ( !$self->slave_is_running($mslave_status)
|
||||||
|
&& !$self->slave_is_running($slave_status)
|
||||||
|
&& $self->pos_cmp($master_pos, $slave_pos) == 0)
|
||||||
|
{
|
||||||
|
$self->change_master_to($slave_dbh, $gmaster_dsn,
|
||||||
|
$self->repl_posn($mslave_status)); # Note it's not $master_pos!
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
die "The servers aren't both stopped at the same position";
|
||||||
|
}
|
||||||
|
|
||||||
|
$mslave_status = $self->get_slave_status($master_dbh);
|
||||||
|
$slave_status = $self->get_slave_status($slave_dbh);
|
||||||
|
my $mslave_pos = $self->repl_posn($mslave_status);
|
||||||
|
$slave_pos = $self->repl_posn($slave_status);
|
||||||
|
if ( $self->short_host($mslave_status) ne $self->short_host($slave_status)
|
||||||
|
|| $self->pos_cmp($mslave_pos, $slave_pos) != 0)
|
||||||
|
{
|
||||||
|
die "The servers don't have the same master/position after the change";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sub make_slave_of_sibling {
|
||||||
|
my ( $self, $slave_dbh, $slave_dsn, $sib_dbh, $sib_dsn,
|
||||||
|
$dsn_parser, $timeout) = @_;
|
||||||
|
|
||||||
|
if ( $self->short_host($slave_dsn) eq $self->short_host($sib_dsn) ) {
|
||||||
|
die "You are trying to make the slave a slave of itself";
|
||||||
|
}
|
||||||
|
|
||||||
|
my $master_dsn1 = $self->get_master_dsn($slave_dbh, $slave_dsn, $dsn_parser)
|
||||||
|
or die "This server is not a slave";
|
||||||
|
my $master_dbh1 = $dsn_parser->get_dbh(
|
||||||
|
$dsn_parser->get_cxn_params($master_dsn1), { AutoCommit => 1 });
|
||||||
|
my $master_dsn2 = $self->get_master_dsn($slave_dbh, $slave_dsn, $dsn_parser)
|
||||||
|
or die "The sibling is not a slave";
|
||||||
|
if ( $self->short_host($master_dsn1) ne $self->short_host($master_dsn2) ) {
|
||||||
|
die "This server isn't a sibling of the slave";
|
||||||
|
}
|
||||||
|
my $sib_master_stat = $self->get_master_status($sib_dbh)
|
||||||
|
or die "Binary logging is not enabled on the sibling";
|
||||||
|
die "The log_slave_updates option is not enabled on the sibling"
|
||||||
|
unless $self->has_slave_updates($sib_dbh);
|
||||||
|
|
||||||
|
$self->catchup_to_same_pos($slave_dbh, $sib_dbh);
|
||||||
|
|
||||||
|
$sib_master_stat = $self->get_master_status($sib_dbh);
|
||||||
|
$self->change_master_to($slave_dbh, $sib_dsn,
|
||||||
|
$self->repl_posn($sib_master_stat));
|
||||||
|
|
||||||
|
my $slave_status = $self->get_slave_status($slave_dbh);
|
||||||
|
my $slave_pos = $self->repl_posn($slave_status);
|
||||||
|
$sib_master_stat = $self->get_master_status($sib_dbh);
|
||||||
|
if ( $self->short_host($slave_status) ne $self->short_host($sib_dsn)
|
||||||
|
|| $self->pos_cmp($self->repl_posn($sib_master_stat), $slave_pos) != 0)
|
||||||
|
{
|
||||||
|
die "After changing the slave's master, it isn't a slave of the sibling, "
|
||||||
|
. "or it has a different replication position than the sibling";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sub make_slave_of_uncle {
|
||||||
|
my ( $self, $slave_dbh, $slave_dsn, $unc_dbh, $unc_dsn,
|
||||||
|
$dsn_parser, $timeout) = @_;
|
||||||
|
|
||||||
|
if ( $self->short_host($slave_dsn) eq $self->short_host($unc_dsn) ) {
|
||||||
|
die "You are trying to make the slave a slave of itself";
|
||||||
|
}
|
||||||
|
|
||||||
|
my $master_dsn = $self->get_master_dsn($slave_dbh, $slave_dsn, $dsn_parser)
|
||||||
|
or die "This server is not a slave";
|
||||||
|
my $master_dbh = $dsn_parser->get_dbh(
|
||||||
|
$dsn_parser->get_cxn_params($master_dsn), { AutoCommit => 1 });
|
||||||
|
my $gmaster_dsn
|
||||||
|
= $self->get_master_dsn($master_dbh, $master_dsn, $dsn_parser)
|
||||||
|
or die "The master is not a slave";
|
||||||
|
my $unc_master_dsn
|
||||||
|
= $self->get_master_dsn($unc_dbh, $unc_dsn, $dsn_parser)
|
||||||
|
or die "The uncle is not a slave";
|
||||||
|
if ($self->short_host($gmaster_dsn) ne $self->short_host($unc_master_dsn)) {
|
||||||
|
die "The uncle isn't really the slave's uncle";
|
||||||
|
}
|
||||||
|
|
||||||
|
my $unc_master_stat = $self->get_master_status($unc_dbh)
|
||||||
|
or die "Binary logging is not enabled on the uncle";
|
||||||
|
die "The log_slave_updates option is not enabled on the uncle"
|
||||||
|
unless $self->has_slave_updates($unc_dbh);
|
||||||
|
|
||||||
|
$self->catchup_to_same_pos($master_dbh, $unc_dbh);
|
||||||
|
$self->catchup_to_master($slave_dbh, $master_dbh, $timeout);
|
||||||
|
|
||||||
|
my $slave_status = $self->get_slave_status($slave_dbh);
|
||||||
|
my $master_status = $self->get_master_status($master_dbh);
|
||||||
|
if ( $self->pos_cmp(
|
||||||
|
$self->repl_posn($slave_status),
|
||||||
|
$self->repl_posn($master_status)) != 0 )
|
||||||
|
{
|
||||||
|
die "The slave is not caught up to its master";
|
||||||
|
}
|
||||||
|
|
||||||
|
$unc_master_stat = $self->get_master_status($unc_dbh);
|
||||||
|
$self->change_master_to($slave_dbh, $unc_dsn,
|
||||||
|
$self->repl_posn($unc_master_stat));
|
||||||
|
|
||||||
|
|
||||||
|
$slave_status = $self->get_slave_status($slave_dbh);
|
||||||
|
my $slave_pos = $self->repl_posn($slave_status);
|
||||||
|
if ( $self->short_host($slave_status) ne $self->short_host($unc_dsn)
|
||||||
|
|| $self->pos_cmp($self->repl_posn($unc_master_stat), $slave_pos) != 0)
|
||||||
|
{
|
||||||
|
die "After changing the slave's master, it isn't a slave of the uncle, "
|
||||||
|
. "or it has a different replication position than the uncle";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sub detach_slave {
|
||||||
|
my ( $self, $dbh ) = @_;
|
||||||
|
$self->stop_slave($dbh);
|
||||||
|
my $stat = $self->get_slave_status($dbh)
|
||||||
|
or die "This server is not a slave";
|
||||||
|
$dbh->do('CHANGE MASTER TO MASTER_HOST=""');
|
||||||
|
$dbh->do('RESET SLAVE'); # Wipes out master.info, etc etc
|
||||||
|
return $stat;
|
||||||
|
}
|
||||||
|
|
||||||
sub slave_is_running {
|
sub slave_is_running {
|
||||||
my ( $self, $slave_status ) = @_;
|
my ( $self, $slave_status ) = @_;
|
||||||
return ($slave_status->{slave_sql_running} || 'No') eq 'Yes';
|
return ($slave_status->{slave_sql_running} || 'No') eq 'Yes';
|
||||||
@@ -4174,28 +4338,29 @@ sub _d {
|
|||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
}
|
|
||||||
# ###########################################################################
|
# ###########################################################################
|
||||||
# End MasterSlave package
|
# End MasterSlave package
|
||||||
# ###########################################################################
|
# ###########################################################################
|
||||||
|
|
||||||
# ###########################################################################
|
# ###########################################################################
|
||||||
# Daemon package
|
# Daemon package 6255
|
||||||
# This package is a copy without comments from the original. The original
|
# This package is a copy without comments from the original. The original
|
||||||
# with comments and its test file can be found in the Bazaar repository at,
|
# with comments and its test file can be found in the SVN repository at,
|
||||||
# lib/Daemon.pm
|
# trunk/common/Daemon.pm
|
||||||
# t/lib/Daemon.t
|
# trunk/common/t/Daemon.t
|
||||||
# See https://launchpad.net/percona-toolkit for more information.
|
# See http://code.google.com/p/maatkit/wiki/Developers for more information.
|
||||||
# ###########################################################################
|
# ###########################################################################
|
||||||
{
|
|
||||||
package Daemon;
|
package Daemon;
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings FATAL => 'all';
|
use warnings FATAL => 'all';
|
||||||
use English qw(-no_match_vars);
|
|
||||||
use constant MKDEBUG => $ENV{MKDEBUG} || 0;
|
|
||||||
|
|
||||||
use POSIX qw(setsid);
|
use POSIX qw(setsid);
|
||||||
|
use English qw(-no_match_vars);
|
||||||
|
|
||||||
|
use constant MKDEBUG => $ENV{MKDEBUG} || 0;
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
my ( $class, %args ) = @_;
|
my ( $class, %args ) = @_;
|
||||||
@@ -4360,22 +4525,22 @@ sub _d {
|
|||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
}
|
|
||||||
# ###########################################################################
|
# ###########################################################################
|
||||||
# End Daemon package
|
# End Daemon package
|
||||||
# ###########################################################################
|
# ###########################################################################
|
||||||
|
|
||||||
# ###########################################################################
|
# ###########################################################################
|
||||||
# SchemaIterator package
|
# SchemaIterator package 7512
|
||||||
# This package is a copy without comments from the original. The original
|
# This package is a copy without comments from the original. The original
|
||||||
# with comments and its test file can be found in the Bazaar repository at,
|
# with comments and its test file can be found in the SVN repository at,
|
||||||
# lib/SchemaIterator.pm
|
# trunk/common/SchemaIterator.pm
|
||||||
# t/lib/SchemaIterator.t
|
# trunk/common/t/SchemaIterator.t
|
||||||
# See https://launchpad.net/percona-toolkit for more information.
|
# See http://code.google.com/p/maatkit/wiki/Developers for more information.
|
||||||
# ###########################################################################
|
# ###########################################################################
|
||||||
{
|
|
||||||
package SchemaIterator;
|
package SchemaIterator;
|
||||||
|
|
||||||
|
{ # package scope
|
||||||
use strict;
|
use strict;
|
||||||
use warnings FATAL => 'all';
|
use warnings FATAL => 'all';
|
||||||
use English qw(-no_match_vars);
|
use English qw(-no_match_vars);
|
||||||
@@ -4472,29 +4637,16 @@ sub _make_filters {
|
|||||||
sub next_schema_object {
|
sub next_schema_object {
|
||||||
my ( $self ) = @_;
|
my ( $self ) = @_;
|
||||||
|
|
||||||
my $schema_obj;
|
my %schema_object;
|
||||||
if ( $self->{file_itr} ) {
|
if ( $self->{file_itr} ) {
|
||||||
$schema_obj= $self->_iterate_files();
|
%schema_object = $self->_iterate_files();
|
||||||
}
|
}
|
||||||
else { # dbh
|
else { # dbh
|
||||||
$schema_obj= $self->_iterate_dbh();
|
%schema_object = $self->_iterate_dbh();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $schema_obj ) {
|
MKDEBUG && _d('Next schema object:', Dumper(\%schema_object));
|
||||||
if ( $schema_obj->{ddl} && $self->{TableParser} ) {
|
return %schema_object;
|
||||||
$schema_obj->{tbl_struct}
|
|
||||||
= $self->{TableParser}->parse($schema_obj->{ddl});
|
|
||||||
}
|
|
||||||
|
|
||||||
delete $schema_obj->{ddl} unless $self->{keep_ddl};
|
|
||||||
|
|
||||||
if ( my $schema = $self->{Schema} ) {
|
|
||||||
$schema->add_schema_object($schema_obj);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
MKDEBUG && _d('Next schema object:', $schema_obj->{db}, $schema_obj->{tbl});
|
|
||||||
return $schema_obj;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub _iterate_files {
|
sub _iterate_files {
|
||||||
@@ -4543,11 +4695,11 @@ sub _iterate_files {
|
|||||||
my ($engine) = $ddl =~ m/\).*?(?:ENGINE|TYPE)=(\w+)/;
|
my ($engine) = $ddl =~ m/\).*?(?:ENGINE|TYPE)=(\w+)/;
|
||||||
|
|
||||||
if ( !$engine || $self->engine_is_allowed($engine) ) {
|
if ( !$engine || $self->engine_is_allowed($engine) ) {
|
||||||
return {
|
return (
|
||||||
db => $self->{db},
|
db => $self->{db},
|
||||||
tbl => $tbl,
|
tbl => $tbl,
|
||||||
ddl => $ddl,
|
ddl => $ddl,
|
||||||
};
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4615,11 +4767,11 @@ sub _iterate_dbh {
|
|||||||
$ddl = $du->get_create_table($dbh, $q, $self->{db}, $tbl)->[1];
|
$ddl = $du->get_create_table($dbh, $q, $self->{db}, $tbl)->[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return (
|
||||||
db => $self->{db},
|
db => $self->{db},
|
||||||
tbl => $tbl,
|
tbl => $tbl,
|
||||||
ddl => $ddl,
|
ddl => $ddl,
|
||||||
};
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4746,21 +4898,21 @@ sub _d {
|
|||||||
print STDERR "# $package:$line $PID ", join(' ', @_), "\n";
|
print STDERR "# $package:$line $PID ", join(' ', @_), "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} # package scope
|
||||||
1;
|
1;
|
||||||
}
|
|
||||||
# ###########################################################################
|
# ###########################################################################
|
||||||
# End SchemaIterator package
|
# End SchemaIterator package
|
||||||
# ###########################################################################
|
# ###########################################################################
|
||||||
|
|
||||||
# ###########################################################################
|
# ###########################################################################
|
||||||
# Retry package
|
# Retry package 7473
|
||||||
# This package is a copy without comments from the original. The original
|
# This package is a copy without comments from the original. The original
|
||||||
# with comments and its test file can be found in the Bazaar repository at,
|
# with comments and its test file can be found in the SVN repository at,
|
||||||
# lib/Retry.pm
|
# trunk/common/Retry.pm
|
||||||
# t/lib/Retry.t
|
# trunk/common/t/Retry.t
|
||||||
# See https://launchpad.net/percona-toolkit for more information.
|
# See http://code.google.com/p/maatkit/wiki/Developers for more information.
|
||||||
# ###########################################################################
|
# ###########################################################################
|
||||||
{
|
|
||||||
package Retry;
|
package Retry;
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
@@ -4831,25 +4983,30 @@ sub _d {
|
|||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
}
|
|
||||||
# ###########################################################################
|
# ###########################################################################
|
||||||
# End Retry package
|
# End Retry package
|
||||||
# ###########################################################################
|
# ###########################################################################
|
||||||
|
|
||||||
# ###########################################################################
|
# ###########################################################################
|
||||||
# Progress package
|
# Progress package 7096
|
||||||
# This package is a copy without comments from the original. The original
|
# This package is a copy without comments from the original. The original
|
||||||
# with comments and its test file can be found in the Bazaar repository at,
|
# with comments and its test file can be found in the SVN repository at,
|
||||||
# lib/Progress.pm
|
# trunk/common/Progress.pm
|
||||||
# t/lib/Progress.t
|
# trunk/common/t/Progress.t
|
||||||
# See https://launchpad.net/percona-toolkit for more information.
|
# See http://code.google.com/p/maatkit/wiki/Developers for more information.
|
||||||
# ###########################################################################
|
# ###########################################################################
|
||||||
{
|
|
||||||
package Progress;
|
package Progress;
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings FATAL => 'all';
|
use warnings FATAL => 'all';
|
||||||
|
|
||||||
use English qw(-no_match_vars);
|
use English qw(-no_match_vars);
|
||||||
|
use Data::Dumper;
|
||||||
|
$Data::Dumper::Indent = 1;
|
||||||
|
$Data::Dumper::Sortkeys = 1;
|
||||||
|
$Data::Dumper::Quotekeys = 0;
|
||||||
|
|
||||||
use constant MKDEBUG => $ENV{MKDEBUG} || 0;
|
use constant MKDEBUG => $ENV{MKDEBUG} || 0;
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
@@ -4972,7 +5129,7 @@ sub _d {
|
|||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
}
|
|
||||||
# ###########################################################################
|
# ###########################################################################
|
||||||
# End Progress package
|
# End Progress package
|
||||||
# ###########################################################################
|
# ###########################################################################
|
||||||
@@ -6593,7 +6750,7 @@ sub do_tbl_replicate {
|
|||||||
foreach my $warning ( @$warnings ) {
|
foreach my $warning ( @$warnings ) {
|
||||||
if ( $warning->{message} =~ m/Data truncated for column 'boundaries'/ ) {
|
if ( $warning->{message} =~ m/Data truncated for column 'boundaries'/ ) {
|
||||||
_d("Warning: WHERE clause too large for boundaries column; ",
|
_d("Warning: WHERE clause too large for boundaries column; ",
|
||||||
"pt-table-sync may fail; value:", $where);
|
"mk-table-sync may fail; value:", $where);
|
||||||
}
|
}
|
||||||
elsif ( ($warning->{code} || 0) == 1592 ) {
|
elsif ( ($warning->{code} || 0) == 1592 ) {
|
||||||
# Error: 1592 SQLSTATE: HY000 (ER_BINLOG_UNSAFE_STATEMENT)
|
# Error: 1592 SQLSTATE: HY000 (ER_BINLOG_UNSAFE_STATEMENT)
|
||||||
@@ -7133,7 +7290,7 @@ Or,
|
|||||||
|
|
||||||
Or,
|
Or,
|
||||||
|
|
||||||
pt-table-checksum host1 host2 ... hostN | pt-checksum-filter
|
pt-table-checksum host1 host2 ... hostN | mk-checksum-filter
|
||||||
|
|
||||||
See L<"SPECIFYING HOSTS"> for more on the syntax of the host arguments.
|
See L<"SPECIFYING HOSTS"> for more on the syntax of the host arguments.
|
||||||
|
|
||||||
@@ -7182,7 +7339,7 @@ on the same server, just checksum both databases:
|
|||||||
|
|
||||||
pt-table-checksum --databases db1,db2
|
pt-table-checksum --databases db1,db2
|
||||||
|
|
||||||
You can then use L<pt-checksum-filter> to compare the results in both databases
|
You can then use L<mk-checksum-filter> to compare the results in both databases
|
||||||
easily.
|
easily.
|
||||||
|
|
||||||
pt-table-checksum examines table structure only on the first host specified,
|
pt-table-checksum examines table structure only on the first host specified,
|
||||||
@@ -7412,7 +7569,7 @@ Output is unsorted, though all lines for one table should be output together.
|
|||||||
For speed, all checksums are done in parallel (as much as possible) and may
|
For speed, all checksums are done in parallel (as much as possible) and may
|
||||||
complete out of the order in which they were started. You might want to run
|
complete out of the order in which they were started. You might want to run
|
||||||
them through another script or command-line utility to make sure they are in the
|
them through another script or command-line utility to make sure they are in the
|
||||||
order you want. If you pipe the output through L<pt-checksum-filter>, you
|
order you want. If you pipe the output through L<mk-checksum-filter>, you
|
||||||
can sort the output and/or avoid seeing output about tables that have no
|
can sort the output and/or avoid seeing output about tables that have no
|
||||||
differences.
|
differences.
|
||||||
|
|
||||||
@@ -8176,8 +8333,8 @@ L<"--replicate-check"> option, pt-table-checksum can run the query for you to
|
|||||||
make it even easier. See L<"CONSISTENT CHECKSUMS"> for details.
|
make it even easier. See L<"CONSISTENT CHECKSUMS"> for details.
|
||||||
|
|
||||||
If you find tables that have differences, you can use the chunk boundaries in a
|
If you find tables that have differences, you can use the chunk boundaries in a
|
||||||
WHERE clause with L<pt-table-sync> to help repair them more efficiently. See
|
WHERE clause with L<mk-table-sync> to help repair them more efficiently. See
|
||||||
L<pt-table-sync> for details.
|
L<mk-table-sync> for details.
|
||||||
|
|
||||||
The table must have at least these columns: db, tbl, chunk, boundaries,
|
The table must have at least these columns: db, tbl, chunk, boundaries,
|
||||||
this_crc, master_crc, this_cnt, master_cnt. The table may be named anything you
|
this_crc, master_crc, this_cnt, master_cnt. The table may be named anything you
|
||||||
@@ -8606,7 +8763,7 @@ These DSN options are used to create a DSN. Each option is given like
|
|||||||
C<option=value>. The options are case-sensitive, so P and p are not the
|
C<option=value>. The options are case-sensitive, so P and p are not the
|
||||||
same option. There cannot be whitespace before or after the C<=> and
|
same option. There cannot be whitespace before or after the C<=> and
|
||||||
if the value contains whitespace it must be quoted. DSN options are
|
if the value contains whitespace it must be quoted. DSN options are
|
||||||
comma-separated. See the L<percona-toolkit> manpage for full details.
|
comma-separated. See the L<maatkit> manpage for full details.
|
||||||
|
|
||||||
=over
|
=over
|
||||||
|
|
||||||
|
@@ -585,6 +585,7 @@ sub repl_posn {
|
|||||||
sub get_slave_lag {
|
sub get_slave_lag {
|
||||||
my ( $self, $dbh ) = @_;
|
my ( $self, $dbh ) = @_;
|
||||||
my $stat = $self->get_slave_status($dbh);
|
my $stat = $self->get_slave_status($dbh);
|
||||||
|
return unless $stat; # server is not a slave
|
||||||
return $stat->{seconds_behind_master};
|
return $stat->{seconds_behind_master};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -9,7 +9,7 @@ BEGIN {
|
|||||||
use strict;
|
use strict;
|
||||||
use warnings FATAL => 'all';
|
use warnings FATAL => 'all';
|
||||||
use English qw(-no_match_vars);
|
use English qw(-no_match_vars);
|
||||||
use Test::More tests => 37;
|
use Test::More tests => 39;
|
||||||
|
|
||||||
use MasterSlave;
|
use MasterSlave;
|
||||||
use DSNParser;
|
use DSNParser;
|
||||||
@@ -398,6 +398,17 @@ SKIP: {
|
|||||||
diag(`/tmp/12346/start >/dev/null`);
|
diag(`/tmp/12346/start >/dev/null`);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
is(
|
||||||
|
$ms->get_slave_lag($dbh),
|
||||||
|
undef,
|
||||||
|
"get_slave_lag() for master"
|
||||||
|
);
|
||||||
|
|
||||||
|
ok(
|
||||||
|
defined $ms->get_slave_lag($slaves[1]),
|
||||||
|
"get_slave_lag() for slave"
|
||||||
|
);
|
||||||
|
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
# Done.
|
# Done.
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
|
@@ -1,95 +0,0 @@
|
|||||||
#!/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 tests => 6;
|
|
||||||
|
|
||||||
use PerconaTest;
|
|
||||||
shift @INC; # our unshift (above)
|
|
||||||
shift @INC; # PerconaTest's unshift
|
|
||||||
|
|
||||||
require "$trunk/bin/pt-table-usage";
|
|
||||||
|
|
||||||
my @args = qw();
|
|
||||||
my $in = "$trunk/t/pt-table-usage/samples/in/";
|
|
||||||
my $out = "t/pt-table-usage/samples/out/";
|
|
||||||
my $output = '';
|
|
||||||
|
|
||||||
# ############################################################################
|
|
||||||
# Basic queries that parse without problems.
|
|
||||||
# ############################################################################
|
|
||||||
ok(
|
|
||||||
no_diff(
|
|
||||||
sub { pt_table_usage::main(@args, "$in/slow001.txt") },
|
|
||||||
"$out/slow001.txt",
|
|
||||||
),
|
|
||||||
'Analysis for slow001.txt'
|
|
||||||
);
|
|
||||||
|
|
||||||
ok(
|
|
||||||
no_diff(
|
|
||||||
sub { pt_table_usage::main(@args, "$in/slow002.txt") },
|
|
||||||
"$out/slow002.txt",
|
|
||||||
),
|
|
||||||
'Analysis for slow002.txt (issue 1237)'
|
|
||||||
);
|
|
||||||
|
|
||||||
ok(
|
|
||||||
no_diff(
|
|
||||||
sub { pt_table_usage::main(@args, '--query',
|
|
||||||
'DROP TABLE IF EXISTS t') },
|
|
||||||
"$out/drop-table-if-exists.txt",
|
|
||||||
),
|
|
||||||
'DROP TABLE IF EXISTS'
|
|
||||||
);
|
|
||||||
|
|
||||||
# ############################################################################
|
|
||||||
# --id-attribute
|
|
||||||
# ############################################################################
|
|
||||||
ok(
|
|
||||||
no_diff(
|
|
||||||
sub { pt_table_usage::main(@args, "$in/slow003.txt",
|
|
||||||
qw(--id-attribute ts)) },
|
|
||||||
"$out/slow003-003.txt",
|
|
||||||
),
|
|
||||||
'Analysis for slow003.txt with --id-attribute'
|
|
||||||
);
|
|
||||||
|
|
||||||
# ############################################################################
|
|
||||||
# --constant-data-value
|
|
||||||
# ############################################################################
|
|
||||||
$output = output(
|
|
||||||
sub { pt_table_usage::main('--query', 'INSERT INTO t VALUES (42)',
|
|
||||||
qw(--constant-data-value <const>)) },
|
|
||||||
);
|
|
||||||
like(
|
|
||||||
$output,
|
|
||||||
qr/SELECT <const>/,
|
|
||||||
"--constant-data-value"
|
|
||||||
);
|
|
||||||
|
|
||||||
# ############################################################################
|
|
||||||
# Queries with tables that can't be resolved.
|
|
||||||
# ############################################################################
|
|
||||||
|
|
||||||
# The tables in the WHERE can't be resolved so there's no WHERE access listed.
|
|
||||||
ok(
|
|
||||||
no_diff(
|
|
||||||
sub { pt_table_usage::main(@args, "$in/slow003.txt") },
|
|
||||||
"$out/slow003-001.txt",
|
|
||||||
),
|
|
||||||
'Analysis for slow003.txt'
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
# #############################################################################
|
|
||||||
# Done.
|
|
||||||
# #############################################################################
|
|
||||||
exit;
|
|
@@ -1,44 +0,0 @@
|
|||||||
#!/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 tests => 1;
|
|
||||||
|
|
||||||
use PerconaTest;
|
|
||||||
shift @INC; # our unshift (above)
|
|
||||||
shift @INC; # PerconaTest's unshift
|
|
||||||
|
|
||||||
require "$trunk/bin/pt-table-usage";
|
|
||||||
|
|
||||||
my @args = qw();
|
|
||||||
my $in = "$trunk/t/pt-table-usage/samples/in/";
|
|
||||||
my $out = "t/pt-table-usage/samples/out/";
|
|
||||||
my $output = '';
|
|
||||||
|
|
||||||
# ############################################################################
|
|
||||||
# Test --create-table-definitions
|
|
||||||
# ############################################################################
|
|
||||||
|
|
||||||
# Without --create-table-definitions, the tables wouldn't be db-qualified.
|
|
||||||
ok(
|
|
||||||
no_diff(
|
|
||||||
sub { pt_table_usage::main(@args,
|
|
||||||
'--query', 'select city from city where city="New York"',
|
|
||||||
'--create-table-definitions',
|
|
||||||
"$trunk/t/lib/samples/mysqldump-no-data/all-dbs.txt") },
|
|
||||||
"$out/create-table-defs-001.txt",
|
|
||||||
),
|
|
||||||
'--create-table-definitions'
|
|
||||||
);
|
|
||||||
|
|
||||||
# #############################################################################
|
|
||||||
# Done.
|
|
||||||
# #############################################################################
|
|
||||||
exit;
|
|
@@ -1,58 +0,0 @@
|
|||||||
#!/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-table-usage";
|
|
||||||
|
|
||||||
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 => 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
my $output;
|
|
||||||
my $cnf = '/tmp/12345/my.sandbox.cnf';
|
|
||||||
my @args = ('--explain-extended', "F=$cnf");
|
|
||||||
|
|
||||||
my $in = "$trunk/t/pt-table-usage/samples/in/";
|
|
||||||
my $out = "t/pt-table-usage/samples/out/";
|
|
||||||
|
|
||||||
$output = output(
|
|
||||||
sub { pt_table_usage::main(@args, "$in/slow003.txt") },
|
|
||||||
stderr => 1,
|
|
||||||
);
|
|
||||||
|
|
||||||
like(
|
|
||||||
$output,
|
|
||||||
qr/No database/,
|
|
||||||
"--explain-extended doesn't work without a database"
|
|
||||||
);
|
|
||||||
|
|
||||||
ok(
|
|
||||||
no_diff(
|
|
||||||
sub { pt_table_usage::main(@args, qw(-D sakila), "$in/slow003.txt") },
|
|
||||||
"$out/slow003-002.txt",
|
|
||||||
),
|
|
||||||
'EXPLAIN EXTENDED slow003.txt'
|
|
||||||
);
|
|
||||||
|
|
||||||
# #############################################################################
|
|
||||||
# Done.
|
|
||||||
# #############################################################################
|
|
||||||
exit;
|
|
@@ -1,24 +0,0 @@
|
|||||||
# Time: 071218 11:48:27
|
|
||||||
# Thread_id: 10 Query_id: 1
|
|
||||||
# Query_time: 0.000012 Lock_time: 0.000000 Rows_sent: 0 Rows_examined: 0
|
|
||||||
select * from t;
|
|
||||||
# Time: 071218 11:48:27
|
|
||||||
# Thread_id: 10 Query_id: 2
|
|
||||||
# Query_time: 0.000012 Lock_time: 0.000000 Rows_sent: 0 Rows_examined: 0
|
|
||||||
select * from t1, t2 as x, t3 y, z;
|
|
||||||
# Time: 071218 11:48:27
|
|
||||||
# Thread_id: 10 Query_id: 3
|
|
||||||
# Query_time: 0.000012 Lock_time: 0.000000 Rows_sent: 0 Rows_examined: 0
|
|
||||||
insert into t values (1, 2, 3);
|
|
||||||
# Time: 071218 11:48:27
|
|
||||||
# Thread_id: 10 Query_id: 4
|
|
||||||
# Query_time: 0.000012 Lock_time: 0.000000 Rows_sent: 0 Rows_examined: 0
|
|
||||||
delete from t where id < 1000;
|
|
||||||
# Time: 071218 11:48:27
|
|
||||||
# Thread_id: 10 Query_id: 5
|
|
||||||
# Query_time: 0.000012 Lock_time: 0.000000 Rows_sent: 0 Rows_examined: 0
|
|
||||||
select * from a as t1, b as t2 where t1.id=t2.id;
|
|
||||||
# Time: 071218 11:48:27
|
|
||||||
# Thread_id: 10 Query_id: 6
|
|
||||||
# Query_time: 0.000012 Lock_time: 0.000000 Rows_sent: 0 Rows_examined: 0
|
|
||||||
replace into t set foo='bar';
|
|
@@ -1,20 +0,0 @@
|
|||||||
# Time: 071218 11:48:27
|
|
||||||
# Thread_id: 10 Query_id: 1
|
|
||||||
# Query_time: 0.000012 Lock_time: 0.000000 Rows_sent: 0 Rows_examined: 0
|
|
||||||
UPDATE t1 AS a JOIN t2 AS b USING (id) SET a.foo="bar" WHERE b.foo IS NOT NULL;
|
|
||||||
# Time: 071218 11:48:27
|
|
||||||
# Thread_id: 10 Query_id: 2
|
|
||||||
# Query_time: 0.000012 Lock_time: 0.000000 Rows_sent: 0 Rows_examined: 0
|
|
||||||
UPDATE t1 AS a JOIN t2 AS b USING (id) SET a.foo="bar", b.foo="bat" WHERE a.id=1;
|
|
||||||
# Time: 071218 11:48:27
|
|
||||||
# Thread_id: 10 Query_id: 3
|
|
||||||
# Query_time: 0.000012 Lock_time: 0.000000 Rows_sent: 0 Rows_examined: 0
|
|
||||||
UPDATE t1 INNER JOIN t2 USING (id) SET t1.foo="bar" WHERE t2.id=1;
|
|
||||||
# Time: 071218 11:48:27
|
|
||||||
# Thread_id: 10 Query_id: 4
|
|
||||||
# Query_time: 0.000012 Lock_time: 0.000000 Rows_sent: 0 Rows_examined: 0
|
|
||||||
insert into t1 (a, b, c) select x, y, z from t2 where x is not null;
|
|
||||||
# Time: 071218 11:48:27
|
|
||||||
# Thread_id: 10 Query_id: 5
|
|
||||||
# Query_time: 0.000012 Lock_time: 0.000000 Rows_sent: 0 Rows_examined: 0
|
|
||||||
insert into t (a, b, c) select a.x, a.y, b.z from a, b where a.id=b.id;
|
|
@@ -1,3 +0,0 @@
|
|||||||
# Time: 110422 11:28:00
|
|
||||||
# Query_time: 0.000300 Lock_time: 0.000000 Rows_sent: 1 Rows_examined: 1
|
|
||||||
select country.country, city.city from city join country using (country_id) where country = 'Brazil' and city like 'A%' limit 1;
|
|
@@ -1,4 +0,0 @@
|
|||||||
Query_id: 0x1E0BF7001F0D58BB.1
|
|
||||||
SELECT sakila.city
|
|
||||||
WHERE sakila.city
|
|
||||||
|
|
@@ -1,3 +0,0 @@
|
|||||||
Query_id: 0xAED187CD505CBD92.1
|
|
||||||
DROP_TABLE t
|
|
||||||
|
|
@@ -1,31 +0,0 @@
|
|||||||
Query_id: 0xF28708D8F2920792.1
|
|
||||||
SELECT t
|
|
||||||
|
|
||||||
Query_id: 0x09CB59D3450EF6E8.1
|
|
||||||
SELECT t1
|
|
||||||
SELECT t2
|
|
||||||
SELECT t3
|
|
||||||
SELECT z
|
|
||||||
TLIST t1
|
|
||||||
TLIST t2
|
|
||||||
TLIST t3
|
|
||||||
TLIST z
|
|
||||||
|
|
||||||
Query_id: 0xCF687AF9F2D5E248.1
|
|
||||||
INSERT t
|
|
||||||
SELECT DUAL
|
|
||||||
|
|
||||||
Query_id: 0xF1FBC364588DC469.1
|
|
||||||
DELETE t
|
|
||||||
WHERE t
|
|
||||||
|
|
||||||
Query_id: 0x8745D03011B0E1CE.1
|
|
||||||
SELECT a
|
|
||||||
SELECT b
|
|
||||||
JOIN a
|
|
||||||
JOIN b
|
|
||||||
|
|
||||||
Query_id: 0xEB871CD2B5729EA1.1
|
|
||||||
REPLACE t
|
|
||||||
SELECT DUAL
|
|
||||||
|
|
@@ -1,40 +0,0 @@
|
|||||||
Query_id: 0x6B1671EA6890F103.1
|
|
||||||
UPDATE t1
|
|
||||||
SELECT DUAL
|
|
||||||
JOIN t1
|
|
||||||
JOIN t2
|
|
||||||
WHERE t2
|
|
||||||
|
|
||||||
Query_id: 0x1CD27577D202A339.1
|
|
||||||
UPDATE t1
|
|
||||||
SELECT DUAL
|
|
||||||
JOIN t1
|
|
||||||
JOIN t2
|
|
||||||
WHERE t1
|
|
||||||
|
|
||||||
Query_id: 0x1CD27577D202A339.2
|
|
||||||
UPDATE t2
|
|
||||||
SELECT DUAL
|
|
||||||
JOIN t1
|
|
||||||
JOIN t2
|
|
||||||
WHERE t1
|
|
||||||
|
|
||||||
Query_id: 0xF4BEDD52BF14F91B.1
|
|
||||||
UPDATE t1
|
|
||||||
SELECT DUAL
|
|
||||||
JOIN t1
|
|
||||||
JOIN t2
|
|
||||||
WHERE t2
|
|
||||||
|
|
||||||
Query_id: 0x1E62B5AB0DD828BF.1
|
|
||||||
INSERT t1
|
|
||||||
SELECT t2
|
|
||||||
WHERE t2
|
|
||||||
|
|
||||||
Query_id: 0xE25F88EDB02EA4A3.1
|
|
||||||
INSERT t
|
|
||||||
SELECT a
|
|
||||||
SELECT b
|
|
||||||
JOIN a
|
|
||||||
JOIN b
|
|
||||||
|
|
@@ -1,6 +0,0 @@
|
|||||||
Query_id: 0x7C6C08E1FA6D7E73.1
|
|
||||||
SELECT country
|
|
||||||
SELECT city
|
|
||||||
JOIN city
|
|
||||||
JOIN country
|
|
||||||
|
|
@@ -1,8 +0,0 @@
|
|||||||
Query_id: 0x7C6C08E1FA6D7E73.1
|
|
||||||
SELECT sakila.country
|
|
||||||
SELECT sakila.city
|
|
||||||
JOIN sakila.city
|
|
||||||
JOIN sakila.country
|
|
||||||
WHERE sakila.city
|
|
||||||
WHERE sakila.country
|
|
||||||
|
|
@@ -1,6 +0,0 @@
|
|||||||
Query_id: 110422 11:28:00.1
|
|
||||||
SELECT country
|
|
||||||
SELECT city
|
|
||||||
JOIN city
|
|
||||||
JOIN country
|
|
||||||
|
|
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
# NOTE port: The server is listening on a non-default port.
|
# NOTE port: The server is listening on a non-default port.
|
||||||
|
|
||||||
# WARN slave_net_timeout: This variable is set too high. This is too long to wait before noticing that the connection to the master has failed and retrying. This should probably be set to 60 seconds or less. It is also a good idea to use mk-heartbeat to ensure that the connection does not appear to time out when the master is simply idle.
|
# WARN slave_net_timeout: This variable is set too high. This is too long to wait before noticing that the connection to the master has failed and retrying. This should probably be set to 60 seconds or less. It is also a good idea to use pt-heartbeat to ensure that the connection does not appear to time out when the master is simply idle.
|
||||||
|
|
||||||
# NOTE innodb_data_file_path: Auto-extending InnoDB files can consume a lot of disk space that is very difficult to reclaim later. Some people prefer to set innodb_file_per_table and allocate a fixed-size file for ibdata1.
|
# NOTE innodb_data_file_path: Auto-extending InnoDB files can consume a lot of disk space that is very difficult to reclaim later. Some people prefer to set innodb_file_per_table and allocate a fixed-size file for ibdata1.
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user