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
1=== modified file 'bin/pt-online-schema-change'
2--- bin/pt-online-schema-change 2014-07-04 17:16:08 +0000
3+++ bin/pt-online-schema-change 2014-07-30 22:39:02 +0000
4@@ -4785,6 +4785,7 @@
5
6 use strict;
7 use warnings FATAL => 'all';
8+use POSIX qw( ceil );
9 use English qw(-no_match_vars);
10 use constant PTDEBUG => $ENV{PTDEBUG} || 0;
11
12@@ -4950,8 +4951,8 @@
13 }
14 else {
15 PTDEBUG && _d('Initial', $var, 'value:', $init_val);
16- $val = int(($init_val * $threshold_factor) + $init_val);
17- $vars->{$var} = $val;
18+ $val = ($init_val * $threshold_factor) + $init_val;
19+ $vars->{$var} = int(ceil($val));
20 }
21 PTDEBUG && _d('Wait if', $var, '>=', $val);
22 }
23
24=== modified file 'bin/pt-table-checksum'
25--- bin/pt-table-checksum 2014-07-04 17:16:08 +0000
26+++ bin/pt-table-checksum 2014-07-30 22:39:02 +0000
27@@ -8347,6 +8347,7 @@
28
29 use strict;
30 use warnings FATAL => 'all';
31+use POSIX qw( ceil );
32 use English qw(-no_match_vars);
33 use constant PTDEBUG => $ENV{PTDEBUG} || 0;
34
35@@ -8512,8 +8513,8 @@
36 }
37 else {
38 PTDEBUG && _d('Initial', $var, 'value:', $init_val);
39- $val = int(($init_val * $threshold_factor) + $init_val);
40- $vars->{$var} = $val;
41+ $val = ($init_val * $threshold_factor) + $init_val;
42+ $vars->{$var} = int(ceil($val));
43 }
44 PTDEBUG && _d('Wait if', $var, '>=', $val);
45 }
46
47=== modified file 'lib/MySQLStatusWaiter.pm'
48--- lib/MySQLStatusWaiter.pm 2013-01-03 00:19:16 +0000
49+++ lib/MySQLStatusWaiter.pm 2014-07-30 22:39:02 +0000
50@@ -24,6 +24,7 @@
51
52 use strict;
53 use warnings FATAL => 'all';
54+use POSIX qw( ceil );
55 use English qw(-no_match_vars);
56 use constant PTDEBUG => $ENV{PTDEBUG} || 0;
57
58@@ -221,8 +222,8 @@
59 }
60 else {
61 PTDEBUG && _d('Initial', $var, 'value:', $init_val);
62- $val = int(($init_val * $threshold_factor) + $init_val);
63- $vars->{$var} = $val;
64+ $val = ($init_val * $threshold_factor) + $init_val;
65+ $vars->{$var} = int(ceil($val));
66 }
67 PTDEBUG && _d('Wait if', $var, '>=', $val);
68 }
69
70=== modified file 't/lib/MySQLStatusWaiter.t'
71--- t/lib/MySQLStatusWaiter.t 2012-05-25 21:27:23 +0000
72+++ t/lib/MySQLStatusWaiter.t 2014-07-30 22:39:02 +0000
73@@ -8,6 +8,7 @@
74
75 use strict;
76 use warnings FATAL => 'all';
77+use POSIX qw( ceil floor );
78 use English qw(-no_match_vars);
79 use Test::More tests => 17;
80
81@@ -19,6 +20,7 @@
82 my $slept = 0;
83 my @vals = ();
84
85+
86 sub oktorun {
87 return $oktorun;
88 }
89@@ -76,33 +78,35 @@
90 "Catch non-existent variable"
91 );
92
93-# ############################################################################
94-# Use initial vals + 20%.
95-# ############################################################################
96+
97+# ############################################################################
98+# Initial vals + 20%
99+# ############################################################################
100+
101 @vals = (
102 # initial check for existence
103- { Threads_connected => 10, },
104- { Threads_running => 5, },
105+ { Threads_connected => 9, },
106+ { Threads_running => 4, },
107
108 # first check, no wait
109 { Threads_connected => 1, },
110 { Threads_running => 1, },
111
112 # second check, wait
113- { Threads_connected => 12, }, # too high
114- { Threads_running => 6, }, # too high
115+ { Threads_connected => 11, }, # too high
116+ { Threads_running => 5, }, # too high
117
118 # third check, wait
119- { Threads_connected => 12, }, # too high
120- { Threads_running => 5, },
121+ { Threads_connected => 11, }, # too high
122+ { Threads_running => 4, },
123
124 # fourth check, wait
125 { Threads_connected => 10, },
126- { Threads_running => 6, }, # too high
127+ { Threads_running => 5, }, # too high
128
129 # fifth check, no wait
130 { Threads_connected => 10, },
131- { Threads_running => 5, },
132+ { Threads_running => 4, },
133 );
134
135 $oktorun = 1;
136@@ -117,10 +121,10 @@
137 is_deeply(
138 $sw->max_values(),
139 {
140- Threads_connected => int(10 + (10 * 0.20)),
141- Threads_running => int(5 + (5 * 0.20)),
142+ Threads_connected => ceil(9 + (9 * 0.20)),
143+ Threads_running => ceil(4 + (4 * 0.20)),
144 },
145- "Initial values +20%"
146+ "Threshold = ceil(InitialValue * 1.2)"
147 );
148
149 # first check
150
151=== modified file 't/pt-table-checksum/basics.t'
152--- t/pt-table-checksum/basics.t 2014-07-07 00:43:50 +0000
153+++ t/pt-table-checksum/basics.t 2014-07-30 22:39:02 +0000
154@@ -97,6 +97,7 @@
155 "Static chunk size (--chunk-time 0)"
156 );
157
158+
159 $row = $master_dbh->selectrow_arrayref("select count(*) from percona.checksums");
160 ok(
161 $row->[0] >= 85 && $row->[0] <= 90,
162
163=== modified file 't/pt-table-checksum/samples/default-results-5.5.txt'
164--- t/pt-table-checksum/samples/default-results-5.5.txt 2013-02-19 01:51:14 +0000
165+++ t/pt-table-checksum/samples/default-results-5.5.txt 2014-07-30 22:39:02 +0000
166@@ -21,7 +21,7 @@
167 0 0 0 0 mysql.time_zone_transition
168 0 0 0 0 mysql.time_zone_transition_type
169 0 0 2 0 mysql.user
170-0 0 38 0 percona_test.checksums
171+0 0 22 0 percona_test.checksums
172 0 0 1 0 percona_test.load_data
173 0 0 1 0 percona_test.sentinel
174 0 0 200 0 sakila.actor
175
176=== modified file 't/pt-table-checksum/samples/default-results-5.6.txt'
177--- t/pt-table-checksum/samples/default-results-5.6.txt 2013-02-19 01:51:44 +0000
178+++ t/pt-table-checksum/samples/default-results-5.6.txt 2014-07-30 22:39:02 +0000
179@@ -20,7 +20,7 @@
180 0 0 0 0 mysql.time_zone_transition
181 0 0 0 0 mysql.time_zone_transition_type
182 0 0 2 0 mysql.user
183-0 0 37 0 percona_test.checksums
184+0 0 22 0 percona_test.checksums
185 0 0 1 0 percona_test.load_data
186 0 0 1 0 percona_test.sentinel
187 0 0 200 0 sakila.actor
188
189=== modified file 't/pt-table-checksum/samples/static-chunk-size-results-5.5.txt'
190--- t/pt-table-checksum/samples/static-chunk-size-results-5.5.txt 2013-02-19 01:51:14 +0000
191+++ t/pt-table-checksum/samples/static-chunk-size-results-5.5.txt 2014-07-30 22:39:02 +0000
192@@ -21,7 +21,7 @@
193 0 0 0 1 0 mysql.time_zone_transition
194 0 0 0 1 0 mysql.time_zone_transition_type
195 0 0 2 1 0 mysql.user
196-0 0 38 1 0 percona_test.checksums
197+0 0 22 1 0 percona_test.checksums
198 0 0 1 1 0 percona_test.load_data
199 0 0 1 1 0 percona_test.sentinel
200 0 0 200 1 0 sakila.actor
201
202=== modified file 't/pt-table-checksum/samples/static-chunk-size-results-5.6.txt'
203--- t/pt-table-checksum/samples/static-chunk-size-results-5.6.txt 2013-02-19 01:51:44 +0000
204+++ t/pt-table-checksum/samples/static-chunk-size-results-5.6.txt 2014-07-30 22:39:02 +0000
205@@ -20,7 +20,7 @@
206 0 0 0 1 0 mysql.time_zone_transition
207 0 0 0 1 0 mysql.time_zone_transition_type
208 0 0 2 1 0 mysql.user
209-0 0 37 1 0 percona_test.checksums
210+0 0 22 1 0 percona_test.checksums
211 0 0 1 1 0 percona_test.load_data
212 0 0 1 1 0 percona_test.sentinel
213 0 0 200 1 0 sakila.actor

Subscribers

People subscribed via source and target branches

to all changes: