Merge lp:~percona-toolkit-dev/percona-toolkit/pt-table-checksum-max-load-20-percent-rounds-down-1253872 into lp:~percona-toolkit-dev/percona-toolkit/release-2.2.10

Proposed by Frank Cizmich
Status: Merged
Approved by: Daniel Nichter
Approved revision: 620
Merged at revision: 611
Proposed branch: lp:~percona-toolkit-dev/percona-toolkit/pt-table-checksum-max-load-20-percent-rounds-down-1253872
Merge into: lp:~percona-toolkit-dev/percona-toolkit/release-2.2.10
Diff against target: 213 lines (+32/-24)
9 files modified
bin/pt-online-schema-change (+3/-2)
bin/pt-table-checksum (+3/-2)
lib/MySQLStatusWaiter.pm (+3/-2)
t/lib/MySQLStatusWaiter.t (+18/-14)
t/pt-table-checksum/basics.t (+1/-0)
t/pt-table-checksum/samples/default-results-5.5.txt (+1/-1)
t/pt-table-checksum/samples/default-results-5.6.txt (+1/-1)
t/pt-table-checksum/samples/static-chunk-size-results-5.5.txt (+1/-1)
t/pt-table-checksum/samples/static-chunk-size-results-5.6.txt (+1/-1)
To merge this branch: bzr merge lp:~percona-toolkit-dev/percona-toolkit/pt-table-checksum-max-load-20-percent-rounds-down-1253872
Reviewer Review Type Date Requested Status
Daniel Nichter Approve
Review via email: mp+228738@code.launchpad.net

Description of the change

added ceiling option to MySQLStatusWaiter so pt-table-checksum can round threshold = initial value + 20% up instead of down.
Net effect is to have a higher threshold than the initial one when low integer values are involved.
eg: 4 + 20% rounds to 5 instead of 4

To post a comment you must log in.
Revision history for this message
Daniel Nichter (daniel-nichter) wrote :

$args{ceiling} is introduced but nothing makes use of it, except the test? Is there a simpler way to do this, i.e. just round-up in the one place we calculate the value?

620. By Frank Cizmich

Removed ceiling argument passing, simply round up threshold now. Simplified test accordingly

