mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-11 13:40:07 +00:00
Merged ubuntu-12-64-issues
This commit is contained in:
@@ -2182,7 +2182,7 @@ sub get_dbh {
|
|||||||
PTDEBUG && _d($dbh, $sql);
|
PTDEBUG && _d($dbh, $sql);
|
||||||
my ($sql_mode) = eval { $dbh->selectrow_array($sql) };
|
my ($sql_mode) = eval { $dbh->selectrow_array($sql) };
|
||||||
if ( $EVAL_ERROR ) {
|
if ( $EVAL_ERROR ) {
|
||||||
die $EVAL_ERROR;
|
die "Error getting the current SQL_MODE: $EVAL_ERROR";
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = 'SET @@SQL_QUOTE_SHOW_CREATE = 1'
|
$sql = 'SET @@SQL_QUOTE_SHOW_CREATE = 1'
|
||||||
@@ -2192,15 +2192,17 @@ sub get_dbh {
|
|||||||
PTDEBUG && _d($dbh, $sql);
|
PTDEBUG && _d($dbh, $sql);
|
||||||
eval { $dbh->do($sql) };
|
eval { $dbh->do($sql) };
|
||||||
if ( $EVAL_ERROR ) {
|
if ( $EVAL_ERROR ) {
|
||||||
die $EVAL_ERROR;
|
die "Error setting SQL_QUOTE_SHOW_CREATE, SQL_MODE"
|
||||||
|
. ($sql_mode ? " and $sql_mode" : '')
|
||||||
|
. ": $EVAL_ERROR";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( my ($charset) = $cxn_string =~ m/charset=(\w+)/ ) {
|
if ( my ($charset) = $cxn_string =~ m/charset=([\w]+)/ ) {
|
||||||
$sql = "/*!40101 SET NAMES $charset*/";
|
$sql = qq{/*!40101 SET NAMES "$charset"*/};
|
||||||
PTDEBUG && _d($dbh, ':', $sql);
|
PTDEBUG && _d($dbh, ':', $sql);
|
||||||
eval { $dbh->do($sql) };
|
eval { $dbh->do($sql) };
|
||||||
if ( $EVAL_ERROR ) {
|
if ( $EVAL_ERROR ) {
|
||||||
die $EVAL_ERROR;
|
die "Error setting NAMES to $charset: $EVAL_ERROR";
|
||||||
}
|
}
|
||||||
PTDEBUG && _d('Enabling charset for STDOUT');
|
PTDEBUG && _d('Enabling charset for STDOUT');
|
||||||
if ( $charset eq 'utf8' ) {
|
if ( $charset eq 'utf8' ) {
|
||||||
@@ -2212,12 +2214,12 @@ sub get_dbh {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $self->prop('set-vars') ) {
|
if ( my $var = $self->prop('set-vars') ) {
|
||||||
$sql = "SET " . $self->prop('set-vars');
|
$sql = "SET $var";
|
||||||
PTDEBUG && _d($dbh, ':', $sql);
|
PTDEBUG && _d($dbh, ':', $sql);
|
||||||
eval { $dbh->do($sql) };
|
eval { $dbh->do($sql) };
|
||||||
if ( $EVAL_ERROR ) {
|
if ( $EVAL_ERROR ) {
|
||||||
die $EVAL_ERROR;
|
die "Error setting $var: $EVAL_ERROR";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3953,6 +3955,22 @@ sub main {
|
|||||||
$dp->get_cxn_params($table), { AutoCommit => $ac });
|
$dp->get_cxn_params($table), { AutoCommit => $ac });
|
||||||
PTDEBUG && _d('Inspecting table on', $dp->as_string($table));
|
PTDEBUG && _d('Inspecting table on', $dp->as_string($table));
|
||||||
|
|
||||||
|
if ( $o->get('bulk-insert') ) {
|
||||||
|
local $@;
|
||||||
|
my $sql = "LOAD DATA LOCAL INFILE '/dev/null' INTO TABLE "
|
||||||
|
. "`test`.`pt_not_there`";
|
||||||
|
eval { $dbh->do($sql); 1 } or do {
|
||||||
|
my $e = $@;
|
||||||
|
my $error_re = qr/\QDBD::mysql::db do failed: The used command is not allowed with this MySQL version [for Statement "LOAD DATA LOCAL INFILE/;
|
||||||
|
if ($e =~ $error_re) {
|
||||||
|
$dbh->disconnect();
|
||||||
|
die("--bulk-insert cannot work as LOAD DATA LOCAL INFILE "
|
||||||
|
. "is disabled. See http://kb.percona.com/troubleshoot-load-data-infile"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
# Set options that can enable removing data on the master and archiving it
|
# Set options that can enable removing data on the master and archiving it
|
||||||
# on the slaves.
|
# on the slaves.
|
||||||
if ( $table->{a} ) {
|
if ( $table->{a} ) {
|
||||||
@@ -5091,6 +5109,9 @@ STDOUT to utf8, passes the mysql_enable_utf8 option to DBD::mysql, and runs SET
|
|||||||
NAMES UTF8 after connecting to MySQL. Any other value sets binmode on STDOUT
|
NAMES UTF8 after connecting to MySQL. Any other value sets binmode on STDOUT
|
||||||
without the utf8 layer, and runs SET NAMES after connecting to MySQL.
|
without the utf8 layer, and runs SET NAMES after connecting to MySQL.
|
||||||
|
|
||||||
|
Note that only charsets as known by MySQL are recognized; So for example,
|
||||||
|
"UTF8" will work, but "UTF-8" will not.
|
||||||
|
|
||||||
See also L<"--[no]check-charset">.
|
See also L<"--[no]check-charset">.
|
||||||
|
|
||||||
=item --[no]check-charset
|
=item --[no]check-charset
|
||||||
|
@@ -1389,25 +1389,20 @@ sub _d {
|
|||||||
# ###########################################################################
|
# ###########################################################################
|
||||||
|
|
||||||
# ###########################################################################
|
# ###########################################################################
|
||||||
# ReadKeyMini
|
# ReadKeyMini package
|
||||||
|
# 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,
|
||||||
|
# lib/ReadKeyMini.pm
|
||||||
|
# t/lib/ReadKeyMini.t
|
||||||
|
# See https://launchpad.net/percona-toolkit for more information.
|
||||||
# ###########################################################################
|
# ###########################################################################
|
||||||
|
{
|
||||||
|
|
||||||
BEGIN {
|
BEGIN {
|
||||||
|
|
||||||
package ReadKeyMini;
|
package ReadKeyMini;
|
||||||
# Here be magic. We lie to %INC and say that someone already pulled us from
|
|
||||||
# the filesystem. Which might be true, if this is inside a .pm file, but
|
|
||||||
# might not be, if we are part of the big file. The spurious BEGINs are mostly
|
|
||||||
# unnecesary, but if we aren't inside a .pm and something uses us, import or
|
|
||||||
# EXPORT_OK might not yet be defined. Though that probably won't help.
|
|
||||||
# Costs us nothing though, so worth trying. Putting this on top of the file
|
|
||||||
# would solve the issue.
|
|
||||||
BEGIN { $INC{"ReadKeyMini.pm"} ||= 1 }
|
BEGIN { $INC{"ReadKeyMini.pm"} ||= 1 }
|
||||||
|
|
||||||
# Package: ReadKeyMini
|
|
||||||
# ReadKeyMini is a wrapper around Term::ReadKey. If that's available,
|
|
||||||
# we use ReadMode and GetTerminalSize from there. Otherwise, we use homebrewn
|
|
||||||
# definitions.
|
|
||||||
|
|
||||||
use warnings;
|
use warnings;
|
||||||
use strict;
|
use strict;
|
||||||
use English qw(-no_match_vars);
|
use English qw(-no_match_vars);
|
||||||
@@ -1434,14 +1429,14 @@ my %modes = (
|
|||||||
'ultra-raw' => 5,
|
'ultra-raw' => 5,
|
||||||
);
|
);
|
||||||
|
|
||||||
# This primarily comes from the Perl Cookbook, recipe 15.8
|
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
my $fd_stdin = fileno(STDIN);
|
my $fd_stdin = fileno(STDIN);
|
||||||
my $flags;
|
my $flags;
|
||||||
unless ( $PerconaTest::DONT_RESTORE_STDIN ) {
|
unless ( $PerconaTest::DONT_RESTORE_STDIN ) {
|
||||||
$flags = fcntl(STDIN, F_GETFL, 0)
|
$flags = fcntl(STDIN, F_GETFL, 0)
|
||||||
or die "can't fcntl F_GETFL: $!";
|
or warn "can't fcntl F_GETFL: $!";
|
||||||
}
|
}
|
||||||
my $term = POSIX::Termios->new();
|
my $term = POSIX::Termios->new();
|
||||||
$term->getattr($fd_stdin);
|
$term->getattr($fd_stdin);
|
||||||
@@ -1475,7 +1470,7 @@ my %modes = (
|
|||||||
$term->setattr( $fd_stdin, TCSANOW );
|
$term->setattr( $fd_stdin, TCSANOW );
|
||||||
unless ( $PerconaTest::DONT_RESTORE_STDIN ) {
|
unless ( $PerconaTest::DONT_RESTORE_STDIN ) {
|
||||||
fcntl(STDIN, F_SETFL, $flags)
|
fcntl(STDIN, F_SETFL, $flags)
|
||||||
or die "can't fcntl F_SETFL: $!";
|
or warn "can't fcntl F_SETFL: $!";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1489,9 +1484,6 @@ sub readkey {
|
|||||||
sysread(STDIN, $key, 1);
|
sysread(STDIN, $key, 1);
|
||||||
my $timeout = 0.1;
|
my $timeout = 0.1;
|
||||||
if ( $key eq "\033" ) {
|
if ( $key eq "\033" ) {
|
||||||
# Ugly and broken hack, but good enough for the two minutes it took to write.
|
|
||||||
# Namely, Ctrl escapes, the F-NUM keys, and other stuff you can send from the keyboard
|
|
||||||
# take more than one "character" to represent, and would be wrong to break into pieces.
|
|
||||||
{
|
{
|
||||||
my $x = '';
|
my $x = '';
|
||||||
STDIN->blocking(0);
|
STDIN->blocking(0);
|
||||||
@@ -1505,15 +1497,11 @@ sub readkey {
|
|||||||
return $key;
|
return $key;
|
||||||
}
|
}
|
||||||
|
|
||||||
# As per perlfaq8:
|
|
||||||
|
|
||||||
BEGIN {
|
BEGIN {
|
||||||
eval { no warnings; local $^W; require 'sys/ioctl.ph' };
|
eval { no warnings; local $^W; require 'sys/ioctl.ph' };
|
||||||
if ( !defined &TIOCGWINSZ ) {
|
if ( !defined &TIOCGWINSZ ) {
|
||||||
*TIOCGWINSZ = sub () {
|
*TIOCGWINSZ = sub () {
|
||||||
# Very few systems actually have ioctl.ph, thus it comes to this.
|
|
||||||
# These seem to be good enough, for now. See:
|
|
||||||
# http://stackoverflow.com/a/4286840/536499
|
|
||||||
$^O eq 'linux' ? 0x005413
|
$^O eq 'linux' ? 0x005413
|
||||||
: $^O eq 'solaris' ? 0x005468
|
: $^O eq 'solaris' ? 0x005468
|
||||||
: 0x40087468;
|
: 0x40087468;
|
||||||
@@ -1536,11 +1524,11 @@ sub _GetTerminalSize {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $rows = `tput lines` ) {
|
if ( $rows = `tput lines 2>/dev/null` ) {
|
||||||
chomp($rows);
|
chomp($rows);
|
||||||
chomp($cols = `tput cols`);
|
chomp($cols = `tput cols`);
|
||||||
}
|
}
|
||||||
elsif ( my $stty = `stty -a` ) {
|
elsif ( my $stty = `stty -a 2>/dev/null` ) {
|
||||||
($rows, $cols) = $stty =~ /([0-9]+) rows; ([0-9]+) columns;/;
|
($rows, $cols) = $stty =~ /([0-9]+) rows; ([0-9]+) columns;/;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -1555,6 +1543,7 @@ sub _GetTerminalSize {
|
|||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
}
|
||||||
# ###########################################################################
|
# ###########################################################################
|
||||||
# End ReadKeyMini package
|
# End ReadKeyMini package
|
||||||
# ###########################################################################
|
# ###########################################################################
|
||||||
|
@@ -10371,6 +10371,32 @@ sub main {
|
|||||||
$host->{name} = $name || 'unknown host';
|
$host->{name} = $name || 'unknown host';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# ########################################################################
|
||||||
|
# If we're comparing rows, check that LOAD DATA LOCAL INFILE works for,
|
||||||
|
# all hosts, or bail out early if it doesn't.
|
||||||
|
# ########################################################################
|
||||||
|
my $compare = $o->get('compare');
|
||||||
|
if ( $compare->{results}
|
||||||
|
&& lc($o->get('compare-results-method')) eq 'rows' )
|
||||||
|
{
|
||||||
|
foreach my $host ( @$hosts ) {
|
||||||
|
local $@;
|
||||||
|
my $sql = "LOAD DATA LOCAL INFILE '/dev/null' INTO TABLE "
|
||||||
|
. "`test`.`pt_not_there`";
|
||||||
|
eval { $host->{dbh}->do($sql); 1 } or do {
|
||||||
|
my $e = $@;
|
||||||
|
my $error_re = qr/\QDBD::mysql::db do failed: The used command is not allowed with this MySQL version [for Statement "LOAD DATA LOCAL INFILE/;
|
||||||
|
if ($e =~ $error_re) {
|
||||||
|
$_->{dbh}->disconnect() for @$hosts;
|
||||||
|
die("Cannot compare rows as LOAD DATA LOCAL INFILE "
|
||||||
|
. "is disabled for $host->{name}. See "
|
||||||
|
. "http://kb.percona.com/troubleshoot-load-data-infile"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# ########################################################################
|
# ########################################################################
|
||||||
# Make some common modules.
|
# Make some common modules.
|
||||||
# ########################################################################
|
# ########################################################################
|
||||||
@@ -10404,7 +10430,6 @@ sub main {
|
|||||||
# ########################################################################
|
# ########################################################################
|
||||||
# Make compare modules in order.
|
# Make compare modules in order.
|
||||||
# ########################################################################
|
# ########################################################################
|
||||||
my $compare = $o->get('compare');
|
|
||||||
my @compare_modules;
|
my @compare_modules;
|
||||||
if ( $compare->{results} ) {
|
if ( $compare->{results} ) {
|
||||||
my $method = lc $o->get('compare-results-method');
|
my $method = lc $o->get('compare-results-method');
|
||||||
|
@@ -103,7 +103,7 @@ sub new {
|
|||||||
dsn_name => $dp->as_string($dsn, [qw(h P S)]),
|
dsn_name => $dp->as_string($dsn, [qw(h P S)]),
|
||||||
hostname => '',
|
hostname => '',
|
||||||
set => $args{set},
|
set => $args{set},
|
||||||
NAME_lc => $args{NAME_lc},
|
NAME_lc => defined($args{NAME_lc}) ? $args{NAME_lc} : 1,
|
||||||
dbh_set => 0,
|
dbh_set => 0,
|
||||||
OptionParser => $o,
|
OptionParser => $o,
|
||||||
DSNParser => $dp,
|
DSNParser => $dp,
|
||||||
|
@@ -336,7 +336,7 @@ sub get_dbh {
|
|||||||
PTDEBUG && _d($dbh, $sql);
|
PTDEBUG && _d($dbh, $sql);
|
||||||
my ($sql_mode) = eval { $dbh->selectrow_array($sql) };
|
my ($sql_mode) = eval { $dbh->selectrow_array($sql) };
|
||||||
if ( $EVAL_ERROR ) {
|
if ( $EVAL_ERROR ) {
|
||||||
die $EVAL_ERROR;
|
die "Error getting the current SQL_MODE: $EVAL_ERROR";
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = 'SET @@SQL_QUOTE_SHOW_CREATE = 1'
|
$sql = 'SET @@SQL_QUOTE_SHOW_CREATE = 1'
|
||||||
@@ -346,16 +346,18 @@ sub get_dbh {
|
|||||||
PTDEBUG && _d($dbh, $sql);
|
PTDEBUG && _d($dbh, $sql);
|
||||||
eval { $dbh->do($sql) };
|
eval { $dbh->do($sql) };
|
||||||
if ( $EVAL_ERROR ) {
|
if ( $EVAL_ERROR ) {
|
||||||
die $EVAL_ERROR;
|
die "Error setting SQL_QUOTE_SHOW_CREATE, SQL_MODE"
|
||||||
|
. ($sql_mode ? " and $sql_mode" : '')
|
||||||
|
. ": $EVAL_ERROR";
|
||||||
}
|
}
|
||||||
|
|
||||||
# Set character set and binmode on STDOUT.
|
# Set character set and binmode on STDOUT.
|
||||||
if ( my ($charset) = $cxn_string =~ m/charset=(\w+)/ ) {
|
if ( my ($charset) = $cxn_string =~ m/charset=([\w]+)/ ) {
|
||||||
$sql = "/*!40101 SET NAMES $charset*/";
|
$sql = qq{/*!40101 SET NAMES "$charset"*/};
|
||||||
PTDEBUG && _d($dbh, ':', $sql);
|
PTDEBUG && _d($dbh, ':', $sql);
|
||||||
eval { $dbh->do($sql) };
|
eval { $dbh->do($sql) };
|
||||||
if ( $EVAL_ERROR ) {
|
if ( $EVAL_ERROR ) {
|
||||||
die $EVAL_ERROR;
|
die "Error setting NAMES to $charset: $EVAL_ERROR";
|
||||||
}
|
}
|
||||||
PTDEBUG && _d('Enabling charset for STDOUT');
|
PTDEBUG && _d('Enabling charset for STDOUT');
|
||||||
if ( $charset eq 'utf8' ) {
|
if ( $charset eq 'utf8' ) {
|
||||||
@@ -367,12 +369,12 @@ sub get_dbh {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $self->prop('set-vars') ) {
|
if ( my $var = $self->prop('set-vars') ) {
|
||||||
$sql = "SET " . $self->prop('set-vars');
|
$sql = "SET $var";
|
||||||
PTDEBUG && _d($dbh, ':', $sql);
|
PTDEBUG && _d($dbh, ':', $sql);
|
||||||
eval { $dbh->do($sql) };
|
eval { $dbh->do($sql) };
|
||||||
if ( $EVAL_ERROR ) {
|
if ( $EVAL_ERROR ) {
|
||||||
die $EVAL_ERROR;
|
die "Error setting $var: $EVAL_ERROR";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -717,12 +717,17 @@ sub full_output {
|
|||||||
my ( $code, %args ) = @_;
|
my ( $code, %args ) = @_;
|
||||||
die "I need a code argument" unless $code;
|
die "I need a code argument" unless $code;
|
||||||
|
|
||||||
my (undef, $file) = tempfile();
|
local (*STDOUT, *STDERR);
|
||||||
open *output_fh, '>', $file
|
require IO::File;
|
||||||
or die "Cannot open file $file: $OS_ERROR";
|
|
||||||
local *STDOUT = *output_fh;
|
|
||||||
|
|
||||||
*STDERR = *STDOUT;
|
my (undef, $file) = tempfile();
|
||||||
|
open *STDOUT, '>', $file
|
||||||
|
or die "Cannot open file $file: $OS_ERROR";
|
||||||
|
*STDOUT->autoflush(1);
|
||||||
|
|
||||||
|
open *STDERR, '>', $file
|
||||||
|
or die "Cannot open file $file: $OS_ERROR";
|
||||||
|
*STDERR->autoflush(1);
|
||||||
|
|
||||||
my $status;
|
my $status;
|
||||||
if (my $pid = fork) {
|
if (my $pid = fork) {
|
||||||
@@ -745,7 +750,7 @@ sub full_output {
|
|||||||
else {
|
else {
|
||||||
exit $code->();
|
exit $code->();
|
||||||
}
|
}
|
||||||
close *output_fh;
|
close $_ or die "Cannot close $_: $OS_ERROR" for qw(STDOUT STDERR);
|
||||||
my $output = do { local $/; open my $fh, "<", $file or die $!; <$fh> };
|
my $output = do { local $/; open my $fh, "<", $file or die $!; <$fh> };
|
||||||
|
|
||||||
return ($output, $status);
|
return ($output, $status);
|
||||||
@@ -772,6 +777,19 @@ sub tables_used {
|
|||||||
return [ sort keys %tables ];
|
return [ sort keys %tables ];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub load_data_is_disabled {
|
||||||
|
my ($dbh) = @_;
|
||||||
|
my $sql = "LOAD DATA LOCAL INFILE '/dev/null' INTO TABLE "
|
||||||
|
. "`t`.`pt_not_there`";
|
||||||
|
local $@;
|
||||||
|
if (!eval { $dbh->do($sql); 1 } ) {
|
||||||
|
my $e = $@;
|
||||||
|
return 1 if $e =~ qr/\QDBD::mysql::db do failed: The used command is not allowed with this MySQL version [for Statement "LOAD DATA LOCAL INFILE/;
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
}
|
}
|
||||||
# ###########################################################################
|
# ###########################################################################
|
||||||
|
@@ -15,8 +15,14 @@
|
|||||||
# this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
# this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
||||||
# Place, Suite 330, Boston, MA 02111-1307 USA.
|
# Place, Suite 330, Boston, MA 02111-1307 USA.
|
||||||
# ###########################################################################
|
# ###########################################################################
|
||||||
# ReadKeyMini
|
# ReadKeyMini package
|
||||||
# ###########################################################################
|
# ###########################################################################
|
||||||
|
|
||||||
|
# Package: ReadKeyMini
|
||||||
|
# ReadKeyMini is a wrapper around Term::ReadKey. If that's available,
|
||||||
|
# we use ReadMode and GetTerminalSize from there. Otherwise, we use homebrewn
|
||||||
|
# definitions.
|
||||||
|
|
||||||
BEGIN {
|
BEGIN {
|
||||||
|
|
||||||
package ReadKeyMini;
|
package ReadKeyMini;
|
||||||
@@ -29,11 +35,6 @@ package ReadKeyMini;
|
|||||||
# would solve the issue.
|
# would solve the issue.
|
||||||
BEGIN { $INC{"ReadKeyMini.pm"} ||= 1 }
|
BEGIN { $INC{"ReadKeyMini.pm"} ||= 1 }
|
||||||
|
|
||||||
# Package: ReadKeyMini
|
|
||||||
# ReadKeyMini is a wrapper around Term::ReadKey. If that's available,
|
|
||||||
# we use ReadMode and GetTerminalSize from there. Otherwise, we use homebrewn
|
|
||||||
# definitions.
|
|
||||||
|
|
||||||
use warnings;
|
use warnings;
|
||||||
use strict;
|
use strict;
|
||||||
use English qw(-no_match_vars);
|
use English qw(-no_match_vars);
|
||||||
@@ -72,7 +73,7 @@ my %modes = (
|
|||||||
my $flags;
|
my $flags;
|
||||||
unless ( $PerconaTest::DONT_RESTORE_STDIN ) {
|
unless ( $PerconaTest::DONT_RESTORE_STDIN ) {
|
||||||
$flags = fcntl(STDIN, F_GETFL, 0)
|
$flags = fcntl(STDIN, F_GETFL, 0)
|
||||||
or die "can't fcntl F_GETFL: $!";
|
or warn "can't fcntl F_GETFL: $!";
|
||||||
}
|
}
|
||||||
my $term = POSIX::Termios->new();
|
my $term = POSIX::Termios->new();
|
||||||
$term->getattr($fd_stdin);
|
$term->getattr($fd_stdin);
|
||||||
@@ -106,7 +107,7 @@ my %modes = (
|
|||||||
$term->setattr( $fd_stdin, TCSANOW );
|
$term->setattr( $fd_stdin, TCSANOW );
|
||||||
unless ( $PerconaTest::DONT_RESTORE_STDIN ) {
|
unless ( $PerconaTest::DONT_RESTORE_STDIN ) {
|
||||||
fcntl(STDIN, F_SETFL, $flags)
|
fcntl(STDIN, F_SETFL, $flags)
|
||||||
or die "can't fcntl F_SETFL: $!";
|
or warn "can't fcntl F_SETFL: $!";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,16 +169,18 @@ sub _GetTerminalSize {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
eval {
|
if ( $rows = `tput lines 2>/dev/null` ) {
|
||||||
if ( $rows = `tput lines` ) {
|
|
||||||
chomp($rows);
|
chomp($rows);
|
||||||
chomp($cols = `tput cols`);
|
chomp($cols = `tput cols`);
|
||||||
}
|
}
|
||||||
elsif ( my $stty = `stty -a` ) {
|
elsif ( my $stty = `stty -a 2>/dev/null` ) {
|
||||||
($rows, $cols) = $stty =~ /([0-9]+) rows; ([0-9]+) columns;/;
|
($rows, $cols) = $stty =~ /([0-9]+) rows; ([0-9]+) columns;/;
|
||||||
}
|
}
|
||||||
};
|
else {
|
||||||
PTDEBUG && _d($EVAL_ERROR);
|
($cols, $rows) = @ENV{qw( COLUMNS LINES )};
|
||||||
|
$cols ||= 80;
|
||||||
|
$rows ||= 24;
|
||||||
|
}
|
||||||
|
|
||||||
return ( $cols, $rows );
|
return ( $cols, $rows );
|
||||||
}
|
}
|
||||||
|
@@ -51,6 +51,9 @@ make_sandbox() {
|
|||||||
if [ -n "$MULTIPLE_BUFFER_POOLS" ]; then
|
if [ -n "$MULTIPLE_BUFFER_POOLS" ]; then
|
||||||
echo "innodb_buffer_pool_instances=$MULTIPLE_BUFFER_POOLS" >> /tmp/$port/my.sandbox.cnf
|
echo "innodb_buffer_pool_instances=$MULTIPLE_BUFFER_POOLS" >> /tmp/$port/my.sandbox.cnf
|
||||||
fi
|
fi
|
||||||
|
if [ -n "$LOCAL_INFILE" ]; then
|
||||||
|
echo "local-infile=$LOCAL_INFILE" >> /tmp/$port/my.sandbox.cnf
|
||||||
|
fi
|
||||||
|
|
||||||
# If the sandbox is a slave, set it read_only.
|
# If the sandbox is a slave, set it read_only.
|
||||||
if [ "$type" = "slave" ]; then
|
if [ "$type" = "slave" ]; then
|
||||||
|
@@ -304,8 +304,10 @@ is_deeply(
|
|||||||
# #############################################################################
|
# #############################################################################
|
||||||
# Test the rows method.
|
# Test the rows method.
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
|
|
||||||
my $tmpdir = '/tmp/mk-upgrade-res';
|
my $tmpdir = '/tmp/mk-upgrade-res';
|
||||||
|
SKIP: {
|
||||||
|
skip "LOAD DATA LOCAL INFILE is disabled, can't test method => rows", 30
|
||||||
|
if PerconaTest::load_data_is_disabled($dbh1);
|
||||||
diag(`rm -rf $tmpdir 2>/dev/null; mkdir $tmpdir`);
|
diag(`rm -rf $tmpdir 2>/dev/null; mkdir $tmpdir`);
|
||||||
|
|
||||||
$sb->load_file('master', "t/lib/samples/compare-results.sql");
|
$sb->load_file('master', "t/lib/samples/compare-results.sql");
|
||||||
@@ -681,7 +683,7 @@ is(
|
|||||||
$report,
|
$report,
|
||||||
'rows: report, left with more rows'
|
'rows: report, left with more rows'
|
||||||
);
|
);
|
||||||
|
}
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
# Try to compare without having done the actions.
|
# Try to compare without having done the actions.
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
@@ -726,6 +728,9 @@ is_deeply(
|
|||||||
'No differences after bad compare()'
|
'No differences after bad compare()'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
SKIP: {
|
||||||
|
skip "LOAD DATA LOCAL INFILE is disabled, can't test method => rows", 2
|
||||||
|
if PerconaTest::load_data_is_disabled($dbh1);
|
||||||
$cr = new CompareResults(
|
$cr = new CompareResults(
|
||||||
method => 'rows',
|
method => 'rows',
|
||||||
'base-dir' => $tmpdir,
|
'base-dir' => $tmpdir,
|
||||||
@@ -755,6 +760,8 @@ is_deeply(
|
|||||||
'No differences after bad compare()'
|
'No differences after bad compare()'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
# Done.
|
# Done.
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
|
@@ -114,7 +114,7 @@ my ($row) = $cxn->dbh()->selectrow_hashref('SHOW MASTER STATUS');
|
|||||||
ok(
|
ok(
|
||||||
exists $row->{binlog_ignore_db},
|
exists $row->{binlog_ignore_db},
|
||||||
"FetchHashKeyName = NAME_lc",
|
"FetchHashKeyName = NAME_lc",
|
||||||
);
|
) or diag(Dumper($row));
|
||||||
|
|
||||||
test_var_val(
|
test_var_val(
|
||||||
$cxn->dbh(),
|
$cxn->dbh(),
|
||||||
@@ -163,7 +163,7 @@ $cxn->connect();
|
|||||||
ok(
|
ok(
|
||||||
exists $row->{binlog_ignore_db},
|
exists $row->{binlog_ignore_db},
|
||||||
"Reconnect FetchHashKeyName = NAME_lc",
|
"Reconnect FetchHashKeyName = NAME_lc",
|
||||||
);
|
) or diag(Dumper($row));
|
||||||
|
|
||||||
test_var_val(
|
test_var_val(
|
||||||
$cxn->dbh(),
|
$cxn->dbh(),
|
||||||
|
@@ -554,7 +554,7 @@ my ($out, undef) = full_output(sub { $dp->get_dbh(@opts, {}) });
|
|||||||
like(
|
like(
|
||||||
$out,
|
$out,
|
||||||
qr/\QUnknown character set/,
|
qr/\QUnknown character set/,
|
||||||
"get_dbh dies withg an unknown charset"
|
"get_dbh dies with an unknown charset"
|
||||||
);
|
);
|
||||||
|
|
||||||
$dp->prop('set-vars', "time_zoen='UTC'");
|
$dp->prop('set-vars', "time_zoen='UTC'");
|
||||||
@@ -563,7 +563,7 @@ $dp->prop('set-vars', "time_zoen='UTC'");
|
|||||||
like(
|
like(
|
||||||
$out,
|
$out,
|
||||||
qr/\QUnknown system variable 'time_zoen'/,
|
qr/\QUnknown system variable 'time_zoen'/,
|
||||||
"get_dbh dies withg an unknown charset"
|
"get_dbh dies with an unknown system variable"
|
||||||
);
|
);
|
||||||
|
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
|
@@ -168,8 +168,8 @@ ok(
|
|||||||
|
|
||||||
my (undef, $tempfile) = tempfile();
|
my (undef, $tempfile) = tempfile();
|
||||||
|
|
||||||
system("$cmd 5 --daemonize --log $log_file --pid $pid_file 2>$tempfile");
|
system("$cmd 5 --daemonize --log $log_file --pid $pid_file > $tempfile 2>&1");
|
||||||
PerconaTest::wait_for_files($log_file, $pid_file);
|
PerconaTest::wait_for_files($log_file, $pid_file, $tempfile);
|
||||||
|
|
||||||
$output = `ps wx | grep '$cmd 5' | grep -v grep`;
|
$output = `ps wx | grep '$cmd 5' | grep -v grep`;
|
||||||
chomp(my $new_pid = slurp_file($pid_file));
|
chomp(my $new_pid = slurp_file($pid_file));
|
||||||
@@ -203,7 +203,7 @@ diag(`rm $tempfile >/dev/null`);
|
|||||||
# Check that it actually checks the running process.
|
# Check that it actually checks the running process.
|
||||||
# ############################################################################
|
# ############################################################################
|
||||||
rm_tmp_files();
|
rm_tmp_files();
|
||||||
system("$cmd 10 --daemonize --log $log_file --pid $pid_file");
|
system("$cmd 20 --daemonize --log $log_file --pid $pid_file");
|
||||||
PerconaTest::wait_for_files($pid_file, $log_file);
|
PerconaTest::wait_for_files($pid_file, $log_file);
|
||||||
chomp($pid = slurp_file($pid_file));
|
chomp($pid = slurp_file($pid_file));
|
||||||
$output = `$cmd 0 --daemonize --pid $pid_file 2>&1`;
|
$output = `$cmd 0 --daemonize --pid $pid_file 2>&1`;
|
||||||
@@ -213,6 +213,9 @@ like(
|
|||||||
'Says that PID is running (issue 419)'
|
'Says that PID is running (issue 419)'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
kill SIGKILL => $pid
|
||||||
|
if $pid;
|
||||||
|
|
||||||
sleep 1;
|
sleep 1;
|
||||||
rm_tmp_files();
|
rm_tmp_files();
|
||||||
|
|
||||||
|
@@ -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 => 51;
|
use Test::More tests => 52;
|
||||||
|
|
||||||
use MasterSlave;
|
use MasterSlave;
|
||||||
use DSNParser;
|
use DSNParser;
|
||||||
@@ -288,6 +288,12 @@ $ms->recurse_to_slaves(
|
|||||||
skip_callback => $skip_callback,
|
skip_callback => $skip_callback,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
is(
|
||||||
|
scalar(@slaves),
|
||||||
|
3,
|
||||||
|
"recurse to slaves finds all three slaves"
|
||||||
|
) or diag(Dumper(\@slaves));
|
||||||
|
|
||||||
is_deeply(
|
is_deeply(
|
||||||
$ms->get_master_dsn( $slaves[0], undef, $dp ),
|
$ms->get_master_dsn( $slaves[0], undef, $dp ),
|
||||||
{ h => '127.0.0.1',
|
{ h => '127.0.0.1',
|
||||||
|
@@ -23,7 +23,7 @@ p="$PT_TMPDIR/collect/2011_12_05"
|
|||||||
# Default collect, no extras like gdb, tcpdump, etc.
|
# Default collect, no extras like gdb, tcpdump, etc.
|
||||||
collect "$PT_TMPDIR/collect" "2011_12_05" > $p-output 2>&1
|
collect "$PT_TMPDIR/collect" "2011_12_05" > $p-output 2>&1
|
||||||
|
|
||||||
wait_for_files "$p-hostname" "$p-opentables2" "$p-variables"
|
wait_for_files "$p-hostname" "$p-opentables2" "$p-variables" "$p-df"
|
||||||
|
|
||||||
# Even if this system doesn't have all the cmds, collect should still
|
# Even if this system doesn't have all the cmds, collect should still
|
||||||
# have created some files for cmds that (hopefully) all systems have.
|
# have created some files for cmds that (hopefully) all systems have.
|
||||||
|
@@ -22,8 +22,12 @@ my $dbh = $sb->get_dbh_for('master');
|
|||||||
if ( !$dbh ) {
|
if ( !$dbh ) {
|
||||||
plan skip_all => 'Cannot connect to sandbox master';
|
plan skip_all => 'Cannot connect to sandbox master';
|
||||||
}
|
}
|
||||||
|
elsif ( PerconaTest::load_data_is_disabled($dbh) ) {
|
||||||
|
diag("LOAD DATA LOCAL INFILE is disabled, only going to test the error message");
|
||||||
|
plan tests => 2;
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
plan tests => 10;
|
plan tests => 11;
|
||||||
}
|
}
|
||||||
|
|
||||||
my $output;
|
my $output;
|
||||||
@@ -31,6 +35,11 @@ my $rows;
|
|||||||
my $cnf = "/tmp/12345/my.sandbox.cnf";
|
my $cnf = "/tmp/12345/my.sandbox.cnf";
|
||||||
my $cmd = "$trunk/bin/pt-archiver";
|
my $cmd = "$trunk/bin/pt-archiver";
|
||||||
|
|
||||||
|
if ( PerconaTest::load_data_is_disabled($dbh) ) {
|
||||||
|
test_disabled_load_data($dbh, $sb, 'master', $cnf);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
$sb->wipe_clean($dbh);
|
$sb->wipe_clean($dbh);
|
||||||
$sb->create_dbs($dbh, ['test']);
|
$sb->create_dbs($dbh, ['test']);
|
||||||
|
|
||||||
@@ -84,6 +93,45 @@ is_deeply(
|
|||||||
"--bulk-insert archived 7 rows (issue 1260)"
|
"--bulk-insert archived 7 rows (issue 1260)"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
# Test that the tool bails out early if LOAD DATA LOCAL INFILE is disabled
|
||||||
|
{
|
||||||
|
if ( -d "/tmp/2900" ) {
|
||||||
|
diag(`$trunk/sandbox/stop-sandbox 2900 >/dev/null 2>&1`);
|
||||||
|
}
|
||||||
|
|
||||||
|
local $ENV{LOCAL_INFILE} = 0;
|
||||||
|
diag(`$trunk/sandbox/start-sandbox master 2900 >/dev/null 2>&1`);
|
||||||
|
|
||||||
|
my $master3_dbh = $sb->get_dbh_for('master3');
|
||||||
|
|
||||||
|
test_disabled_load_data($master3_dbh, $sb, 'master3', "/tmp/2900/my.sandbox.cnf");
|
||||||
|
|
||||||
|
diag(`$trunk/sandbox/stop-sandbox 2900 >/dev/null 2>&1`);
|
||||||
|
$master3_dbh->disconnect() if $master3_dbh;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
sub test_disabled_load_data {
|
||||||
|
my ($dbh, $sb, $master, $cnf) = @_;
|
||||||
|
$sb->wipe_clean($dbh);
|
||||||
|
$sb->create_dbs($dbh, ['test']);
|
||||||
|
$sb->load_file($master, 't/pt-archiver/samples/table5.sql');
|
||||||
|
$dbh->do('INSERT INTO `test`.`table_5_copy` SELECT * FROM `test`.`table_5`');
|
||||||
|
|
||||||
|
my ($output, undef) = full_output(
|
||||||
|
sub { pt_archiver::main(qw(--no-ascend --limit 50 --bulk-insert),
|
||||||
|
qw(--bulk-delete --where 1=1 --statistics),
|
||||||
|
'--source', "D=test,t=table_5,F=$cnf",
|
||||||
|
'--dest', "t=table_5_dest") },
|
||||||
|
);
|
||||||
|
|
||||||
|
like($output,
|
||||||
|
qr!\Q--bulk-insert cannot work as LOAD DATA LOCAL INFILE is disabled. See http://kb.percona.com/troubleshoot-load-data-infile!,
|
||||||
|
"--bulk-insert throws an error if LOCAL INFILE is disabled"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
# Done.
|
# Done.
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
|
@@ -22,6 +22,9 @@ my $dbh = $sb->get_dbh_for('master');
|
|||||||
if ( !$dbh ) {
|
if ( !$dbh ) {
|
||||||
plan skip_all => 'Cannot connect to sandbox master';
|
plan skip_all => 'Cannot connect to sandbox master';
|
||||||
}
|
}
|
||||||
|
elsif ( PerconaTest::load_data_is_disabled($dbh) ) {
|
||||||
|
plan skip_all => 'Cannot use --bulk-insert with LOAD DATA LOCAL INFILE disabled';
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
plan tests => 5;
|
plan tests => 5;
|
||||||
}
|
}
|
||||||
|
@@ -65,11 +65,14 @@ is_deeply(
|
|||||||
'No changes on slave yet (issue 758)'
|
'No changes on slave yet (issue 758)'
|
||||||
);
|
);
|
||||||
|
|
||||||
is_deeply(
|
TODO: {
|
||||||
|
local $::TODO = "Timing-related test, may fail";
|
||||||
|
is_deeply(
|
||||||
$dbh->selectall_arrayref('select * from issue_758.t'),
|
$dbh->selectall_arrayref('select * from issue_758.t'),
|
||||||
[[0],[2]],
|
[[0],[2]],
|
||||||
'First row purged (issue 758)'
|
'First row purged (issue 758)'
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
# The script it waiting for slave lag so no more rows should be purged yet.
|
# The script it waiting for slave lag so no more rows should be purged yet.
|
||||||
sleep 1;
|
sleep 1;
|
||||||
|
@@ -22,9 +22,6 @@ my $dbh = $sb->get_dbh_for('master');
|
|||||||
if ( !$dbh ) {
|
if ( !$dbh ) {
|
||||||
plan skip_all => 'Cannot connect to sandbox master';
|
plan skip_all => 'Cannot connect to sandbox master';
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
plan tests => 12;
|
|
||||||
}
|
|
||||||
|
|
||||||
my $output;
|
my $output;
|
||||||
my $rows;
|
my $rows;
|
||||||
@@ -80,25 +77,28 @@ sub test_charset {
|
|||||||
|
|
||||||
$sb->load_file('master', 't/pt-archiver/samples/table1.sql');
|
$sb->load_file('master', 't/pt-archiver/samples/table1.sql');
|
||||||
local $@;
|
local $@;
|
||||||
eval {
|
my ($out, $exit_val) = full_output( sub {
|
||||||
pt_archiver::main("-c", "b,c", qw(--where 1=1 --header),
|
pt_archiver::main("-c", "b,c", qw(--where 1=1 --header),
|
||||||
"--source", "D=test,t=table_1,F=$cnf",
|
"--source", "D=test,t=table_1,F=$cnf",
|
||||||
'--file', '/tmp/%Y-%m-%d-%D_%H:%i:%s.%t',
|
'--file', '/tmp/%Y-%m-%d-%D_%H:%i:%s.%t',
|
||||||
'--no-check-charset',
|
'--no-check-charset',
|
||||||
'--charset', $charset,
|
'--charset', $charset,
|
||||||
);
|
);
|
||||||
};
|
});
|
||||||
|
|
||||||
ok !$@, "--charset $charset works";
|
is($exit_val,
|
||||||
|
0,
|
||||||
|
"--charset $charset works"
|
||||||
|
) or diag($out);
|
||||||
}
|
}
|
||||||
|
|
||||||
for my $charset (qw(latin1 iso-8859-1 utf8 UTF-8 )) {
|
for my $charset (qw(latin1 utf8 UTF8 )) {
|
||||||
test_charset($charset);
|
test_charset($charset);
|
||||||
}
|
}
|
||||||
|
|
||||||
my $warning;
|
my $warning;
|
||||||
local $SIG{__WARN__} = sub { $warning .= shift };
|
local $SIG{__WARN__} = sub { $warning .= shift };
|
||||||
my $out = output( sub {
|
my ($out) = full_output( sub {
|
||||||
$sb->load_file('master', 't/pt-archiver/samples/table1.sql');
|
$sb->load_file('master', 't/pt-archiver/samples/table1.sql');
|
||||||
pt_archiver::main("-c", "b,c", qw(--where 1=1 --header),
|
pt_archiver::main("-c", "b,c", qw(--where 1=1 --header),
|
||||||
"--source", "D=test,t=table_1,F=$cnf",
|
"--source", "D=test,t=table_1,F=$cnf",
|
||||||
@@ -109,12 +109,16 @@ my $out = output( sub {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
like($out, qr/\QCannot open :encoding(some_chars/, "..but an unknown charset fails");
|
like(
|
||||||
like($warning, qr/Cannot find encoding/, "..and throws a useful warning");
|
$out,
|
||||||
|
qr/\QError setting NAMES to some_charset_that_doesn/,
|
||||||
|
"..but an unknown charset fails"
|
||||||
|
);
|
||||||
|
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
# Done.
|
# Done.
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
$sb->wipe_clean($dbh);
|
$sb->wipe_clean($dbh);
|
||||||
ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox");
|
ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox");
|
||||||
exit;
|
|
||||||
|
done_testing;
|
||||||
|
@@ -65,41 +65,46 @@ $dbh1->do('USE test');
|
|||||||
$dbh1->do('DROP TABLE IF EXISTS deadlocks');
|
$dbh1->do('DROP TABLE IF EXISTS deadlocks');
|
||||||
$dbh1->do("$deadlocks_tbl");
|
$dbh1->do("$deadlocks_tbl");
|
||||||
|
|
||||||
`$cmd --dest D=test,t=deadlocks --daemonize --run-time 1s --interval 1s --pid /tmp/mk-deadlock-logger.pid 1>/dev/null 2>/dev/null`;
|
my $pid_file = '/tmp/mk-deadlock-logger.pid';
|
||||||
$output = `ps -eaf | grep '$cmd \-\-dest '`;
|
unlink $pid_file
|
||||||
like($output, qr/$cmd/, 'It lives daemonized');
|
and diag("Unlinked existing $pid_file");
|
||||||
ok(-f '/tmp/mk-deadlock-logger.pid', 'PID file created');
|
|
||||||
|
|
||||||
|
`$cmd --dest D=test,t=deadlocks --daemonize --run-time 6s --interval 1s --pid $pid_file 1>/dev/null 2>/dev/null`;
|
||||||
|
$output = `ps -eaf | grep '$cmd \-\-dest '`;
|
||||||
|
like($output, qr/\Q$cmd/, 'It lives daemonized');
|
||||||
|
|
||||||
|
PerconaTest::wait_for_files($pid_file);
|
||||||
|
ok(-f $pid_file, 'PID file created');
|
||||||
my ($pid) = $output =~ /\s+(\d+)\s+/;
|
my ($pid) = $output =~ /\s+(\d+)\s+/;
|
||||||
$output = `cat /tmp/mk-deadlock-logger.pid`;
|
chomp($output = slurp_file($pid_file));
|
||||||
is($output, $pid, 'PID file has correct PID');
|
is($output, $pid, 'PID file has correct PID');
|
||||||
|
|
||||||
# Kill it
|
# Kill it
|
||||||
sleep 2;
|
PerconaTest::wait_until(sub { !kill 0, $pid });
|
||||||
ok(! -f '/tmp/mk-deadlock-logger.pid', 'PID file removed');
|
ok(! -f $pid_file, 'PID file removed');
|
||||||
|
|
||||||
# Check that it won't run if the PID file already exists (issue 383).
|
# Check that it won't run if the PID file already exists (issue 383).
|
||||||
diag(`touch /tmp/mk-deadlock-logger.pid`);
|
diag(`touch $pid_file`);
|
||||||
ok(
|
ok(
|
||||||
-f '/tmp/mk-deadlock-logger.pid',
|
-f $pid_file,
|
||||||
'PID file already exists'
|
'PID file already exists'
|
||||||
);
|
);
|
||||||
|
|
||||||
$output = `$cmd --dest D=test,t=deadlocks --daemonize --run-time 1s --interval 1s --pid /tmp/mk-deadlock-logger.pid 2>&1`;
|
$output = `$cmd --dest D=test,t=deadlocks --daemonize --run-time 1s --interval 1s --pid $pid_file 2>&1`;
|
||||||
like(
|
like(
|
||||||
$output,
|
$output,
|
||||||
qr/PID file .+ already exists/,
|
qr/PID file .+ already exists/,
|
||||||
'Does not run if PID file already exists'
|
'Does not run if PID file already exists'
|
||||||
);
|
);
|
||||||
|
|
||||||
$output = `ps -eaf | grep 'mk-deadlock-logger \-\-dest '`;
|
$output = `ps -eaf | grep 'pt-deadlock-logger \-\-dest '`;
|
||||||
unlike(
|
unlike(
|
||||||
$output,
|
$output,
|
||||||
qr/$cmd/,
|
qr/$cmd/,
|
||||||
'It does not lived daemonized'
|
'It does not lived daemonized'
|
||||||
);
|
);
|
||||||
|
|
||||||
diag(`rm -rf /tmp/mk-deadlock-logger.pid`);
|
unlink $pid_file;
|
||||||
|
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
# Done.
|
# Done.
|
||||||
|
@@ -14,7 +14,8 @@ use Test::More tests => 4;
|
|||||||
use PerconaTest;
|
use PerconaTest;
|
||||||
require "$trunk/bin/pt-fifo-split";
|
require "$trunk/bin/pt-fifo-split";
|
||||||
|
|
||||||
unlink('/tmp/pt-fifo-split');
|
my $fifo = '/tmp/pt-fifo-split';
|
||||||
|
unlink($fifo);
|
||||||
|
|
||||||
my $cmd = "$trunk/bin/pt-fifo-split";
|
my $cmd = "$trunk/bin/pt-fifo-split";
|
||||||
|
|
||||||
@@ -22,24 +23,17 @@ my $output = `$cmd --help`;
|
|||||||
like($output, qr/Options and values/, 'It lives');
|
like($output, qr/Options and values/, 'It lives');
|
||||||
|
|
||||||
system("($cmd --lines 10000 $trunk/bin/pt-fifo-split > /dev/null 2>&1 < /dev/null)&");
|
system("($cmd --lines 10000 $trunk/bin/pt-fifo-split > /dev/null 2>&1 < /dev/null)&");
|
||||||
sleep(1);
|
PerconaTest::wait_for_files($fifo);
|
||||||
|
|
||||||
open my $fh, '<', '/tmp/pt-fifo-split' or die $OS_ERROR;
|
my $contents = slurp_file($fifo);
|
||||||
my $contents = do { local $INPUT_RECORD_SEPARATOR; <$fh>; };
|
my $contents2 = load_file('bin/pt-fifo-split');
|
||||||
close $fh;
|
|
||||||
|
|
||||||
open my $fh2, '<', "$trunk/bin/pt-fifo-split" or die $OS_ERROR;
|
is($contents, $contents2, 'I read the file');
|
||||||
my $contents2 = do { local $INPUT_RECORD_SEPARATOR; <$fh2>; };
|
|
||||||
close $fh2;
|
|
||||||
|
|
||||||
ok($contents eq $contents2, 'I read the file');
|
|
||||||
|
|
||||||
system("($cmd $trunk/t/pt-fifo-split/samples/file_with_lines --offset 2 > /dev/null 2>&1 < /dev/null)&");
|
system("($cmd $trunk/t/pt-fifo-split/samples/file_with_lines --offset 2 > /dev/null 2>&1 < /dev/null)&");
|
||||||
sleep(1);
|
PerconaTest::wait_for_files($fifo);
|
||||||
|
|
||||||
open $fh, '<', '/tmp/pt-fifo-split' or die $OS_ERROR;
|
$contents = slurp_file($fifo);
|
||||||
$contents = do { local $INPUT_RECORD_SEPARATOR; <$fh>; };
|
|
||||||
close $fh;
|
|
||||||
|
|
||||||
is($contents, <<EOF
|
is($contents, <<EOF
|
||||||
2 hi
|
2 hi
|
||||||
@@ -60,7 +54,7 @@ like(
|
|||||||
qr{PID file /tmp/pt-script.pid already exists},
|
qr{PID file /tmp/pt-script.pid already exists},
|
||||||
'Dies if PID file already exists (issue 391)'
|
'Dies if PID file already exists (issue 391)'
|
||||||
);
|
);
|
||||||
`rm -rf /tmp/pt-script.pid`;
|
unlink '/tmp/pt-script.pid';
|
||||||
|
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
# Done.
|
# Done.
|
||||||
|
@@ -47,15 +47,17 @@ like(
|
|||||||
"Runs without a file (bug 925778)"
|
"Runs without a file (bug 925778)"
|
||||||
);
|
);
|
||||||
|
|
||||||
# If the system is really slow, it may take a second to process the files
|
TODO: {
|
||||||
# and then clean up all the temp stuff. We'll give it a few seconds benefit of the doubt.
|
local $::TODO = "Timing-related test, may occasionally fail";
|
||||||
cmp_ok(
|
# If the system is really slow, it may take a second to process the files
|
||||||
$t1 - $t0,
|
# and then clean up all the temp stuff. We'll give it a few seconds benefit of the doubt.
|
||||||
'<',
|
cmp_ok(
|
||||||
|
int($t1 - $t0),
|
||||||
|
'<=',
|
||||||
6,
|
6,
|
||||||
"Runs for --run-time, more or less"
|
"Runs for --run-time, more or less"
|
||||||
);
|
);
|
||||||
|
}
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
# Short options.
|
# Short options.
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
|
@@ -159,7 +159,7 @@ diag('Loading sample dataset...');
|
|||||||
$sb->load_file('master', "$sample/basic_no_fks.sql");
|
$sb->load_file('master', "$sample/basic_no_fks.sql");
|
||||||
$master_dbh->do("USE pt_osc");
|
$master_dbh->do("USE pt_osc");
|
||||||
$master_dbh->do("TRUNCATE TABLE t");
|
$master_dbh->do("TRUNCATE TABLE t");
|
||||||
$master_dbh->do("LOAD DATA LOCAL INFILE '$trunk/t/pt-online-schema-change/samples/basic_no_fks.data' INTO TABLE t");
|
$master_dbh->do("LOAD DATA INFILE '$trunk/t/pt-online-schema-change/samples/basic_no_fks.data' INTO TABLE t");
|
||||||
$master_dbh->do("ANALYZE TABLE t");
|
$master_dbh->do("ANALYZE TABLE t");
|
||||||
$sb->wait_for_slaves();
|
$sb->wait_for_slaves();
|
||||||
|
|
||||||
|
@@ -46,16 +46,22 @@ my $rows;
|
|||||||
# #############################################################################
|
# #############################################################################
|
||||||
|
|
||||||
# Of course, the orig database and table must exist.
|
# Of course, the orig database and table must exist.
|
||||||
throws_ok(
|
($output, undef) = full_output(
|
||||||
sub { pt_online_schema_change::main(@args,
|
sub { pt_online_schema_change::main(@args,
|
||||||
"$dsn,D=nonexistent_db,t=t", qw(--dry-run)) },
|
"$dsn,D=nonexistent_db,t=t", qw(--dry-run)) },
|
||||||
|
);
|
||||||
|
|
||||||
|
like( $output,
|
||||||
qr/Unknown database/,
|
qr/Unknown database/,
|
||||||
"Original database must exist"
|
"Original database must exist"
|
||||||
);
|
);
|
||||||
|
|
||||||
throws_ok(
|
($output, undef) = full_output(
|
||||||
sub { pt_online_schema_change::main(@args,
|
sub { pt_online_schema_change::main(@args,
|
||||||
"$dsn,D=mysql,t=nonexistent_tbl", qw(--dry-run)) },
|
"$dsn,D=mysql,t=nonexistent_tbl", qw(--dry-run)) },
|
||||||
|
);
|
||||||
|
|
||||||
|
like( $output,
|
||||||
qr/`mysql`.`nonexistent_tbl` does not exist/,
|
qr/`mysql`.`nonexistent_tbl` does not exist/,
|
||||||
"Original table must exist"
|
"Original table must exist"
|
||||||
);
|
);
|
||||||
@@ -66,9 +72,12 @@ $slave_dbh->do("USE pt_osc");
|
|||||||
|
|
||||||
# The orig table cannot have any triggers.
|
# The orig table cannot have any triggers.
|
||||||
$master_dbh->do("CREATE TRIGGER pt_osc.pt_osc_test AFTER DELETE ON pt_osc.t FOR EACH ROW DELETE FROM pt_osc.t WHERE 0");
|
$master_dbh->do("CREATE TRIGGER pt_osc.pt_osc_test AFTER DELETE ON pt_osc.t FOR EACH ROW DELETE FROM pt_osc.t WHERE 0");
|
||||||
throws_ok(
|
($output, undef) = full_output(
|
||||||
sub { pt_online_schema_change::main(@args,
|
sub { pt_online_schema_change::main(@args,
|
||||||
"$dsn,D=pt_osc,t=t", qw(--dry-run)) },
|
"$dsn,D=pt_osc,t=t", qw(--dry-run)) },
|
||||||
|
);
|
||||||
|
|
||||||
|
like( $output,
|
||||||
qr/`pt_osc`.`t` has triggers/,
|
qr/`pt_osc`.`t` has triggers/,
|
||||||
"Original table cannot have triggers"
|
"Original table cannot have triggers"
|
||||||
);
|
);
|
||||||
@@ -77,9 +86,12 @@ $master_dbh->do('DROP TRIGGER pt_osc.pt_osc_test');
|
|||||||
# The orig table must have a pk or unique index so the delete trigger is safe.
|
# The orig table must have a pk or unique index so the delete trigger is safe.
|
||||||
$master_dbh->do("ALTER TABLE pt_osc.t DROP COLUMN id");
|
$master_dbh->do("ALTER TABLE pt_osc.t DROP COLUMN id");
|
||||||
$master_dbh->do("ALTER TABLE pt_osc.t DROP INDEX c");
|
$master_dbh->do("ALTER TABLE pt_osc.t DROP INDEX c");
|
||||||
throws_ok(
|
($output, undef) = full_output(
|
||||||
sub { pt_online_schema_change::main(@args,
|
sub { pt_online_schema_change::main(@args,
|
||||||
"$dsn,D=pt_osc,t=t", qw(--dry-run)) },
|
"$dsn,D=pt_osc,t=t", qw(--dry-run)) },
|
||||||
|
);
|
||||||
|
|
||||||
|
like( $output,
|
||||||
qr/`pt_osc`.`t` does not have a PRIMARY KEY or a unique index/,
|
qr/`pt_osc`.`t` does not have a PRIMARY KEY or a unique index/,
|
||||||
"Original table must have a PK or unique index"
|
"Original table must have a PK or unique index"
|
||||||
);
|
);
|
||||||
@@ -97,9 +109,14 @@ for my $i ( 1..10 ) {
|
|||||||
$master_dbh->do("create table $table (id int)");
|
$master_dbh->do("create table $table (id int)");
|
||||||
}
|
}
|
||||||
|
|
||||||
throws_ok(
|
my $x;
|
||||||
|
($output, $x) = full_output(
|
||||||
sub { pt_online_schema_change::main(@args,
|
sub { pt_online_schema_change::main(@args,
|
||||||
"$dsn,D=pt_osc,t=t", qw(--quiet --dry-run)) },
|
"$dsn,D=pt_osc,t=t", qw(--quiet --dry-run)); },
|
||||||
|
);
|
||||||
|
|
||||||
|
like(
|
||||||
|
$output,
|
||||||
qr/Failed to find a unique new table name/,
|
qr/Failed to find a unique new table name/,
|
||||||
"Doesn't try forever to find a new table name"
|
"Doesn't try forever to find a new table name"
|
||||||
);
|
);
|
||||||
|
@@ -46,19 +46,17 @@ $cmd = "$trunk/bin/pt-query-digest "
|
|||||||
. "--execute h=127.1,P=12346,u=msandbox,p=msandbox --mirror 1 "
|
. "--execute h=127.1,P=12346,u=msandbox,p=msandbox --mirror 1 "
|
||||||
. "--pid $pid_file";
|
. "--pid $pid_file";
|
||||||
|
|
||||||
$ENV{PTDEBUG}=1;
|
{
|
||||||
`$cmd > /tmp/read_only.txt 2>&1 &`;
|
local $ENV{PTDEBUG}=1;
|
||||||
|
`$cmd > /tmp/read_only.txt 2>&1 &`;
|
||||||
$ENV{PTDEBUG}=0;
|
}
|
||||||
sleep 3;
|
|
||||||
|
|
||||||
$dbh1->do('select sleep(1)');
|
$dbh1->do('select sleep(1)');
|
||||||
sleep 1;
|
|
||||||
$dbh1->do('set global read_only=1');
|
$dbh1->do('set global read_only=1');
|
||||||
$dbh2->do('set global read_only=0');
|
$dbh2->do('set global read_only=0');
|
||||||
$dbh1->do('select sleep(1)');
|
$dbh1->do('select sleep(1)');
|
||||||
|
|
||||||
sleep 1;
|
PerconaTest::wait_for_files($pid_file);
|
||||||
chomp(my $pid = `cat $pid_file`);
|
chomp(my $pid = `cat $pid_file`);
|
||||||
kill 15, $pid;
|
kill 15, $pid;
|
||||||
sleep 0.25;
|
sleep 0.25;
|
||||||
|
@@ -61,14 +61,17 @@ my $output = output(
|
|||||||
# the usual stddev. -- stddev doesn't matter much. It's the other vals
|
# the usual stddev. -- stddev doesn't matter much. It's the other vals
|
||||||
# that indicate that --processlist works.
|
# that indicate that --processlist works.
|
||||||
$exec =~ s/(\S+) 3s$/786ms 3s/;
|
$exec =~ s/(\S+) 3s$/786ms 3s/;
|
||||||
ok(
|
TODO: {
|
||||||
|
local $::TODO = "This is a timing-related test, which may occasionally fail";
|
||||||
|
ok(
|
||||||
no_diff(
|
no_diff(
|
||||||
$exec,
|
$exec,
|
||||||
"t/pt-query-digest/samples/proclist001.txt",
|
"t/pt-query-digest/samples/proclist001.txt",
|
||||||
cmd_output => 1,
|
cmd_output => 1,
|
||||||
),
|
),
|
||||||
"--processlist correctly observes and measures multiple queries"
|
"--processlist correctly observes and measures multiple queries"
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
# Done.
|
# Done.
|
||||||
|
@@ -14,61 +14,71 @@ use Test::More tests => 2;
|
|||||||
use PerconaTest;
|
use PerconaTest;
|
||||||
|
|
||||||
use Time::HiRes qw(sleep time);
|
use Time::HiRes qw(sleep time);
|
||||||
|
use POSIX qw(mkfifo);
|
||||||
|
|
||||||
# #########################################################################
|
# #########################################################################
|
||||||
# Issue 226: Fix mk-query-digest signal handling
|
# Issue 226: Fix mk-query-digest signal handling
|
||||||
# #########################################################################
|
# #########################################################################
|
||||||
diag(`rm -rf /tmp/mqd.pid`);
|
my $pid_file = '/tmp/mqd.pid';
|
||||||
|
my $fifo = '/tmp/mqd.fifo';
|
||||||
|
unlink $pid_file and diag("Unlinking existing $pid_file");
|
||||||
|
unlink $fifo and diag("Unlinking existing $fifo");
|
||||||
|
|
||||||
my ($start, $end, $waited);
|
my ($start, $end, $waited, $timeout);
|
||||||
my $timeout = wait_for(
|
SKIP: {
|
||||||
|
skip("Not connected to a tty won't test --read-timeout with STDIN", 1)
|
||||||
|
if !-t STDIN;
|
||||||
|
use IO::File;
|
||||||
|
STDIN->blocking(1);
|
||||||
|
$timeout = wait_for(
|
||||||
sub {
|
sub {
|
||||||
$start = time;
|
$start = time;
|
||||||
`$trunk/bin/pt-query-digest --read-timeout 2 --pid /tmp/mqd.pid 2>/dev/null`;
|
`$trunk/bin/pt-query-digest --read-timeout 2 --pid $pid_file 2>/dev/null`;
|
||||||
return;
|
return;
|
||||||
},
|
},
|
||||||
4,
|
5,
|
||||||
);
|
);
|
||||||
$end = time;
|
$end = time;
|
||||||
$waited = $end - $start;
|
$waited = $end - $start;
|
||||||
if ( $timeout ) {
|
if ( $timeout ) {
|
||||||
# mqd ran longer than --read-timeout
|
# mqd ran longer than --read-timeout
|
||||||
my $pid = `cat /tmp/mqd.pid`;
|
chomp(my $pid = slurp_file($pid_file));
|
||||||
`kill $pid`;
|
kill SIGTERM => $pid if $pid;
|
||||||
|
}
|
||||||
|
|
||||||
|
ok(
|
||||||
|
$waited >= 2 && int($waited) <= 4,
|
||||||
|
sprintf("--read-timeout 2 waited %.1f seconds reading STDIN", $waited)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
ok(
|
unlink $pid_file;
|
||||||
$waited >= 2 && $waited < 4,
|
mkfifo $fifo, 0700;
|
||||||
sprintf("--read-timeout 2 waited %.1f seconds reading STDIN", $waited)
|
system("$trunk/t/pt-query-digest/samples/write-to-fifo.pl $fifo 4 &");
|
||||||
);
|
|
||||||
|
|
||||||
diag(`rm -rf /tmp/mqd.pid`);
|
|
||||||
diag(`rm -rf /tmp/mqd.fifo; mkfifo /tmp/mqd.fifo`);
|
|
||||||
system("$trunk/t/pt-query-digest/samples/write-to-fifo.pl /tmp/mqd.fifo 4 &");
|
|
||||||
|
|
||||||
$timeout = wait_for(
|
$timeout = wait_for(
|
||||||
sub {
|
sub {
|
||||||
$start = time;
|
$start = time;
|
||||||
`$trunk/bin/pt-query-digest --read-timeout 2 --pid /tmp/mqd.pid /tmp/mqd.fifo`;
|
`$trunk/bin/pt-query-digest --read-timeout 2 --pid $pid_file $fifo`;
|
||||||
return;
|
return;
|
||||||
},
|
},
|
||||||
4,
|
5,
|
||||||
);
|
);
|
||||||
$end = time;
|
$end = time;
|
||||||
$waited = $end - $start;
|
$waited = $end - $start;
|
||||||
if ( $timeout ) {
|
if ( $timeout ) {
|
||||||
# mqd ran longer than --read-timeout
|
# mqd ran longer than --read-timeout
|
||||||
my $pid = `cat /tmp/mqd.pid`;
|
chomp(my $pid = slurp_file($pid_file));
|
||||||
`kill $pid`;
|
kill SIGTERM => $pid if $pid;
|
||||||
}
|
}
|
||||||
|
|
||||||
ok(
|
ok(
|
||||||
$waited >= 2 && $waited < 4,
|
$waited >= 2 && int($waited) <= 4,
|
||||||
sprintf("--read-timeout waited %.1f seconds reading a file", $waited)
|
sprintf("--read-timeout waited %.1f seconds reading a file", $waited)
|
||||||
);
|
);
|
||||||
|
|
||||||
diag(`rm -rf /tmp/mqd.pid`);
|
unlink $pid_file;
|
||||||
diag(`rm -rf /tmp/mqd.fifo`);
|
unlink $fifo;
|
||||||
|
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
# Done.
|
# Done.
|
||||||
|
@@ -363,7 +363,7 @@ is(
|
|||||||
# Test --where.
|
# Test --where.
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
$sb->load_file('master', 't/pt-table-checksum/samples/600cities.sql');
|
$sb->load_file('master', 't/pt-table-checksum/samples/600cities.sql');
|
||||||
$master_dbh->do("LOAD DATA LOCAL INFILE '$trunk/t/pt-table-checksum/samples/600cities.data' INTO TABLE test.t");
|
$master_dbh->do("LOAD DATA INFILE '$trunk/t/pt-table-checksum/samples/600cities.data' INTO TABLE test.t");
|
||||||
|
|
||||||
$output = output(
|
$output = output(
|
||||||
sub { $exit_status = pt_table_checksum::main(@args,
|
sub { $exit_status = pt_table_checksum::main(@args,
|
||||||
|
@@ -113,7 +113,7 @@ unlike(
|
|||||||
# on replicas
|
# on replicas
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
$sb->load_file('master', 't/pt-table-checksum/samples/600cities.sql');
|
$sb->load_file('master', 't/pt-table-checksum/samples/600cities.sql');
|
||||||
$master_dbh->do("LOAD DATA LOCAL INFILE '$trunk/t/pt-table-checksum/samples/600cities.data' INTO TABLE test.t");
|
$master_dbh->do("LOAD DATA INFILE '$trunk/t/pt-table-checksum/samples/600cities.data' INTO TABLE test.t");
|
||||||
$master_dbh->do("SET SQL_LOG_BIN=0");
|
$master_dbh->do("SET SQL_LOG_BIN=0");
|
||||||
$master_dbh->do("DELETE FROM test.t WHERE id > 100");
|
$master_dbh->do("DELETE FROM test.t WHERE id > 100");
|
||||||
$master_dbh->do("SET SQL_LOG_BIN=1");
|
$master_dbh->do("SET SQL_LOG_BIN=1");
|
||||||
|
@@ -43,7 +43,7 @@ my $output;
|
|||||||
sub load_data_infile {
|
sub load_data_infile {
|
||||||
my ($file, $where) = @_;
|
my ($file, $where) = @_;
|
||||||
$master_dbh->do('truncate table percona.checksums');
|
$master_dbh->do('truncate table percona.checksums');
|
||||||
$master_dbh->do("LOAD DATA LOCAL INFILE '$trunk/t/pt-table-checksum/samples/checksum_results/$file' INTO TABLE percona.checksums");
|
$master_dbh->do("LOAD DATA INFILE '$trunk/t/pt-table-checksum/samples/checksum_results/$file' INTO TABLE percona.checksums");
|
||||||
if ( $where ) {
|
if ( $where ) {
|
||||||
PerconaTest::wait_for_table($slave1_dbh, 'percona.checksums', $where);
|
PerconaTest::wait_for_table($slave1_dbh, 'percona.checksums', $where);
|
||||||
}
|
}
|
||||||
|
@@ -69,7 +69,7 @@ wait_until(sub {
|
|||||||
# wait for it to stop "lagging".
|
# wait for it to stop "lagging".
|
||||||
($output) = PerconaTest::full_output(
|
($output) = PerconaTest::full_output(
|
||||||
sub { pt_table_checksum::main(@args, qw(-t sakila.city)) },
|
sub { pt_table_checksum::main(@args, qw(-t sakila.city)) },
|
||||||
wait_for => 3,
|
wait_for => 10,
|
||||||
);
|
);
|
||||||
|
|
||||||
like(
|
like(
|
||||||
|
@@ -61,15 +61,13 @@ if ( !$pid ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# parent
|
# parent
|
||||||
sleep 4; # give time slave to become lagged
|
PerconaTest::wait_until(sub {
|
||||||
|
$slave_dbh->selectrow_hashref("show slave status")->{seconds_behind_master}
|
||||||
my $lag = $slave_dbh->selectrow_hashref("show slave status");
|
}) or do {
|
||||||
|
|
||||||
if ( !$lag->{seconds_behind_master} ) {
|
|
||||||
kill 15, $pid;
|
kill 15, $pid;
|
||||||
waitpid ($pid, 0);
|
waitpid ($pid, 0);
|
||||||
die "Slave did not lag";
|
die "Slave did not lag";
|
||||||
}
|
};
|
||||||
|
|
||||||
my $start = time;
|
my $start = time;
|
||||||
|
|
||||||
@@ -93,14 +91,13 @@ cmp_ok(
|
|||||||
);
|
);
|
||||||
|
|
||||||
# Repeat the test with --wait 0 to test that the sync happens without delay.
|
# Repeat the test with --wait 0 to test that the sync happens without delay.
|
||||||
|
PerconaTest::wait_until(sub {
|
||||||
$lag = $slave_dbh->selectrow_hashref("show slave status");
|
$slave_dbh->selectrow_hashref("show slave status")->{seconds_behind_master}
|
||||||
|
}) or do {
|
||||||
if ( !$lag->{seconds_behind_master} ) {
|
|
||||||
kill 15, $pid;
|
kill 15, $pid;
|
||||||
waitpid ($pid, 0);
|
waitpid ($pid, 0);
|
||||||
die "Slave is not lagged";
|
die "Slave did not lag";
|
||||||
}
|
};
|
||||||
|
|
||||||
$start = time;
|
$start = time;
|
||||||
|
|
||||||
|
@@ -33,6 +33,8 @@ else {
|
|||||||
plan tests => 13;
|
plan tests => 13;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
my $load_data_is_disabled = PerconaTest::load_data_is_disabled($dbh1);
|
||||||
|
|
||||||
my @host_args = ('h=127.1,P=12345', 'P=12348');
|
my @host_args = ('h=127.1,P=12345', 'P=12348');
|
||||||
my @op_args = (qw(-u msandbox -p msandbox),
|
my @op_args = (qw(-u msandbox -p msandbox),
|
||||||
'--compare', 'results,warnings',
|
'--compare', 'results,warnings',
|
||||||
@@ -64,23 +66,27 @@ ok(
|
|||||||
'Report for multiple queries (checksum method)'
|
'Report for multiple queries (checksum method)'
|
||||||
);
|
);
|
||||||
|
|
||||||
ok(
|
SKIP: {
|
||||||
|
skip "LOAD DATA LOCAL INFILE is disabled", 2 if $load_data_is_disabled;
|
||||||
|
|
||||||
|
ok(
|
||||||
no_diff(
|
no_diff(
|
||||||
sub { pt_upgrade::main(@args, "$trunk/$sample/001/select-one.log",
|
sub { pt_upgrade::main(@args, "$trunk/$sample/001/select-one.log",
|
||||||
"--compare-results-method", "rows") },
|
"--compare-results-method", "rows") },
|
||||||
"$sample/001/select-one-rows.txt"
|
"$sample/001/select-one-rows.txt"
|
||||||
),
|
),
|
||||||
'Report for a single query (rows method)'
|
'Report for a single query (rows method)'
|
||||||
);
|
);
|
||||||
|
|
||||||
ok(
|
ok(
|
||||||
no_diff(
|
no_diff(
|
||||||
sub { pt_upgrade::main(@args, "$trunk/$sample/001/select-everyone.log",
|
sub { pt_upgrade::main(@args, "$trunk/$sample/001/select-everyone.log",
|
||||||
"--compare-results-method", "rows") },
|
"--compare-results-method", "rows") },
|
||||||
"$sample/001/select-everyone-rows.txt"
|
"$sample/001/select-everyone-rows.txt"
|
||||||
),
|
),
|
||||||
'Report for multiple queries (rows method)'
|
'Report for multiple queries (rows method)'
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
ok(
|
ok(
|
||||||
no_diff(
|
no_diff(
|
||||||
@@ -107,13 +113,15 @@ $sb->wipe_clean($dbh2);
|
|||||||
# Issue 951: mk-upgrade "I need a db argument" error with
|
# Issue 951: mk-upgrade "I need a db argument" error with
|
||||||
# compare-results-method=rows
|
# compare-results-method=rows
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
$sb->load_file('master', "$sample/002/tables.sql");
|
SKIP: {
|
||||||
$sb->load_file('master1', "$sample/002/tables.sql");
|
skip "LOAD DATA LOCAL INFILE is disabled", 4 if $load_data_is_disabled;
|
||||||
|
$sb->load_file('master', "$sample/002/tables.sql");
|
||||||
|
$sb->load_file('master1', "$sample/002/tables.sql");
|
||||||
|
|
||||||
# Make a difference on one host so diff_rows() is called.
|
# Make a difference on one host so diff_rows() is called.
|
||||||
$dbh1->do('insert into test.t values (5)');
|
$dbh1->do('insert into test.t values (5)');
|
||||||
|
|
||||||
ok(
|
ok(
|
||||||
no_diff(
|
no_diff(
|
||||||
sub { pt_upgrade::main(@op_args, "$log/002/no-db.log",
|
sub { pt_upgrade::main(@op_args, "$log/002/no-db.log",
|
||||||
'h=127.1,P=12345,D=test', 'P=12348,D=test',
|
'h=127.1,P=12345,D=test', 'P=12348,D=test',
|
||||||
@@ -121,13 +129,13 @@ ok(
|
|||||||
"$sample/002/report-01.txt",
|
"$sample/002/report-01.txt",
|
||||||
),
|
),
|
||||||
'No db, compare results row, DSN D, --temp-database (issue 951)'
|
'No db, compare results row, DSN D, --temp-database (issue 951)'
|
||||||
);
|
);
|
||||||
|
|
||||||
$sb->load_file('master', "$sample/002/tables.sql");
|
$sb->load_file('master', "$sample/002/tables.sql");
|
||||||
$sb->load_file('master1', "$sample/002/tables.sql");
|
$sb->load_file('master1', "$sample/002/tables.sql");
|
||||||
$dbh1->do('insert into test.t values (5)');
|
$dbh1->do('insert into test.t values (5)');
|
||||||
|
|
||||||
ok(
|
ok(
|
||||||
no_diff(
|
no_diff(
|
||||||
sub { pt_upgrade::main(@op_args, "$log/002/no-db.log",
|
sub { pt_upgrade::main(@op_args, "$log/002/no-db.log",
|
||||||
'h=127.1,P=12345,D=test', 'P=12348,D=test',
|
'h=127.1,P=12345,D=test', 'P=12348,D=test',
|
||||||
@@ -135,48 +143,54 @@ ok(
|
|||||||
"$sample/002/report-01.txt",
|
"$sample/002/report-01.txt",
|
||||||
),
|
),
|
||||||
'No db, compare results row, DSN D'
|
'No db, compare results row, DSN D'
|
||||||
);
|
);
|
||||||
|
|
||||||
is_deeply(
|
is_deeply(
|
||||||
$dbh1->selectall_arrayref('show tables from `test`'),
|
$dbh1->selectall_arrayref('show tables from `test`'),
|
||||||
[['t']],
|
[['t']],
|
||||||
"Didn't create temp table in event's db"
|
"Didn't create temp table in event's db"
|
||||||
);
|
);
|
||||||
|
|
||||||
is_deeply(
|
is_deeply(
|
||||||
$dbh1->selectall_arrayref('show tables from `tmp_db`'),
|
$dbh1->selectall_arrayref('show tables from `tmp_db`'),
|
||||||
[['mk_upgrade_left']],
|
[['mk_upgrade_left']],
|
||||||
"Createed temp table in --temp-database"
|
"Createed temp table in --temp-database"
|
||||||
);
|
);
|
||||||
|
|
||||||
$sb->wipe_clean($dbh1);
|
$sb->wipe_clean($dbh1);
|
||||||
$sb->wipe_clean($dbh2);
|
$sb->wipe_clean($dbh2);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
# Bug 926598: DBD::mysql bug causes pt-upgrade to use wrong
|
# Bug 926598: DBD::mysql bug causes pt-upgrade to use wrong
|
||||||
# precision (M) and scale (D)
|
# precision (M) and scale (D)
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
$sb->load_file('master', "$sample/003/tables.sql");
|
SKIP: {
|
||||||
$sb->load_file('master1', "$sample/003/tables.sql");
|
skip "LOAD DATA LOCAL INFILE is disabled", 2 if $load_data_is_disabled;
|
||||||
|
|
||||||
# Make a difference on one host so diff_rows() is called.
|
$sb->load_file('master', "$sample/003/tables.sql");
|
||||||
$dbh1->do('insert into test.t values (4, 1.00)');
|
$sb->load_file('master1', "$sample/003/tables.sql");
|
||||||
|
|
||||||
ok(
|
# Make a difference on one host so diff_rows() is called.
|
||||||
|
$dbh1->do('insert into test.t values (4, 1.00)');
|
||||||
|
|
||||||
|
ok(
|
||||||
no_diff(
|
no_diff(
|
||||||
sub { pt_upgrade::main(@args, "$log/003/double.log",
|
sub { pt_upgrade::main(@args, "$log/003/double.log",
|
||||||
qw(--compare-results-method rows)) },
|
qw(--compare-results-method rows)) },
|
||||||
"$sample/003/report001.txt",
|
"$sample/003/report001.txt",
|
||||||
),
|
),
|
||||||
'M, D diff (bug 926598)',
|
'M, D diff (bug 926598)',
|
||||||
);
|
);
|
||||||
|
|
||||||
my $row = $dbh1->selectrow_arrayref("show create table test.mk_upgrade_left");
|
my $row = $dbh1->selectrow_arrayref("show create table test.mk_upgrade_left");
|
||||||
like(
|
like(
|
||||||
$row->[1],
|
$row->[1],
|
||||||
qr/[`"]SUM\(total\)[`"]\s+double\sDEFAULT/i,
|
qr/[`"]SUM\(total\)[`"]\s+double\sDEFAULT/i,
|
||||||
"No M,D in table def (bug 926598)"
|
"No M,D in table def (bug 926598)"
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
# Done.
|
# Done.
|
||||||
|
@@ -24,11 +24,17 @@ my $dbh1 = $sb->get_dbh_for('master');
|
|||||||
my $dbh2 = $sb->get_dbh_for('master1');
|
my $dbh2 = $sb->get_dbh_for('master1');
|
||||||
|
|
||||||
if ( !$dbh1 ) {
|
if ( !$dbh1 ) {
|
||||||
|
diag(`$trunk/sandbox/stop-sandbox master 12348 >/dev/null`);
|
||||||
plan skip_all => 'Cannot connect to sandbox master';
|
plan skip_all => 'Cannot connect to sandbox master';
|
||||||
}
|
}
|
||||||
elsif ( !$dbh2 ) {
|
elsif ( !$dbh2 ) {
|
||||||
|
diag(`$trunk/sandbox/stop-sandbox master 12348 >/dev/null`);
|
||||||
plan skip_all => 'Cannot connect to second sandbox master';
|
plan skip_all => 'Cannot connect to second sandbox master';
|
||||||
}
|
}
|
||||||
|
elsif ( PerconaTest::load_data_is_disabled($dbh1) ) {
|
||||||
|
diag(`$trunk/sandbox/stop-sandbox master 12348 >/dev/null`);
|
||||||
|
plan skip_all => 'LOAD DATA LOCAL INFILE is disabled';
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
plan tests => 6;
|
plan tests => 6;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user