Fix for 923896

This commit is contained in:
Brian Fraser fraserb@gmail.com
2012-05-27 23:28:35 -03:00
parent f6e265613c
commit 20d6ccff9e
3 changed files with 36 additions and 1 deletions

View File

@@ -2177,6 +2177,7 @@ sub find {
} }
if ( $find_spec{busy_time} && ($query->{Command} || '') eq 'Query' ) { if ( $find_spec{busy_time} && ($query->{Command} || '') eq 'Query' ) {
next QUERY unless defined $query->{Time};
if ( $query->{Time} < $find_spec{busy_time} ) { if ( $query->{Time} < $find_spec{busy_time} ) {
PTDEBUG && _d("Query isn't running long enough"); PTDEBUG && _d("Query isn't running long enough");
next QUERY; next QUERY;
@@ -2186,6 +2187,7 @@ sub find {
} }
if ( $find_spec{idle_time} && ($query->{Command} || '') eq 'Sleep' ) { if ( $find_spec{idle_time} && ($query->{Command} || '') eq 'Sleep' ) {
next QUERY unless defined $query->{Time};
if ( $query->{Time} < $find_spec{idle_time} ) { if ( $query->{Time} < $find_spec{idle_time} ) {
PTDEBUG && _d("Query isn't idle long enough"); PTDEBUG && _d("Query isn't idle long enough");
next QUERY; next QUERY;

View File

@@ -470,6 +470,7 @@ sub find {
# Match special busy_time. # Match special busy_time.
if ( $find_spec{busy_time} && ($query->{Command} || '') eq 'Query' ) { if ( $find_spec{busy_time} && ($query->{Command} || '') eq 'Query' ) {
next QUERY unless defined($query->{Time});
if ( $query->{Time} < $find_spec{busy_time} ) { if ( $query->{Time} < $find_spec{busy_time} ) {
PTDEBUG && _d("Query isn't running long enough"); PTDEBUG && _d("Query isn't running long enough");
next QUERY; next QUERY;
@@ -480,6 +481,7 @@ sub find {
# Match special idle_time. # Match special idle_time.
if ( $find_spec{idle_time} && ($query->{Command} || '') eq 'Sleep' ) { if ( $find_spec{idle_time} && ($query->{Command} || '') eq 'Sleep' ) {
next QUERY unless defined($query->{Time});
if ( $query->{Time} < $find_spec{idle_time} ) { if ( $query->{Time} < $find_spec{idle_time} ) {
PTDEBUG && _d("Query isn't idle long enough"); PTDEBUG && _d("Query isn't idle long enough");
next QUERY; next QUERY;

View File

@@ -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 => 32; use Test::More tests => 34;
use Processlist; use Processlist;
use PerconaTest; use PerconaTest;
@@ -827,6 +827,37 @@ is_deeply(
"Find all queries that aren't ignored" "Find all queries that aren't ignored"
); );
# #############################################################################
# https://bugs.launchpad.net/percona-toolkit/+bug/923896
# #############################################################################
%find_spec = (
busy_time => 1,
ignore => {},
match => {},
);
my $proc = { 'Time' => undef,
'Command' => 'Query',
'db' => undef,
'Id' => '7',
'Info' => undef,
'User' => 'msandbox',
'State' => '',
'Host' => 'localhost'
};
local $@;
eval { $pl->find([$proc], %find_spec) };
ok !$@;
delete $find_spec{busy_time};
$find_spec{idle_time} = 1;
$proc->{Command} = 'Sleep';
local $@;
eval { $pl->find([$proc], %find_spec) };
ok !$@;
# ############################################################################# # #############################################################################
# Done. # Done.
# ############################################################################# # #############################################################################