Revision history for this message
Daniel Nichter (daniel-nichter) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'bin/pt-online-schema-change'
--- bin/pt-online-schema-change 2014-07-04 17:16:08 +0000
+++ bin/pt-online-schema-change 2014-07-30 22:39:02 +0000
@@ -4785,6 +4785,7 @@
47854785
4786use strict;4786use strict;
4787use warnings FATAL => 'all';4787use warnings FATAL => 'all';
4788use POSIX qw( ceil );
4788use English qw(-no_match_vars);4789use English qw(-no_match_vars);
4789use constant PTDEBUG => $ENV{PTDEBUG} || 0;4790use constant PTDEBUG => $ENV{PTDEBUG} || 0;
47904791
@@ -4950,8 +4951,8 @@
4950 }4951 }
4951 else {4952 else {
4952 PTDEBUG && _d('Initial', $var, 'value:', $init_val);4953 PTDEBUG && _d('Initial', $var, 'value:', $init_val);
4953 $val = int(($init_val * $threshold_factor) + $init_val);4954 $val = ($init_val * $threshold_factor) + $init_val;
4954 $vars->{$var} = $val;4955 $vars->{$var} = int(ceil($val));
4955 }4956 }
4956 PTDEBUG && _d('Wait if', $var, '>=', $val);4957 PTDEBUG && _d('Wait if', $var, '>=', $val);
4957 }4958 }
49584959
=== modified file 'bin/pt-table-checksum'
--- bin/pt-table-checksum 2014-07-04 17:16:08 +0000
+++ bin/pt-table-checksum 2014-07-30 22:39:02 +0000
@@ -8347,6 +8347,7 @@
83478347
8348use strict;8348use strict;
8349use warnings FATAL => 'all';8349use warnings FATAL => 'all';
8350use POSIX qw( ceil );
8350use English qw(-no_match_vars);8351use English qw(-no_match_vars);
8351use constant PTDEBUG => $ENV{PTDEBUG} || 0;8352use constant PTDEBUG => $ENV{PTDEBUG} || 0;
83528353
@@ -8512,8 +8513,8 @@
8512 }8513 }
8513 else {8514 else {
8514 PTDEBUG && _d('Initial', $var, 'value:', $init_val);8515 PTDEBUG && _d('Initial', $var, 'value:', $init_val);
8515 $val = int(($init_val * $threshold_factor) + $init_val);8516 $val = ($init_val * $threshold_factor) + $init_val;
8516 $vars->{$var} = $val;8517 $vars->{$var} = int(ceil($val));
8517 }8518 }
8518 PTDEBUG && _d('Wait if', $var, '>=', $val);8519 PTDEBUG && _d('Wait if', $var, '>=', $val);
8519 }8520 }
85208521
=== modified file 'lib/MySQLStatusWaiter.pm'
--- lib/MySQLStatusWaiter.pm 2013-01-03 00:19:16 +0000
+++ lib/MySQLStatusWaiter.pm 2014-07-30 22:39:02 +0000
@@ -24,6 +24,7 @@
2424
25use strict;25use strict;
26use warnings FATAL => 'all';26use warnings FATAL => 'all';
27use POSIX qw( ceil );
27use English qw(-no_match_vars);28use English qw(-no_match_vars);
28use constant PTDEBUG => $ENV{PTDEBUG} || 0;29use constant PTDEBUG => $ENV{PTDEBUG} || 0;
2930
@@ -221,8 +222,8 @@
221 }222 }
222 else {223 else {
223 PTDEBUG && _d('Initial', $var, 'value:', $init_val);224 PTDEBUG && _d('Initial', $var, 'value:', $init_val);
224 $val = int(($init_val * $threshold_factor) + $init_val);225 $val = ($init_val * $threshold_factor) + $init_val;
225 $vars->{$var} = $val;226 $vars->{$var} = int(ceil($val));
226 }227 }
227 PTDEBUG && _d('Wait if', $var, '>=', $val);228 PTDEBUG && _d('Wait if', $var, '>=', $val);
228 }229 }
229230
=== modified file 't/lib/MySQLStatusWaiter.t'
--- t/lib/MySQLStatusWaiter.t 2012-05-25 21:27:23 +0000
+++ t/lib/MySQLStatusWaiter.t 2014-07-30 22:39:02 +0000
@@ -8,6 +8,7 @@
88
9use strict;9use strict;
10use warnings FATAL => 'all';10use warnings FATAL => 'all';
11use POSIX qw( ceil floor );
11use English qw(-no_match_vars);12use English qw(-no_match_vars);
12use Test::More tests => 17;13use Test::More tests => 17;
1314
@@ -19,6 +20,7 @@
19my $slept = 0;20my $slept = 0;
20my @vals = ();21my @vals = ();
2122
23
22sub oktorun {24sub oktorun {
23 return $oktorun;25 return $oktorun;
24}26}
@@ -76,33 +78,35 @@
76 "Catch non-existent variable"78 "Catch non-existent variable"
77);79);
7880
79# ############################################################################81
80# Use initial vals + 20%.82# ############################################################################
81# ############################################################################83# Initial vals + 20%
84# ############################################################################
85
82@vals = (86@vals = (
83 # initial check for existence87 # initial check for existence
84 { Threads_connected => 10, },88 { Threads_connected => 9, },
85 { Threads_running => 5, },89 { Threads_running => 4, },
8690
87 # first check, no wait91 # first check, no wait
88 { Threads_connected => 1, },92 { Threads_connected => 1, },
89 { Threads_running => 1, },93 { Threads_running => 1, },
9094
91 # second check, wait95 # second check, wait
92 { Threads_connected => 12, }, # too high96 { Threads_connected => 11, }, # too high
93 { Threads_running => 6, }, # too high97 { Threads_running => 5, }, # too high
9498
95 # third check, wait99 # third check, wait
96 { Threads_connected => 12, }, # too high100 { Threads_connected => 11, }, # too high
97 { Threads_running => 5, },101 { Threads_running => 4, },
98102
99 # fourth check, wait103 # fourth check, wait
100 { Threads_connected => 10, },104 { Threads_connected => 10, },
101 { Threads_running => 6, }, # too high105 { Threads_running => 5, }, # too high
102 106
103 # fifth check, no wait107 # fifth check, no wait
104 { Threads_connected => 10, },108 { Threads_connected => 10, },
105 { Threads_running => 5, },109 { Threads_running => 4, },
106);110);
107111
108$oktorun = 1;112$oktorun = 1;
@@ -117,10 +121,10 @@
117is_deeply(121is_deeply(
118 $sw->max_values(),122 $sw->max_values(),
119 {123 {
120 Threads_connected => int(10 + (10 * 0.20)),124 Threads_connected => ceil(9 + (9 * 0.20)),
121 Threads_running => int(5 + (5 * 0.20)),125 Threads_running => ceil(4 + (4 * 0.20)),
122 },126 },
123 "Initial values +20%"127 "Threshold = ceil(InitialValue * 1.2)"
124);128);
125129
126# first check130# first check
127131
=== modified file 't/pt-table-checksum/basics.t'
--- t/pt-table-checksum/basics.t 2014-07-07 00:43:50 +0000
+++ t/pt-table-checksum/basics.t 2014-07-30 22:39:02 +0000
@@ -97,6 +97,7 @@
97 "Static chunk size (--chunk-time 0)"97 "Static chunk size (--chunk-time 0)"
98);98);
9999
100
100$row = $master_dbh->selectrow_arrayref("select count(*) from percona.checksums");101$row = $master_dbh->selectrow_arrayref("select count(*) from percona.checksums");
101ok(102ok(
102 $row->[0] >= 85 && $row->[0] <= 90,103 $row->[0] >= 85 && $row->[0] <= 90,
103104
=== modified file 't/pt-table-checksum/samples/default-results-5.5.txt'
--- t/pt-table-checksum/samples/default-results-5.5.txt 2013-02-19 01:51:14 +0000
+++ t/pt-table-checksum/samples/default-results-5.5.txt 2014-07-30 22:39:02 +0000
@@ -21,7 +21,7 @@
210 0 0 0 mysql.time_zone_transition210 0 0 0 mysql.time_zone_transition
220 0 0 0 mysql.time_zone_transition_type220 0 0 0 mysql.time_zone_transition_type
230 0 2 0 mysql.user230 0 2 0 mysql.user
240 0 38 0 percona_test.checksums240 0 22 0 percona_test.checksums
250 0 1 0 percona_test.load_data250 0 1 0 percona_test.load_data
260 0 1 0 percona_test.sentinel260 0 1 0 percona_test.sentinel
270 0 200 0 sakila.actor270 0 200 0 sakila.actor
2828
=== modified file 't/pt-table-checksum/samples/default-results-5.6.txt'
--- t/pt-table-checksum/samples/default-results-5.6.txt 2013-02-19 01:51:44 +0000
+++ t/pt-table-checksum/samples/default-results-5.6.txt 2014-07-30 22:39:02 +0000
@@ -20,7 +20,7 @@
200 0 0 0 mysql.time_zone_transition200 0 0 0 mysql.time_zone_transition
210 0 0 0 mysql.time_zone_transition_type210 0 0 0 mysql.time_zone_transition_type
220 0 2 0 mysql.user220 0 2 0 mysql.user
230 0 37 0 percona_test.checksums230 0 22 0 percona_test.checksums
240 0 1 0 percona_test.load_data240 0 1 0 percona_test.load_data
250 0 1 0 percona_test.sentinel250 0 1 0 percona_test.sentinel
260 0 200 0 sakila.actor260 0 200 0 sakila.actor
2727
=== modified file 't/pt-table-checksum/samples/static-chunk-size-results-5.5.txt'
--- t/pt-table-checksum/samples/static-chunk-size-results-5.5.txt 2013-02-19 01:51:14 +0000
+++ t/pt-table-checksum/samples/static-chunk-size-results-5.5.txt 2014-07-30 22:39:02 +0000
@@ -21,7 +21,7 @@
210 0 0 1 0 mysql.time_zone_transition210 0 0 1 0 mysql.time_zone_transition
220 0 0 1 0 mysql.time_zone_transition_type220 0 0 1 0 mysql.time_zone_transition_type
230 0 2 1 0 mysql.user230 0 2 1 0 mysql.user
240 0 38 1 0 percona_test.checksums240 0 22 1 0 percona_test.checksums
250 0 1 1 0 percona_test.load_data250 0 1 1 0 percona_test.load_data
260 0 1 1 0 percona_test.sentinel260 0 1 1 0 percona_test.sentinel
270 0 200 1 0 sakila.actor270 0 200 1 0 sakila.actor
2828
=== modified file 't/pt-table-checksum/samples/static-chunk-size-results-5.6.txt'
--- t/pt-table-checksum/samples/static-chunk-size-results-5.6.txt 2013-02-19 01:51:44 +0000
+++ t/pt-table-checksum/samples/static-chunk-size-results-5.6.txt 2014-07-30 22:39:02 +0000
@@ -20,7 +20,7 @@
200 0 0 1 0 mysql.time_zone_transition200 0 0 1 0 mysql.time_zone_transition
210 0 0 1 0 mysql.time_zone_transition_type210 0 0 1 0 mysql.time_zone_transition_type
220 0 2 1 0 mysql.user220 0 2 1 0 mysql.user
230 0 37 1 0 percona_test.checksums230 0 22 1 0 percona_test.checksums
240 0 1 1 0 percona_test.load_data240 0 1 1 0 percona_test.load_data
250 0 1 1 0 percona_test.sentinel250 0 1 1 0 percona_test.sentinel
260 0 200 1 0 sakila.actor260 0 200 1 0 sakila.actor

Subscribers

People subscribed via source and target branches

to all changes: