Merge lp:~percona-toolkit-dev/percona-toolkit/fix-pqd-distill-bugs.

This commit is contained in:
Daniel Nichter
2013-08-03 12:54:01 -07:00
19 changed files with 712 additions and 447 deletions

View File

@@ -48,7 +48,7 @@ BEGIN {
FileIterator
Runtime
Pipeline
HTTPMicro
HTTP::Micro
VersionCheck
));
}
@@ -2928,6 +2928,13 @@ sub distill_verbs {
$query =~ m/\A\s*UNLOCK TABLES/i && return "UNLOCK";
$query =~ m/\A\s*xa\s+(\S+)/i && return "XA_$1";
if ( $query =~ m/\A\s*LOAD/i ) {
my ($tbl) = $query =~ m/INTO TABLE\s+(\S+)/i;
$tbl ||= '';
$tbl =~ s/`//g;
return "LOAD DATA $tbl";
}
if ( $query =~ m/\Aadministrator command:/ ) {
$query =~ s/administrator command:/ADMIN/;
$query = uc $query;
@@ -3021,6 +3028,9 @@ sub distill {
map { $verbs =~ s/$_/$alias_for{$_}/ } keys %alias_for;
$query = $verbs;
}
elsif ( $verbs && $verbs =~ m/^LOAD DATA/ ) {
return $verbs;
}
else {
my @tables = $self->__distill_tables($query, $table, %args);
$query = join(q{ }, $verbs, @tables);
@@ -8259,7 +8269,7 @@ sub get_tables {
return ($tbl);
}
$query =~ s/ (?:LOW_PRIORITY|IGNORE|STRAIGHT_JOIN)//ig;
$query =~ s/(?:LOW_PRIORITY|IGNORE|STRAIGHT_JOIN|DELAYED)\s+/ /ig;
if ( $query =~ s/^\s*LOCK TABLES\s+//i ) {
PTDEBUG && _d('Special table type: LOCK TABLES');
@@ -8272,6 +8282,15 @@ sub get_tables {
$query =~ s/".*?"/?/sg; # quoted strings
$query =~ s/'.*?'/?/sg; # quoted strings
if ( $query =~ m/\A\s*(?:INSERT|REPLACE)(?!\s+INTO)/i ) {
$query =~ s/\A\s*((?:INSERT|REPLACE))\s+/$1 INTO /i;
}
if ( $query =~ m/\A\s*LOAD DATA/i ) {
my ($tbl) = $query =~ m/INTO TABLE\s+(\S+)/i;
return $tbl;
}
my @tables;
foreach my $tbls ( $query =~ m/$tbl_regex/gio ) {
PTDEBUG && _d('Match tables:', $tbls);
@@ -9253,59 +9272,79 @@ package Daemon;
use strict;
use warnings FATAL => 'all';
use English qw(-no_match_vars);
use constant PTDEBUG => $ENV{PTDEBUG} || 0;
use POSIX qw(setsid);
use Fcntl qw(:DEFAULT);
sub new {
my ($class, %args) = @_;
foreach my $arg ( qw(o) ) {
die "I need a $arg argument" unless $args{$arg};
}
my $o = $args{o};
my $self = {
o => $o,
log_file => $o->has('log') ? $o->get('log') : undef,
PID_file => $o->has('pid') ? $o->get('pid') : undef,
log_file => $args{log_file},
pid_file => $args{pid_file},
daemonize => $args{daemonize},
force_log_file => $args{force_log_file},
parent_exit => $args{parent_exit},
pid_file_owner => 0,
};
check_PID_file(undef, $self->{PID_file});
PTDEBUG && _d('Daemonized child will log to', $self->{log_file});
return bless $self, $class;
}
sub daemonize {
sub run {
my ($self) = @_;
PTDEBUG && _d('About to fork and daemonize');
defined (my $pid = fork()) or die "Cannot fork: $OS_ERROR";
if ( $pid ) {
PTDEBUG && _d('Parent PID', $PID, 'exiting after forking child PID',$pid);
exit;
my $daemonize = $self->{daemonize};
my $pid_file = $self->{pid_file};
my $log_file = $self->{log_file};
my $force_log_file = $self->{force_log_file};
my $parent_exit = $self->{parent_exit};
PTDEBUG && _d('Starting daemon');
if ( $pid_file ) {
eval {
$self->_make_pid_file(
pid => $PID, # parent's pid
pid_file => $pid_file,
);
};
die "$EVAL_ERROR\n" if $EVAL_ERROR;
if ( !$daemonize ) {
$self->{pid_file_owner} = $PID; # parent's pid
}
}
PTDEBUG && _d('Daemonizing child PID', $PID);
$self->{PID_owner} = $PID;
$self->{child} = 1;
if ( $daemonize ) {
defined (my $child_pid = fork()) or die "Cannot fork: $OS_ERROR";
if ( $child_pid ) {
PTDEBUG && _d('Forked child', $child_pid);
$parent_exit->($child_pid) if $parent_exit;
exit 0;
}
POSIX::setsid() or die "Cannot start a new session: $OS_ERROR";
chdir '/' or die "Cannot chdir to /: $OS_ERROR";
$self->_make_PID_file();
$OUTPUT_AUTOFLUSH = 1;
if ( $pid_file ) {
$self->_update_pid_file(
pid => $PID, # child's pid
pid_file => $pid_file,
);
$self->{pid_file_owner} = $PID;
}
}
if ( $daemonize || $force_log_file ) {
PTDEBUG && _d('Redirecting STDIN to /dev/null');
close STDIN;
open STDIN, '/dev/null'
or die "Cannot reopen STDIN to /dev/null: $OS_ERROR";
if ( $self->{log_file} ) {
PTDEBUG && _d('Redirecting STDOUT and STDERR to', $self->{log_file});
if ( $log_file ) {
PTDEBUG && _d('Redirecting STDOUT and STDERR to', $log_file);
close STDOUT;
open STDOUT, '>>', $self->{log_file}
or die "Cannot open log file $self->{log_file}: $OS_ERROR";
open STDOUT, '>>', $log_file
or die "Cannot open log file $log_file: $OS_ERROR";
close STDERR;
open STDERR, ">&STDOUT"
@@ -9328,82 +9367,119 @@ sub daemonize {
}
}
$OUTPUT_AUTOFLUSH = 1;
}
PTDEBUG && _d('Daemon running');
return;
}
sub check_PID_file {
my ( $self, $file ) = @_;
my $PID_file = $self ? $self->{PID_file} : $file;
PTDEBUG && _d('Checking PID file', $PID_file);
if ( $PID_file && -f $PID_file ) {
my $pid;
eval {
chomp($pid = (slurp_file($PID_file) || ''));
sub _make_pid_file {
my ($self, %args) = @_;
my @required_args = qw(pid pid_file);
foreach my $arg ( @required_args ) {
die "I need a $arg argument" unless $args{$arg};
};
if ( $EVAL_ERROR ) {
die "The PID file $PID_file already exists but it cannot be read: "
. $EVAL_ERROR;
my $pid = $args{pid};
my $pid_file = $args{pid_file};
eval {
sysopen(PID_FH, $pid_file, O_RDWR|O_CREAT|O_EXCL) or die $OS_ERROR;
print PID_FH $PID, "\n";
close PID_FH;
};
if ( my $e = $EVAL_ERROR ) {
if ( $e =~ m/file exists/i ) {
my $old_pid = $self->_check_pid_file(
pid_file => $pid_file,
pid => $PID,
);
if ( $old_pid ) {
warn "Overwriting PID file $pid_file because PID $old_pid "
. "is not running.\n";
}
PTDEBUG && _d('PID file exists; it contains PID', $pid);
if ( $pid ) {
my $pid_is_alive = kill 0, $pid;
$self->_update_pid_file(
pid => $PID,
pid_file => $pid_file
);
}
else {
die "Error creating PID file $pid_file: $e\n";
}
}
return;
}
sub _check_pid_file {
my ($self, %args) = @_;
my @required_args = qw(pid_file pid);
foreach my $arg ( @required_args ) {
die "I need a $arg argument" unless $args{$arg};
};
my $pid_file = $args{pid_file};
my $pid = $args{pid};
PTDEBUG && _d('Checking if PID in', $pid_file, 'is running');
if ( ! -f $pid_file ) {
PTDEBUG && _d('PID file', $pid_file, 'does not exist');
return;
}
open my $fh, '<', $pid_file
or die "Error opening $pid_file: $OS_ERROR";
my $existing_pid = do { local $/; <$fh> };
chomp($existing_pid) if $existing_pid;
close $fh
or die "Error closing $pid_file: $OS_ERROR";
if ( $existing_pid ) {
if ( $existing_pid == $pid ) {
warn "The current PID $pid already holds the PID file $pid_file\n";
return;
}
else {
PTDEBUG && _d('Checking if PID', $existing_pid, 'is running');
my $pid_is_alive = kill 0, $existing_pid;
if ( $pid_is_alive ) {
die "The PID file $PID_file already exists "
. " and the PID that it contains, $pid, is running";
die "PID file $pid_file exists and PID $existing_pid is running\n";
}
else {
warn "Overwriting PID file $PID_file because the PID that it "
. "contains, $pid, is not running";
}
}
else {
die "The PID file $PID_file already exists but it does not "
. "contain a PID";
die "PID file $pid_file exists but it is empty. Remove the file "
. "if the process is no longer running.\n";
}
return $existing_pid;
}
else {
PTDEBUG && _d('No PID file');
}
sub _update_pid_file {
my ($self, %args) = @_;
my @required_args = qw(pid pid_file);
foreach my $arg ( @required_args ) {
die "I need a $arg argument" unless $args{$arg};
};
my $pid = $args{pid};
my $pid_file = $args{pid_file};
open my $fh, '>', $pid_file
or die "Cannot open $pid_file: $OS_ERROR";
print { $fh } $pid, "\n"
or die "Cannot print to $pid_file: $OS_ERROR";
close $fh
or warn "Cannot close $pid_file: $OS_ERROR";
return;
}
sub make_PID_file {
my ( $self ) = @_;
if ( exists $self->{child} ) {
die "Do not call Daemon::make_PID_file() for daemonized scripts";
}
$self->_make_PID_file();
$self->{PID_owner} = $PID;
return;
}
sub _make_PID_file {
my ( $self ) = @_;
my $PID_file = $self->{PID_file};
if ( !$PID_file ) {
PTDEBUG && _d('No PID file to create');
return;
}
$self->check_PID_file();
open my $PID_FH, '>', $PID_file
or die "Cannot open PID file $PID_file: $OS_ERROR";
print $PID_FH $PID
or die "Cannot print to PID file $PID_file: $OS_ERROR";
close $PID_FH
or die "Cannot close PID file $PID_file: $OS_ERROR";
PTDEBUG && _d('Created PID file:', $self->{PID_file});
return;
}
sub _remove_PID_file {
my ( $self ) = @_;
if ( $self->{PID_file} && -f $self->{PID_file} ) {
unlink $self->{PID_file}
or warn "Cannot remove PID file $self->{PID_file}: $OS_ERROR";
sub remove_pid_file {
my ($self, $pid_file) = @_;
$pid_file ||= $self->{pid_file};
if ( $pid_file && -f $pid_file ) {
unlink $self->{pid_file}
or warn "Cannot remove PID file $pid_file: $OS_ERROR";
PTDEBUG && _d('Removed PID file');
}
else {
@@ -9415,16 +9491,11 @@ sub _remove_PID_file {
sub DESTROY {
my ($self) = @_;
$self->_remove_PID_file() if ($self->{PID_owner} || 0) == $PID;
return;
if ( $self->{pid_file_owner} == $PID ) {
$self->remove_pid_file();
}
sub slurp_file {
my ($file) = @_;
return unless $file;
open my $fh, "<", $file or die "Cannot open $file: $OS_ERROR";
return do { local $/; <$fh> };
return;
}
sub _d {
@@ -11479,25 +11550,23 @@ sub _d {
# ###########################################################################
# ###########################################################################
# HTTPMicro package
# HTTP::Micro 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/HTTPMicro.pm
# t/lib/HTTPMicro.t
# lib/HTTP/Micro.pm
# t/lib/HTTP/Micro.t
# See https://launchpad.net/percona-toolkit for more information.
# ###########################################################################
{
package HTTP::Micro;
our $VERSION = '0.01';
package HTTPMicro;
BEGIN {
$HTTPMicro::VERSION = '0.001';
}
use strict;
use warnings;
use warnings FATAL => 'all';
use English qw(-no_match_vars);
use Carp ();
my @attributes;
BEGIN {
@attributes = qw(agent timeout);
@@ -11568,7 +11637,7 @@ sub _request {
headers => {},
};
my $handle = HTTPMicro::Handle->new(timeout => $self->{timeout});
my $handle = HTTP::Micro::Handle->new(timeout => $self->{timeout});
$handle->connect($scheme, $host, $port);
@@ -11633,14 +11702,18 @@ sub _split_url {
return ($scheme, $host, $port, $path_query);
}
package
HTTPMicro::Handle; # hide from PAUSE/indexers
use strict;
use warnings;
} # HTTP::Micro
use Carp qw[croak];
use Errno qw[EINTR EPIPE];
use IO::Socket qw[SOCK_STREAM];
{
package HTTP::Micro::Handle;
use strict;
use warnings FATAL => 'all';
use English qw(-no_match_vars);
use Carp qw(croak);
use Errno qw(EINTR EPIPE);
use IO::Socket qw(SOCK_STREAM);
sub BUFSIZE () { 32768 }
@@ -11683,7 +11756,7 @@ sub connect {
croak(qq/Unsupported URL scheme '$scheme'\n/);
}
$self->{fh} = 'IO::Socket::INET'->new(
$self->{fh} = IO::Socket::INET->new(
PeerHost => $host,
PeerPort => $port,
Proto => 'tcp',
@@ -11947,6 +12020,7 @@ sub can_write {
my $self = shift;
return $self->_do_timeout('write', @_)
}
} # HTTP::Micro::Handle
my $prog = <<'EOP';
BEGIN {
@@ -11967,6 +12041,7 @@ BEGIN {
}
}
{
use Carp qw(croak);
my %dispatcher = (
issuer => sub { Net::SSLeay::X509_NAME_oneline( Net::SSLeay::X509_get_issuer_name( shift )) },
subject => sub { Net::SSLeay::X509_NAME_oneline( Net::SSLeay::X509_get_subject_name( shift )) },
@@ -12122,9 +12197,8 @@ if ( $INC{"IO/Socket/SSL.pm"} ) {
}
1;
}
# ###########################################################################
# End HTTPMicro package
# End HTTP::Micro package
# ###########################################################################
# ###########################################################################
@@ -12158,7 +12232,7 @@ use FindBin qw();
eval {
require Percona::Toolkit;
require HTTPMicro;
require HTTP::Micro;
};
{
@@ -12389,7 +12463,7 @@ sub pingback {
my $url = $args{url};
my $instances = $args{instances};
my $ua = $args{ua} || HTTPMicro->new( timeout => 3 );
my $ua = $args{ua} || HTTP::Micro->new( timeout => 3 );
my $response = $ua->request('GET', $url);
PTDEBUG && _d('Server response:', Dumper($response));
@@ -13965,17 +14039,12 @@ sub main {
# ########################################################################
# Daemonize now that everything is setup and ready to work.
# ########################################################################
my $daemon;
if ( $o->get('daemonize') ) {
$daemon = new Daemon(o=>$o);
$daemon->daemonize();
PTDEBUG && _d('I am a daemon now');
}
elsif ( $o->get('pid') ) {
# We're not daemoninzing, it just handles PID stuff.
$daemon = new Daemon(o=>$o);
$daemon->make_PID_file();
}
my $daemon = Daemon->new(
daemonize => $o->get('daemonize'),
pid_file => $o->get('pid'),
log_file => $o->get('log'),
);
$daemon->run();
# ########################################################################
# Do the version-check

View File

@@ -708,5 +708,5 @@ if ( $INC{"IO/Socket/SSL.pm"} ) {
1;
# ###########################################################################
# End HTTPMicro package
# End HTTP::Micro package
# ###########################################################################

View File

@@ -98,7 +98,7 @@ sub get_tables {
# These keywords may appear between UPDATE or SELECT and the table refs.
# They need to be removed so that they are not mistaken for tables.
$query =~ s/ (?:LOW_PRIORITY|IGNORE|STRAIGHT_JOIN)//ig;
$query =~ s/(?:LOW_PRIORITY|IGNORE|STRAIGHT_JOIN|DELAYED)\s+/ /ig;
# Another special case: LOCK TABLES tbl [[AS] alias] READ|WRITE, etc.
# We strip the LOCK TABLES stuff and append "FROM" to fake a SELECT
@@ -114,6 +114,18 @@ sub get_tables {
$query =~ s/".*?"/?/sg; # quoted strings
$query =~ s/'.*?'/?/sg; # quoted strings
# INSERT and REPLACE without INTO
# https://bugs.launchpad.net/percona-toolkit/+bug/984053
if ( $query =~ m/\A\s*(?:INSERT|REPLACE)(?!\s+INTO)/i ) {
# Add INTO so the reset of the code work as usual.
$query =~ s/\A\s*((?:INSERT|REPLACE))\s+/$1 INTO /i;
}
if ( $query =~ m/\A\s*LOAD DATA/i ) {
my ($tbl) = $query =~ m/INTO TABLE\s+(\S+)/i;
return $tbl;
}
my @tables;
foreach my $tbls ( $query =~ m/$tbl_regex/gio ) {
PTDEBUG && _d('Match tables:', $tbls);

View File

@@ -246,6 +246,13 @@ sub distill_verbs {
$query =~ m/\A\s*UNLOCK TABLES/i && return "UNLOCK";
$query =~ m/\A\s*xa\s+(\S+)/i && return "XA_$1";
if ( $query =~ m/\A\s*LOAD/i ) {
my ($tbl) = $query =~ m/INTO TABLE\s+(\S+)/i;
$tbl ||= '';
$tbl =~ s/`//g;
return "LOAD DATA $tbl";
}
if ( $query =~ m/\Aadministrator command:/ ) {
$query =~ s/administrator command:/ADMIN/;
$query = uc $query;
@@ -386,6 +393,9 @@ sub distill {
map { $verbs =~ s/$_/$alias_for{$_}/ } keys %alias_for;
$query = $verbs;
}
elsif ( $verbs && $verbs =~ m/^LOAD DATA/ ) {
return $verbs;
}
else {
# For everything else, distill the tables.
my @tables = $self->__distill_tables($query, $table, %args);

View File

@@ -45,7 +45,7 @@ use FindBin qw();
eval {
require Percona::Toolkit;
require HTTPMicro;
require HTTP::Micro;
};
# Return the version check file used to keep track of
@@ -335,7 +335,7 @@ sub pingback {
my $instances = $args{instances};
# Optional args
my $ua = $args{ua} || HTTPMicro->new( timeout => 3 );
my $ua = $args{ua} || HTTP::Micro->new( timeout => 3 );
# GET https://upgrade.percona.com, the server will return
# a plaintext list of items/programs it wants the tool

View File

@@ -828,6 +828,12 @@ is_deeply(
[qw(t1 t2)], 'get_tables works for lowercased LOCK TABLES',
);
is_deeply(
[ $qp->get_tables("LOAD DATA INFILE '/tmp/foo.txt' INTO TABLE db.tbl") ],
[qw(db.tbl)],
"LOAD DATA db.tbl"
);
# #############################################################################
# Done.
# #############################################################################

View File

@@ -1412,6 +1412,34 @@ is(
'distills SELECT with REPLACE function (issue 1176)'
);
# LOAD DATA
# https://bugs.launchpad.net/percona-toolkit/+bug/821692
# INSERT and REPLACE without INTO
# https://bugs.launchpad.net/percona-toolkit/+bug/984053
is(
$qr->distill("LOAD DATA LOW_PRIORITY LOCAL INFILE 'file' INTO TABLE tbl"),
"LOAD DATA tbl",
"distill LOAD DATA (bug 821692)"
);
is(
$qr->distill("LOAD DATA LOW_PRIORITY LOCAL INFILE 'file' INTO TABLE `tbl`"),
"LOAD DATA tbl",
"distill LOAD DATA (bug 821692)"
);
is(
$qr->distill("insert ignore_bar (id) values (4029731)"),
"INSERT ignore_bar",
"distill INSERT without INTO (bug 984053)"
);
is(
$qr->distill("replace ignore_bar (id) values (4029731)"),
"REPLACE ignore_bar",
"distill REPLACE without INTO (bug 984053)"
);
# #############################################################################
# Done.
# #############################################################################

View File

@@ -1,6 +1,6 @@
# Time: 071218 11:48:27
# Query_time: 0.000012 Lock_time: 0.000000 Rows_sent: 0 Rows_examined: 0
LOAD DATA INFILE '/tmp/foo.txt' INTO db.tbl;
LOAD DATA INFILE '/tmp/foo.txt' INTO TABLE db.tbl;
# Time: 071218 11:48:37
# Query_time: 0.000012 Lock_time: 0.000000 Rows_sent: 0 Rows_examined: 0
LOAD DATA INFILE '/tmp/bar.txt' INTO db.tbl;
LOAD DATA INFILE '/tmp/bar.txt' INTO TABLE db.tbl;

View File

@@ -0,0 +1,24 @@
# User@Host: meow[meow] @ [1.2.3.8]
# Thread_id: 5 Schema: db
# Query_time: 0.000002 Lock_time: 0.000000 Rows_sent: 0 Rows_examined: 0
LOAD DATA LOCAL INFILE '/tmp/foo.txt' INTO TABLE `foo`;
# User@Host: meow[meow] @ [1.2.3.8]
# Thread_id: 7 Schema: db
# Query_time: 0.018799 Lock_time: 0.009453 Rows_sent: 0 Rows_examined: 0
INSERT `foo` VALUES("bar");
# User@Host: meow[meow] @ [1.2.3.8]
# Thread_id: 7 Schema: db
# Query_time: 0.018799 Lock_time: 0.009453 Rows_sent: 0 Rows_examined: 0
REPLACE `foo` VALUES("bar");
# User@Host: meow[meow] @ [1.2.3.8]
# Thread_id: 5 Schema: db
# Query_time: 0.000002 Lock_time: 0.000000 Rows_sent: 0 Rows_examined: 0
load data local infile '/tmp/foo.txt' into table `foo`;
# User@Host: meow[meow] @ [1.2.3.8]
# Thread_id: 7 Schema: db
# Query_time: 0.018799 Lock_time: 0.009453 Rows_sent: 0 Rows_examined: 0
insert `foo` values("bar");
# User@Host: meow[meow] @ [1.2.3.8]
# Thread_id: 7 Schema: db
# Query_time: 0.018799 Lock_time: 0.009453 Rows_sent: 0 Rows_examined: 0
replace `foo` values("bar");

View File

@@ -28,7 +28,7 @@ ok(
"t/pt-query-digest/samples/binlog001.txt"
),
'Analysis for binlog001',
);
) or diag($test_diff);
ok(
no_diff(
@@ -36,7 +36,7 @@ ok(
"t/pt-query-digest/samples/binlog002.txt"
),
'Analysis for binlog002',
);
) or diag($test_diff);
# #############################################################################
# Done.

View File

@@ -32,8 +32,8 @@ my $pid_file = '/tmp/pt-query-digest.test.pid';
$output = `$trunk/bin/pt-query-digest $trunk/commont/t/samples/slow002.txt --pid $pid_file 2>&1`;
like(
$output,
qr{PID file $pid_file already exists},
'Dies if PID file already exists (--pid without --daemonize) (issue 391)'
qr{PID file $pid_file exists},
'Dies if PID file exists (--pid without --daemonize) (issue 391)'
);
`rm $pid_file >/dev/null 2>&1`;

View File

@@ -25,7 +25,7 @@ my $results = "t/pt-query-digest/samples/json";
ok(
no_diff(
sub { pt_query_digest::main(@args, "$sample/slowlogs/empty") },
"t/pt-query-digest/samples/empty_report.txt",
"t/pt-query-digest/samples/empty_json_report.txt",
),
'json output for empty log'
) or diag($test_diff);

View File

@@ -89,6 +89,9 @@ create table foo (i int)\G
# 100ms
# 1s
# 10s+
# Tables
# SHOW TABLE STATUS FROM `d` LIKE 'foo'\G
# SHOW CREATE TABLE `d`.`foo`\G
insert foo values (1) /*... omitted ...*/\G
# Profile
@@ -96,4 +99,4 @@ insert foo values (1) /*... omitted ...*/\G
# ==== ================== ============= ===== ====== ===== ===============
# 1 0xF25D6D5AC7C18FF3 0.0000 0.0% 1 0.0000 0.00 CREATE DATABASE d
# 2 0x03409022EB8A4AE7 0.0000 0.0% 1 0.0000 0.00 CREATE TABLE foo
# 3 0xF579EC4A9633EEA0 0.0000 0.0% 1 0.0000 0.00 INSERT
# 3 0xF579EC4A9633EEA0 0.0000 0.0% 1 0.0000 0.00 INSERT foo

View File

@@ -0,0 +1,2 @@
# No events processed.

View File

@@ -1,5 +1,5 @@
# Query 1: 0.20 QPS, 0.00x concurrency, ID 0xD989521B246E945B at byte 146
# Query 1: 0.20 QPS, 0.00x concurrency, ID 0x14354E1D979884B4 at byte 152
# This item is included in the report because it matches --limit.
# Scores: V/M = 0.00
# Time range: 2007-12-18 11:48:27 to 11:48:37
@@ -10,7 +10,7 @@
# Lock time 0 0 0 0 0 0 0 0
# Rows sent 0 0 0 0 0 0 0 0
# Rows examine 0 0 0 0 0 0 0 0
# Query size 100 86 43 43 43 43 0 43
# Query size 100 98 49 49 49 49 0 49
# Query_time distribution
# 1us
# 10us ################################################################
@@ -23,9 +23,9 @@
# Tables
# SHOW TABLE STATUS FROM `db` LIKE 'tbl'\G
# SHOW CREATE TABLE `db`.`tbl`\G
LOAD DATA INFILE '/tmp/bar.txt' INTO db.tbl\G
LOAD DATA INFILE '/tmp/bar.txt' INTO TABLE db.tbl\G
# Profile
# Rank Query ID Response time Calls R/Call V/M Item
# ==== ================== ============= ===== ====== ===== ======
# 1 0xD989521B246E945B 0.0000 100.0% 2 0.0000 0.00 db.tbl
# ==== ================== ============= ===== ====== ===== ===============
# 1 0x14354E1D979884B4 0.0000 100.0% 2 0.0000 0.00 LOAD DATA db.tbl

View File

@@ -0,0 +1,94 @@
# Query 1: 0 QPS, 0x concurrency, ID 0x471A0C4BD7A4EE34 at byte 730 ______
# This item is included in the report because it matches --limit.
# Scores: V/M = 0.00
# Attribute pct total min max avg 95% stddev median
# ============ === ======= ======= ======= ======= ======= ======= =======
# Count 33 2
# Exec time 49 38ms 19ms 19ms 19ms 19ms 0 19ms
# Lock time 50 19ms 9ms 9ms 9ms 9ms 0 9ms
# Rows sent 0 0 0 0 0 0 0 0
# Rows examine 0 0 0 0 0 0 0 0
# Query size 24 52 26 26 26 26 0 26
# String:
# Databases db
# Hosts
# Users meow
# Query_time distribution
# 1us
# 10us
# 100us
# 1ms
# 10ms ################################################################
# 100ms
# 1s
# 10s+
# Tables
# SHOW TABLE STATUS FROM `db` LIKE 'foo'\G
# SHOW CREATE TABLE `db`.`foo`\G
insert `foo` values("bar")\G
# Query 2: 0 QPS, 0x concurrency, ID 0xF33473286088142B at byte 898 ______
# This item is included in the report because it matches --limit.
# Scores: V/M = 0.00
# Attribute pct total min max avg 95% stddev median
# ============ === ======= ======= ======= ======= ======= ======= =======
# Count 33 2
# Exec time 49 38ms 19ms 19ms 19ms 19ms 0 19ms
# Lock time 50 19ms 9ms 9ms 9ms 9ms 0 9ms
# Rows sent 0 0 0 0 0 0 0 0
# Rows examine 0 0 0 0 0 0 0 0
# Query size 25 54 27 27 27 27 0 27
# String:
# Databases db
# Hosts
# Users meow
# Query_time distribution
# 1us
# 10us
# 100us
# 1ms
# 10ms ################################################################
# 100ms
# 1s
# 10s+
# Tables
# SHOW TABLE STATUS FROM `db` LIKE 'foo'\G
# SHOW CREATE TABLE `db`.`foo`\G
replace `foo` values("bar")\G
# Query 3: 0 QPS, 0x concurrency, ID 0xEBAC9C76529E62CE at byte 534 ______
# This item is included in the report because it matches --limit.
# Scores: V/M = 0.00
# Attribute pct total min max avg 95% stddev median
# ============ === ======= ======= ======= ======= ======= ======= =======
# Count 33 2
# Exec time 0 4us 2us 2us 2us 2us 0 2us
# Lock time 0 0 0 0 0 0 0 0
# Rows sent 0 0 0 0 0 0 0 0
# Rows examine 0 0 0 0 0 0 0 0
# Query size 50 108 54 54 54 54 0 54
# String:
# Databases db
# Hosts
# Users meow
# Query_time distribution
# 1us ################################################################
# 10us
# 100us
# 1ms
# 10ms
# 100ms
# 1s
# 10s+
# Tables
# SHOW TABLE STATUS FROM `db` LIKE 'foo'\G
# SHOW CREATE TABLE `db`.`foo`\G
load data local infile '/tmp/foo.txt' into table `foo`\G
# Profile
# Rank Query ID Response time Calls R/Call V/M Item
# ==== ================== ============= ===== ====== ===== =============
# 1 0x471A0C4BD7A4EE34 0.0376 50.0% 2 0.0188 0.00 INSERT foo
# 2 0xF33473286088142B 0.0376 50.0% 2 0.0188 0.00 REPLACE foo
# 3 0xEBAC9C76529E62CE 0.0000 0.0% 2 0.0000 0.00 LOAD DATA foo

View File

@@ -343,7 +343,7 @@ ok(
"t/pt-query-digest/samples/slow051.txt",
),
'Analysis for slow051 (issue 918)',
);
) or diag($test_diff);
# #############################################################################
# Issue 1124: Make mk-query-digest profile include variance-to-mean ratio
@@ -394,9 +394,10 @@ ok(
);
# #############################################################################
# Bug 1176010: pt-query-digest should know how to group quoted and unquoted database names
# Bug 1176010: pt-query-digest should know how to group quoted and unquoted
# database names
# https://bugs.launchpad.net/percona-toolkit/+bug/1176010
#############################################################################
# #############################################################################
ok(
no_diff(
sub { pt_query_digest::main(@args, $sample.'slow057.txt',
@@ -406,6 +407,22 @@ ok(
'Analysis for slow057 (no grouping bug 1176010)'
) or diag($test_diff);
# #############################################################################
# https://bugs.launchpad.net/percona-toolkit/+bug/821692
# pt-query-digest doesn't distill LOAD DATA correctly
# https://bugs.launchpad.net/percona-toolkit/+bug/984053
# pt-query-digest doesn't distill INSERT/REPLACE without INTO correctly
# #############################################################################
ok(
no_diff(
sub { pt_query_digest::main($sample.'slow058.txt',
'--report-format', 'query_report,profile', '--limit', '100%',
)},
"t/pt-query-digest/samples/slow058.txt",
),
'Analysis for slow058 (bug 821692, bug 984053)'
) or diag($test_diff);
# #############################################################################
# Done.
# #############################################################################

View File

@@ -91,7 +91,7 @@ replace_pkg_in_tool() {
$BRANCH/util/extract-package $pkg $pkg_file | grep -v '^ *#' >> $tmp_file
if [ "$tool_lang" = "perl" ]; then
if [ "$tool_lang" = "perl" -a $pkg != "HTTP::Micro" ]; then
echo "}" >> $tmp_file
fi