mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-08 23:28:19 +00:00
Merge lp:~percona-toolkit-dev/percona-toolkit/fix-928226.
This commit is contained in:
@@ -2192,9 +2192,17 @@ sub _calc_misc_stats {
|
||||
+ $delta_for->{ms_spent_writing};
|
||||
|
||||
if ( $number_of_ios ) {
|
||||
$extra_stats{qtime} =
|
||||
$delta_for->{ms_weighted} / ($number_of_ios + $delta_for->{ios_in_progress})
|
||||
- $delta_for->{ms_spent_doing_io} / $number_of_ios;
|
||||
my $average_ios = $number_of_ios + $delta_for->{ios_in_progress};
|
||||
if ( $average_ios ) {
|
||||
$extra_stats{qtime} = $delta_for->{ms_weighted} / $average_ios
|
||||
- $delta_for->{ms_spent_doing_io} / $number_of_ios;
|
||||
}
|
||||
else {
|
||||
PTDEBUG && _d("IOS_IN_PROGRESS is [", $delta_for->{ios_in_progress},
|
||||
"], and the number of ios is [", $number_of_ios,
|
||||
"], going to use 0 as qtime.");
|
||||
$extra_stats{qtime} = 0;
|
||||
}
|
||||
$extra_stats{stime}
|
||||
= $delta_for->{ms_spent_doing_io} / $number_of_ios;
|
||||
}
|
||||
|
@@ -818,9 +818,17 @@ sub _calc_misc_stats {
|
||||
+ $delta_for->{ms_spent_writing};
|
||||
|
||||
if ( $number_of_ios ) {
|
||||
$extra_stats{qtime} =
|
||||
$delta_for->{ms_weighted} / ($number_of_ios + $delta_for->{ios_in_progress})
|
||||
- $delta_for->{ms_spent_doing_io} / $number_of_ios;
|
||||
my $average_ios = $number_of_ios + $delta_for->{ios_in_progress};
|
||||
if ( $average_ios ) {
|
||||
$extra_stats{qtime} = $delta_for->{ms_weighted} / $average_ios
|
||||
- $delta_for->{ms_spent_doing_io} / $number_of_ios;
|
||||
}
|
||||
else {
|
||||
PTDEBUG && _d("IOS_IN_PROGRESS is [", $delta_for->{ios_in_progress},
|
||||
"], and the number of ios is [", $number_of_ios,
|
||||
"], going to use 0 as qtime.");
|
||||
$extra_stats{qtime} = 0;
|
||||
}
|
||||
$extra_stats{stime}
|
||||
= $delta_for->{ms_spent_doing_io} / $number_of_ios;
|
||||
}
|
||||
|
@@ -9,7 +9,7 @@ BEGIN {
|
||||
use strict;
|
||||
use warnings FATAL => 'all';
|
||||
use English qw(-no_match_vars);
|
||||
use Test::More tests => 107;
|
||||
use Test::More tests => 108;
|
||||
|
||||
use PerconaTest;
|
||||
|
||||
@@ -449,6 +449,30 @@ is_deeply(
|
||||
"_calc_misc_stats works"
|
||||
);
|
||||
|
||||
# Bug 928226: IOS IN PROGRESS can be negative due to kernel bugs,
|
||||
# which can eventually cause a division by zero if it happens to
|
||||
# be the negative of the number of ios.
|
||||
# The tool should return zero in that case, rather than dying.
|
||||
$deltas->{ios_in_progress} = -$deltas->{ios_requested};
|
||||
%misc_stats = $obj->_calc_misc_stats(
|
||||
delta_for => $deltas,
|
||||
elapsed => $curr->{TS} - $prev->{TS},
|
||||
devs_in_group => 1,
|
||||
stats => { %write_stats, %read_stats },
|
||||
);
|
||||
|
||||
is_deeply(
|
||||
\%misc_stats,
|
||||
{
|
||||
busy => '0.6',
|
||||
line_ts => ' 0.0',
|
||||
qtime => 0,
|
||||
s_spent_doing_io => '28.5',
|
||||
stime => '0.0364741641337386',
|
||||
},
|
||||
"_calc_misc_stats works around a negative the IOS IN PROGRESS"
|
||||
);
|
||||
|
||||
$obj->clear_state();
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user