Merge lp:~percona-toolkit-dev/percona-toolkit/partial-fix-1063912-ptc-pxc-slaves into lp:~percona-toolkit-dev/percona-toolkit/2.1.5-release
- partial-fix-1063912-ptc-pxc-slaves
- Merge into 2.1.5-release
Proposed by
Daniel Nichter
Status: | Merged |
---|---|
Merged at revision: | 398 |
Proposed branch: | lp:~percona-toolkit-dev/percona-toolkit/partial-fix-1063912-ptc-pxc-slaves |
Merge into: | lp:~percona-toolkit-dev/percona-toolkit/2.1.5-release |
Diff against target: |
905 lines (+586/-33) 11 files modified
bin/pt-query-digest (+208/-6) bin/pt-stalk (+113/-4) bin/pt-table-checksum (+30/-7) lib/Cxn.pm (+3/-1) lib/RowChecksum.pm (+5/-0) t/lib/Pingback.t (+67/-7) t/lib/RowChecksum.t (+45/-4) t/pt-stalk/plugin.t (+74/-0) t/pt-stalk/samples/plugin001.sh (+21/-0) t/pt-table-checksum/bugs.t (+16/-0) t/pt-table-checksum/run_time.t (+4/-4) |
To merge this branch: | bzr merge lp:~percona-toolkit-dev/percona-toolkit/partial-fix-1063912-ptc-pxc-slaves |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Daniel Nichter | Approve | ||
Review via email: mp+128566@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
- 405. By Daniel Nichter
-
Add note to PXC limiations that complex repl setups aren't supported.
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-query-digest' | |||
2 | --- bin/pt-query-digest 2012-09-24 19:24:36 +0000 | |||
3 | +++ bin/pt-query-digest 2012-10-08 18:50:28 +0000 | |||
4 | @@ -15160,8 +15160,10 @@ | |||
5 | 15160 | may actually include different kinds of attributes (for example, you may have a | 15160 | may actually include different kinds of attributes (for example, you may have a |
6 | 15161 | server with the Percona patches). | 15161 | server with the Percona patches). |
7 | 15162 | 15162 | ||
10 | 15163 | For a full list of attributes, see | 15163 | See L<"ATTRIBUTES REFERENCE"> near the end of this documentation for a list |
11 | 15164 | L<http://code.google.com/p/maatkit/wiki/EventAttributes>. | 15164 | of common and L<"--type"> specific attributes. A familiarity with these |
12 | 15165 | attributes is necessary for working with L<"--filter">, | ||
13 | 15166 | L<"--ignore-attributes">, and other attribute-related options. | ||
14 | 15165 | 15167 | ||
15 | 15166 | With creative use of L<"--filter">, you can create new attributes derived | 15168 | With creative use of L<"--filter">, you can create new attributes derived |
16 | 15167 | from existing attributes. For example, to create an attribute called | 15169 | from existing attributes. For example, to create an attribute called |
17 | @@ -15189,8 +15191,8 @@ | |||
18 | 15189 | These attributes are no different from slow log attributes, so you can use them | 15191 | These attributes are no different from slow log attributes, so you can use them |
19 | 15190 | with L<"--[no]report">, L<"--group-by">, in a L<"--filter">, etc. | 15192 | with L<"--[no]report">, L<"--group-by">, in a L<"--filter">, etc. |
20 | 15191 | 15193 | ||
23 | 15192 | These attributes and more are documented at | 15194 | See the memcached section of L<"ATTRIBUTES REFERENCE"> for a list of |
24 | 15193 | L<http://code.google.com/p/maatkit/wiki/EventAttributes>. | 15195 | memcached-specific attributes. |
25 | 15194 | 15196 | ||
26 | 15195 | =head1 OUTPUT | 15197 | =head1 OUTPUT |
27 | 15196 | 15198 | ||
28 | @@ -15835,8 +15837,8 @@ | |||
29 | 15835 | 15837 | ||
30 | 15836 | It is permissible for the code to have side effects (to alter C<$event>). | 15838 | It is permissible for the code to have side effects (to alter C<$event>). |
31 | 15837 | 15839 | ||
34 | 15838 | You can find an explanation of the structure of $event at | 15840 | See L<"ATTRIBUTES REFERENCE"> for a list of common and L<"--type"> specific |
35 | 15839 | L<http://code.google.com/p/maatkit/wiki/EventAttributes>. | 15841 | attributes. |
36 | 15840 | 15842 | ||
37 | 15841 | Here are more examples of filter code: | 15843 | Here are more examples of filter code: |
38 | 15842 | 15844 | ||
39 | @@ -17069,6 +17071,206 @@ | |||
40 | 17069 | 17071 | ||
41 | 17070 | Replace C<TOOL> with the name of any tool. | 17072 | Replace C<TOOL> with the name of any tool. |
42 | 17071 | 17073 | ||
43 | 17074 | =head1 ATTRIBUTES REFERENCE | ||
44 | 17075 | |||
45 | 17076 | Events may have the following attributes. If writing a L<"--filter">, | ||
46 | 17077 | be sure to check that an attribute is defined in each event before | ||
47 | 17078 | using it, else the filter code may crash the tool with a | ||
48 | 17079 | "use of uninitialized value" error. | ||
49 | 17080 | |||
50 | 17081 | You can dump event attributes for any input like: | ||
51 | 17082 | |||
52 | 17083 | $ pt-query-digest \ | ||
53 | 17084 | slowlog \ | ||
54 | 17085 | --filter 'print Dumper $event' \ | ||
55 | 17086 | --no-report \ | ||
56 | 17087 | --sample 1 | ||
57 | 17088 | |||
58 | 17089 | That will produce a lot of output with "attribute => value" pairs like: | ||
59 | 17090 | |||
60 | 17091 | $VAR1 = { | ||
61 | 17092 | Query_time => '0.033384', | ||
62 | 17093 | Rows_examined => '0', | ||
63 | 17094 | Rows_sent => '0', | ||
64 | 17095 | Thread_id => '10', | ||
65 | 17096 | Tmp_table => 'No', | ||
66 | 17097 | Tmp_table_on_disk => 'No', | ||
67 | 17098 | arg => 'SELECT col FROM tbl WHERE id=5', | ||
68 | 17099 | bytes => 103, | ||
69 | 17100 | cmd => 'Query', | ||
70 | 17101 | db => 'db1', | ||
71 | 17102 | fingerprint => 'select col from tbl where id=?', | ||
72 | 17103 | host => '', | ||
73 | 17104 | pos_in_log => 1334, | ||
74 | 17105 | ts => '071218 11:48:27', | ||
75 | 17106 | user => '[SQL_SLAVE]' | ||
76 | 17107 | }; | ||
77 | 17108 | |||
78 | 17109 | =head2 COMMON | ||
79 | 17110 | |||
80 | 17111 | These attribute are common to all input L<"--type"> and L<"--processlist">, | ||
81 | 17112 | except where noted. | ||
82 | 17113 | |||
83 | 17114 | =over | ||
84 | 17115 | |||
85 | 17116 | =item arg | ||
86 | 17117 | |||
87 | 17118 | The query text, or the command for admin commands like C<Ping>. | ||
88 | 17119 | |||
89 | 17120 | =item bytes | ||
90 | 17121 | |||
91 | 17122 | The byte length of the C<arg>. | ||
92 | 17123 | |||
93 | 17124 | =item cmd | ||
94 | 17125 | |||
95 | 17126 | "Query" or "Admin" for all except memcached. For memcached it's | ||
96 | 17127 | the memcached command: get, set, etc. | ||
97 | 17128 | |||
98 | 17129 | =item db | ||
99 | 17130 | |||
100 | 17131 | The current database, except for memcached. The value comes from USE | ||
101 | 17132 | database statements. By default, C<Schema> is an alias which is automatically | ||
102 | 17133 | changed to C<db>; see L<"--attribute-aliases">. | ||
103 | 17134 | |||
104 | 17135 | =item fingerprint | ||
105 | 17136 | |||
106 | 17137 | An abstracted form of the query. See L<"FINGERPRINTS">. | ||
107 | 17138 | |||
108 | 17139 | =item host | ||
109 | 17140 | |||
110 | 17141 | Client host which executed the query. | ||
111 | 17142 | |||
112 | 17143 | =item pos_in_log | ||
113 | 17144 | |||
114 | 17145 | The byte offset of the event in the log or tcpdump, | ||
115 | 17146 | except for L<"--processlist">. | ||
116 | 17147 | |||
117 | 17148 | =item Query_time | ||
118 | 17149 | |||
119 | 17150 | The total time the query took, including lock time. | ||
120 | 17151 | |||
121 | 17152 | =item ts | ||
122 | 17153 | |||
123 | 17154 | The timestamp of when the query ended. | ||
124 | 17155 | |||
125 | 17156 | =back | ||
126 | 17157 | |||
127 | 17158 | =head2 SLOW, GENERAL, AND BINARY LOGS | ||
128 | 17159 | |||
129 | 17160 | Events have all available attributes from the log file. Therefore, you only | ||
130 | 17161 | need to look at the log file to see which events are available, but remember: | ||
131 | 17162 | not all events have the same attributes. | ||
132 | 17163 | |||
133 | 17164 | Percona Server adds many attributes to the slow log; see | ||
134 | 17165 | http://www.percona.com/doc/percona-server/5.1/diagnostics/slow_extended.html#changes-to-the-log-format | ||
135 | 17166 | for more information. | ||
136 | 17167 | |||
137 | 17168 | =head2 TCPDUMP | ||
138 | 17169 | |||
139 | 17170 | These attributes are available when parsing L<"--type"> tcpdump. | ||
140 | 17171 | |||
141 | 17172 | =over | ||
142 | 17173 | |||
143 | 17174 | =item Error_no | ||
144 | 17175 | |||
145 | 17176 | The MySQL error number if the query caused an error. | ||
146 | 17177 | |||
147 | 17178 | =item ip | ||
148 | 17179 | |||
149 | 17180 | The client's IP address. Certain log files may also contain this attribute. | ||
150 | 17181 | |||
151 | 17182 | =item No_good_index_used | ||
152 | 17183 | |||
153 | 17184 | Yes or No if no good index existed for the query (flag set by server). | ||
154 | 17185 | |||
155 | 17186 | =item No_index_used | ||
156 | 17187 | |||
157 | 17188 | Yes or No if the query did not use any index (flag set by server). | ||
158 | 17189 | |||
159 | 17190 | =item port | ||
160 | 17191 | |||
161 | 17192 | The client's port number. | ||
162 | 17193 | |||
163 | 17194 | =item Warning_count | ||
164 | 17195 | |||
165 | 17196 | The number of warnings, as otherwise shown by C<SHOW WARNINGS>. | ||
166 | 17197 | |||
167 | 17198 | =back | ||
168 | 17199 | |||
169 | 17200 | =head2 PROCESSLIST | ||
170 | 17201 | |||
171 | 17202 | If using L<"--processlist">, an C<id> attribute is available for | ||
172 | 17203 | the process ID, in addition to the common attributes. | ||
173 | 17204 | |||
174 | 17205 | =head2 MEMCACHED | ||
175 | 17206 | |||
176 | 17207 | These attributes are available when parsing L<"--type"> memcached. | ||
177 | 17208 | |||
178 | 17209 | =over | ||
179 | 17210 | |||
180 | 17211 | =item exptime | ||
181 | 17212 | |||
182 | 17213 | Expiration time. | ||
183 | 17214 | |||
184 | 17215 | =item key | ||
185 | 17216 | |||
186 | 17217 | The key used by cmd. | ||
187 | 17218 | |||
188 | 17219 | =item key_print | ||
189 | 17220 | |||
190 | 17221 | An abstracted form of the key. | ||
191 | 17222 | |||
192 | 17223 | =item Memc_add | ||
193 | 17224 | |||
194 | 17225 | Yes/No if the command is add. | ||
195 | 17226 | |||
196 | 17227 | =item Memc_append | ||
197 | 17228 | |||
198 | 17229 | Yes/No if the command is append. | ||
199 | 17230 | |||
200 | 17231 | =item Memc_cas | ||
201 | 17232 | |||
202 | 17233 | Yes/No if the command is cas. | ||
203 | 17234 | |||
204 | 17235 | =item Memc_error | ||
205 | 17236 | |||
206 | 17237 | Yes/No if command caused an error. Currently, the only error is when | ||
207 | 17238 | a retrieval command is interrupted. | ||
208 | 17239 | |||
209 | 17240 | =item Memc_get | ||
210 | 17241 | |||
211 | 17242 | Yes/No if the command is get. | ||
212 | 17243 | |||
213 | 17244 | =item Memc_gets | ||
214 | 17245 | |||
215 | 17246 | Yes/No if the command is gets. | ||
216 | 17247 | |||
217 | 17248 | =item Memc_miss | ||
218 | 17249 | |||
219 | 17250 | Yes/No if the command tried to access a nonexistent key. | ||
220 | 17251 | |||
221 | 17252 | =item Memc_prepend | ||
222 | 17253 | |||
223 | 17254 | Yes/No if the command is prepend. | ||
224 | 17255 | |||
225 | 17256 | =item Memc_replace | ||
226 | 17257 | |||
227 | 17258 | Yes/No if the command is replace. | ||
228 | 17259 | |||
229 | 17260 | =item Memc_set | ||
230 | 17261 | |||
231 | 17262 | Yes/No if the command is set. | ||
232 | 17263 | |||
233 | 17264 | =item res | ||
234 | 17265 | |||
235 | 17266 | Result of cmd. | ||
236 | 17267 | |||
237 | 17268 | =item val | ||
238 | 17269 | |||
239 | 17270 | The return value of cmd, if any. | ||
240 | 17271 | |||
241 | 17272 | =back | ||
242 | 17273 | |||
243 | 17072 | =head1 AUTHORS | 17274 | =head1 AUTHORS |
244 | 17073 | 17275 | ||
245 | 17074 | Baron Schwartz and Daniel Nichter | 17276 | Baron Schwartz and Daniel Nichter |
246 | 17075 | 17277 | ||
247 | === modified file 'bin/pt-stalk' | |||
248 | --- bin/pt-stalk 2012-09-20 13:59:16 +0000 | |||
249 | +++ bin/pt-stalk 2012-10-08 18:50:28 +0000 | |||
250 | @@ -933,6 +933,30 @@ | |||
251 | 933 | ITER=1 | 933 | ITER=1 |
252 | 934 | 934 | ||
253 | 935 | # ########################################################################### | 935 | # ########################################################################### |
254 | 936 | # Plugin hooks | ||
255 | 937 | # ########################################################################### | ||
256 | 938 | |||
257 | 939 | before_stalk() { | ||
258 | 940 | : | ||
259 | 941 | } | ||
260 | 942 | |||
261 | 943 | before_collect() { | ||
262 | 944 | : | ||
263 | 945 | } | ||
264 | 946 | |||
265 | 947 | after_collect() { | ||
266 | 948 | : | ||
267 | 949 | } | ||
268 | 950 | |||
269 | 951 | after_collect_sleep() { | ||
270 | 952 | : | ||
271 | 953 | } | ||
272 | 954 | |||
273 | 955 | after_stalk() { | ||
274 | 956 | : | ||
275 | 957 | } | ||
276 | 958 | |||
277 | 959 | # ########################################################################### | ||
278 | 936 | # Subroutines | 960 | # Subroutines |
279 | 937 | # ########################################################################### | 961 | # ########################################################################### |
280 | 938 | 962 | ||
281 | @@ -1016,12 +1040,12 @@ | |||
282 | 1016 | 1040 | ||
283 | 1017 | oktorun() { | 1041 | oktorun() { |
284 | 1018 | if [ $OKTORUN -eq 0 ]; then | 1042 | if [ $OKTORUN -eq 0 ]; then |
286 | 1019 | EXIT_REASON="OKTORUN is false" | 1043 | [ -z "$EXIT_REASON" ] && EXIT_REASON="OKTORUN is false" |
287 | 1020 | return 1 # stop running | 1044 | return 1 # stop running |
288 | 1021 | fi | 1045 | fi |
289 | 1022 | 1046 | ||
290 | 1023 | if [ -n "$OPT_ITERATIONS" ] && [ $ITER -gt $OPT_ITERATIONS ]; then | 1047 | if [ -n "$OPT_ITERATIONS" ] && [ $ITER -gt $OPT_ITERATIONS ]; then |
292 | 1024 | EXIT_REASON="no more iterations" | 1048 | [ -z "$EXIT_REASON" ] && EXIT_REASON="no more iterations" |
293 | 1025 | return 1 # stop running | 1049 | return 1 # stop running |
294 | 1026 | fi | 1050 | fi |
295 | 1027 | 1051 | ||
296 | @@ -1136,6 +1160,9 @@ | |||
297 | 1136 | log "pt-stalk ran with $RAN_WITH" >> "$OPT_DEST/$prefix-trigger" | 1160 | log "pt-stalk ran with $RAN_WITH" >> "$OPT_DEST/$prefix-trigger" |
298 | 1137 | last_prefix="$prefix" | 1161 | last_prefix="$prefix" |
299 | 1138 | 1162 | ||
300 | 1163 | # Plugin hook: | ||
301 | 1164 | before_collect | ||
302 | 1165 | |||
303 | 1139 | # Fork and background the collect subroutine which will | 1166 | # Fork and background the collect subroutine which will |
304 | 1140 | # run for --run-time seconds. We (the parent) sleep | 1167 | # run for --run-time seconds. We (the parent) sleep |
305 | 1141 | # while its collecting (hopefully --sleep is longer than | 1168 | # while its collecting (hopefully --sleep is longer than |
306 | @@ -1143,7 +1170,11 @@ | |||
307 | 1143 | ( | 1170 | ( |
308 | 1144 | collect "$OPT_DEST" "$prefix" | 1171 | collect "$OPT_DEST" "$prefix" |
309 | 1145 | ) >> "$OPT_DEST/$prefix-output" 2>&1 & | 1172 | ) >> "$OPT_DEST/$prefix-output" 2>&1 & |
311 | 1146 | log "Collector PID $!" | 1173 | local collector_pid=$! |
312 | 1174 | log "Collector PID $collector_pid" | ||
313 | 1175 | |||
314 | 1176 | # Plugin hook: | ||
315 | 1177 | after_collect $collector_pid | ||
316 | 1147 | else | 1178 | else |
317 | 1148 | # There will not be enough disk space, so do not collect. | 1179 | # There will not be enough disk space, so do not collect. |
318 | 1149 | warn "Collect canceled because there will not be enough disk space after collecting another $margin MB" | 1180 | warn "Collect canceled because there will not be enough disk space after collecting another $margin MB" |
319 | @@ -1156,6 +1187,9 @@ | |||
320 | 1156 | ITER=$((ITER + 1)) | 1187 | ITER=$((ITER + 1)) |
321 | 1157 | cycles_true=0 | 1188 | cycles_true=0 |
322 | 1158 | sleep_ok "$OPT_SLEEP" "Sleeping $OPT_SLEEP seconds after collect" | 1189 | sleep_ok "$OPT_SLEEP" "Sleeping $OPT_SLEEP seconds after collect" |
323 | 1190 | |||
324 | 1191 | # Plugin hook: | ||
325 | 1192 | after_collect_sleep | ||
326 | 1159 | else | 1193 | else |
327 | 1160 | # Trigger/check/value is ok, sleep until next check. | 1194 | # Trigger/check/value is ok, sleep until next check. |
328 | 1161 | sleep_ok "$OPT_INTERVAL" | 1195 | sleep_ok "$OPT_INTERVAL" |
329 | @@ -1178,7 +1212,7 @@ | |||
330 | 1178 | # Note: $$ is the parent's PID, but we're a child proc. | 1212 | # Note: $$ is the parent's PID, but we're a child proc. |
331 | 1179 | # Bash 4 has $BASHPID but we can't rely on that. Consequently, | 1213 | # Bash 4 has $BASHPID but we can't rely on that. Consequently, |
332 | 1180 | # we don't know our own PID. See the usage of $! below. | 1214 | # we don't know our own PID. See the usage of $! below. |
334 | 1181 | RAN_WITH="--function=$OPT_FUNCTION --variable=$OPT_VARIABLE --threshold=$OPT_THRESHOLD --match=$OPT_MATCH --cycles=$OPT_CYCLES --interval=$OPT_INTERVAL --iterations=$OPT_ITERATIONS --run-time=$OPT_RUN_TIME --sleep=$OPT_SLEEP --dest=$OPT_DEST --prefix=$OPT_PREFIX --notify-by-email=$OPT_NOTIFY_BY_EMAIL --log=$OPT_LOG --pid=$OPT_PID" | 1215 | RAN_WITH="--function=$OPT_FUNCTION --variable=$OPT_VARIABLE --threshold=$OPT_THRESHOLD --match=$OPT_MATCH --cycles=$OPT_CYCLES --interval=$OPT_INTERVAL --iterations=$OPT_ITERATIONS --run-time=$OPT_RUN_TIME --sleep=$OPT_SLEEP --dest=$OPT_DEST --prefix=$OPT_PREFIX --notify-by-email=$OPT_NOTIFY_BY_EMAIL --log=$OPT_LOG --pid=$OPT_PID --plugin=$OPT_PLUGIN" |
335 | 1182 | 1216 | ||
336 | 1183 | log "Starting $0 $RAN_WITH" | 1217 | log "Starting $0 $RAN_WITH" |
337 | 1184 | 1218 | ||
338 | @@ -1190,9 +1224,15 @@ | |||
339 | 1190 | # Make a secure tmpdir. | 1224 | # Make a secure tmpdir. |
340 | 1191 | mk_tmpdir | 1225 | mk_tmpdir |
341 | 1192 | 1226 | ||
342 | 1227 | # Plugin hook: | ||
343 | 1228 | before_stalk | ||
344 | 1229 | |||
345 | 1193 | # Stalk while oktorun. | 1230 | # Stalk while oktorun. |
346 | 1194 | stalk | 1231 | stalk |
347 | 1195 | 1232 | ||
348 | 1233 | # Plugin hook: | ||
349 | 1234 | after_stalk | ||
350 | 1235 | |||
351 | 1196 | # Clean up. | 1236 | # Clean up. |
352 | 1197 | rm_tmpdir | 1237 | rm_tmpdir |
353 | 1198 | remove_pid_file "$OPT_PID" | 1238 | remove_pid_file "$OPT_PID" |
354 | @@ -1217,6 +1257,15 @@ | |||
355 | 1217 | option_error "Invalid --function value: $OPT_FUNCTION" | 1257 | option_error "Invalid --function value: $OPT_FUNCTION" |
356 | 1218 | fi | 1258 | fi |
357 | 1219 | 1259 | ||
358 | 1260 | # Verify and source the --plugin. | ||
359 | 1261 | if [ "$OPT_PLUGIN" ]; then | ||
360 | 1262 | if [ -f "$OPT_PLUGIN" ]; then | ||
361 | 1263 | . "$OPT_PLUGIN" | ||
362 | 1264 | else | ||
363 | 1265 | option_error "Invalid --plugin value: $OPT_PLUGIN is not a file" | ||
364 | 1266 | fi | ||
365 | 1267 | fi | ||
366 | 1268 | |||
367 | 1220 | if [ -z "$OPT_STALK" -a "$OPT_COLLECT" ]; then | 1269 | if [ -z "$OPT_STALK" -a "$OPT_COLLECT" ]; then |
368 | 1221 | # Not stalking; do immediate collect once. | 1270 | # Not stalking; do immediate collect once. |
369 | 1222 | OPT_ITERATIONS=1 | 1271 | OPT_ITERATIONS=1 |
370 | @@ -1611,6 +1660,66 @@ | |||
371 | 1611 | 1660 | ||
372 | 1612 | Create a PID file when daemonized. | 1661 | Create a PID file when daemonized. |
373 | 1613 | 1662 | ||
374 | 1663 | =item --plugin | ||
375 | 1664 | |||
376 | 1665 | type: string | ||
377 | 1666 | |||
378 | 1667 | Load a plugin to hook into the tool and extend is functionality. | ||
379 | 1668 | The specified file does not need to be executable, nor does its first line | ||
380 | 1669 | need to be shebang line. It only needs to define one or more of these | ||
381 | 1670 | Bash functions: | ||
382 | 1671 | |||
383 | 1672 | =over | ||
384 | 1673 | |||
385 | 1674 | =item before_stalk | ||
386 | 1675 | |||
387 | 1676 | Called before stalking. | ||
388 | 1677 | |||
389 | 1678 | =item before_collect | ||
390 | 1679 | |||
391 | 1680 | Called when the stalk condition is triggered, before running a collector | ||
392 | 1681 | process as a backgrounded subshell. | ||
393 | 1682 | |||
394 | 1683 | =item after_collect | ||
395 | 1684 | |||
396 | 1685 | Called after running a collector process. The PID of the collector process | ||
397 | 1686 | is passed as the first argument. This hook is called before | ||
398 | 1687 | C<after_collect_sleep>. | ||
399 | 1688 | |||
400 | 1689 | =item after_collect_sleep | ||
401 | 1690 | |||
402 | 1691 | Called after sleeping L<"--sleep"> seconds for the collector process to finish. | ||
403 | 1692 | This hook is called after C<after_collect>. | ||
404 | 1693 | |||
405 | 1694 | =item after_stalk | ||
406 | 1695 | |||
407 | 1696 | Called after stalking. Since pt-stalk stalks forever by default, | ||
408 | 1697 | this hook is only called if L<"--iterations"> is specified. | ||
409 | 1698 | |||
410 | 1699 | =back | ||
411 | 1700 | |||
412 | 1701 | For example, a very simple plugin that touches a file when a collector | ||
413 | 1702 | process is triggered: | ||
414 | 1703 | |||
415 | 1704 | before_colllect() { | ||
416 | 1705 | touch /tmp/foo | ||
417 | 1706 | } | ||
418 | 1707 | |||
419 | 1708 | Since the plugin is completely sourced (imported) into the tool's namespace, | ||
420 | 1709 | be careful not to define other functions or global variables that already | ||
421 | 1710 | exist in the tool. You should prefix all plugin-specific functions and | ||
422 | 1711 | global variables with C<plugin_> or C<PLUGIN_>. | ||
423 | 1712 | |||
424 | 1713 | Plugins have access to all command line options but they should not modify | ||
425 | 1714 | them. Each option is a global variable like C<$OPT_DEST> which corresponds | ||
426 | 1715 | to L<"--dest">. Therefore, the global variable for each command line option | ||
427 | 1716 | is C<OPT_> plus the option name in all caps with hyphens replaced by | ||
428 | 1717 | underscores. | ||
429 | 1718 | |||
430 | 1719 | Plugins can stop the tool by setting the global variable C<OKTORUN> | ||
431 | 1720 | to C<1>. In this case, the global variable C<EXIT_REASON> should also | ||
432 | 1721 | be set to indicate why the tool was stopped. | ||
433 | 1722 | |||
434 | 1614 | =item --prefix | 1723 | =item --prefix |
435 | 1615 | 1724 | ||
436 | 1616 | type: string | 1725 | type: string |
437 | 1617 | 1726 | ||
438 | === modified file 'bin/pt-table-checksum' | |||
439 | --- bin/pt-table-checksum 2012-10-05 22:28:45 +0000 | |||
440 | +++ bin/pt-table-checksum 2012-10-08 18:50:28 +0000 | |||
441 | @@ -3320,7 +3320,9 @@ | |||
442 | 3320 | PTDEBUG && _d($sql); | 3320 | PTDEBUG && _d($sql); |
443 | 3321 | my $row = $self->{dbh}->selectrow_arrayref($sql); | 3321 | my $row = $self->{dbh}->selectrow_arrayref($sql); |
444 | 3322 | PTDEBUG && _d(defined $row ? @$row : 'undef'); | 3322 | PTDEBUG && _d(defined $row ? @$row : 'undef'); |
446 | 3323 | $self->{is_cluster_node} = $row && $row->[0] ? 1 : 0; | 3323 | $self->{is_cluster_node} = $row && $row->[1] |
447 | 3324 | ? ($row->[1] eq 'ON' || $row->[1] eq '1') | ||
448 | 3325 | : 0; | ||
449 | 3324 | 3326 | ||
450 | 3325 | return $self->{is_cluster_node}; | 3327 | return $self->{is_cluster_node}; |
451 | 3326 | } | 3328 | } |
452 | @@ -5146,6 +5148,9 @@ | |||
453 | 5146 | my $func = $args{func} || uc($o->get('function')); | 5148 | my $func = $args{func} || uc($o->get('function')); |
454 | 5147 | my $cols = $self->get_checksum_columns(%args); | 5149 | my $cols = $self->get_checksum_columns(%args); |
455 | 5148 | 5150 | ||
456 | 5151 | die "all columns are excluded by --columns or --ignore-columns" | ||
457 | 5152 | unless @{$cols->{select}}; | ||
458 | 5153 | |||
459 | 5149 | my $query; | 5154 | my $query; |
460 | 5150 | if ( !$args{no_cols} ) { | 5155 | if ( !$args{no_cols} ) { |
461 | 5151 | $query = join(', ', | 5156 | $query = join(', ', |
462 | @@ -9340,11 +9345,20 @@ | |||
463 | 9340 | # Make a nibble iterator for this table. This should only fail | 9345 | # Make a nibble iterator for this table. This should only fail |
464 | 9341 | # if the table has no indexes and is too large to checksum in | 9346 | # if the table has no indexes and is too large to checksum in |
465 | 9342 | # one chunk. | 9347 | # one chunk. |
471 | 9343 | my $checksum_cols = $rc->make_chunk_checksum( | 9348 | my $checksum_cols = eval { |
472 | 9344 | dbh => $master_cxn->dbh(), | 9349 | $rc->make_chunk_checksum( |
473 | 9345 | tbl => $tbl, | 9350 | dbh => $master_cxn->dbh(), |
474 | 9346 | %crc_args | 9351 | tbl => $tbl, |
475 | 9347 | ); | 9352 | %crc_args |
476 | 9353 | ); | ||
477 | 9354 | }; | ||
478 | 9355 | |||
479 | 9356 | if ( $EVAL_ERROR ) { | ||
480 | 9357 | warn ts("Skipping table $tbl->{db}.$tbl->{tbl} because " | ||
481 | 9358 | . "$EVAL_ERROR\n"); | ||
482 | 9359 | return; | ||
483 | 9360 | } | ||
484 | 9361 | |||
485 | 9348 | my $nibble_iter; | 9362 | my $nibble_iter; |
486 | 9349 | eval { | 9363 | eval { |
487 | 9350 | $nibble_iter = new OobNibbleIterator( | 9364 | $nibble_iter = new OobNibbleIterator( |
488 | @@ -10664,7 +10678,8 @@ | |||
489 | 10664 | 10678 | ||
490 | 10665 | short form: -c; type: array; group: Filter | 10679 | short form: -c; type: array; group: Filter |
491 | 10666 | 10680 | ||
493 | 10667 | Checksum only this comma-separated list of columns. | 10681 | Checksum only this comma-separated list of columns. If a table doesn't have |
494 | 10682 | any of the specified columns it will be skipped. | ||
495 | 10668 | 10683 | ||
496 | 10669 | =item --config | 10684 | =item --config |
497 | 10670 | 10685 | ||
498 | @@ -10780,6 +10795,8 @@ | |||
499 | 10780 | type: Hash; group: Filter | 10795 | type: Hash; group: Filter |
500 | 10781 | 10796 | ||
501 | 10782 | Ignore this comma-separated list of columns when calculating the checksum. | 10797 | Ignore this comma-separated list of columns when calculating the checksum. |
502 | 10798 | If a table has all of its columns filtered by --ignore-columns, it will | ||
503 | 10799 | be skipped. | ||
504 | 10783 | 10800 | ||
505 | 10784 | =item --ignore-databases | 10801 | =item --ignore-databases |
506 | 10785 | 10802 | ||
507 | @@ -11313,6 +11330,12 @@ | |||
508 | 11313 | cannot be detected automatically. The lag check (see L<"REPLICA CHECKS">) | 11330 | cannot be detected automatically. The lag check (see L<"REPLICA CHECKS">) |
509 | 11314 | is not performed for cluster nodes. | 11331 | is not performed for cluster nodes. |
510 | 11315 | 11332 | ||
511 | 11333 | Mixed replication setups are not currently supported. For example, the tool | ||
512 | 11334 | does not work completely if the master host is replicating to a cluster, | ||
513 | 11335 | or if the cluster is replicating to another cluster. In short, the only | ||
514 | 11336 | supported setup is a single cluster with nodes optionally having traditional | ||
515 | 11337 | replication slaves. | ||
516 | 11338 | |||
517 | 11316 | =back | 11339 | =back |
518 | 11317 | 11340 | ||
519 | 11318 | =head1 BUGS | 11341 | =head1 BUGS |
520 | 11319 | 11342 | ||
521 | === modified file 'lib/Cxn.pm' | |||
522 | --- lib/Cxn.pm 2012-08-29 22:35:17 +0000 | |||
523 | +++ lib/Cxn.pm 2012-10-08 18:50:28 +0000 | |||
524 | @@ -203,7 +203,9 @@ | |||
525 | 203 | PTDEBUG && _d($sql); | 203 | PTDEBUG && _d($sql); |
526 | 204 | my $row = $self->{dbh}->selectrow_arrayref($sql); | 204 | my $row = $self->{dbh}->selectrow_arrayref($sql); |
527 | 205 | PTDEBUG && _d(defined $row ? @$row : 'undef'); | 205 | PTDEBUG && _d(defined $row ? @$row : 'undef'); |
529 | 206 | $self->{is_cluster_node} = $row && $row->[0] ? 1 : 0; | 206 | $self->{is_cluster_node} = $row && $row->[1] |
530 | 207 | ? ($row->[1] eq 'ON' || $row->[1] eq '1') | ||
531 | 208 | : 0; | ||
532 | 207 | 209 | ||
533 | 208 | return $self->{is_cluster_node}; | 210 | return $self->{is_cluster_node}; |
534 | 209 | } | 211 | } |
535 | 210 | 212 | ||
536 | === modified file 'lib/RowChecksum.pm' | |||
537 | --- lib/RowChecksum.pm 2012-06-07 03:36:07 +0000 | |||
538 | +++ lib/RowChecksum.pm 2012-10-08 18:50:28 +0000 | |||
539 | @@ -67,6 +67,11 @@ | |||
540 | 67 | my $func = $args{func} || uc($o->get('function')); | 67 | my $func = $args{func} || uc($o->get('function')); |
541 | 68 | my $cols = $self->get_checksum_columns(%args); | 68 | my $cols = $self->get_checksum_columns(%args); |
542 | 69 | 69 | ||
543 | 70 | # Skip tables that have all their columns skipped; See | ||
544 | 71 | # https://bugs.launchpad.net/percona-toolkit/+bug/1016131 | ||
545 | 72 | die "all columns are excluded by --columns or --ignore-columns" | ||
546 | 73 | unless @{$cols->{select}}; | ||
547 | 74 | |||
548 | 70 | # Prepend columns to query, resulting in "col1, col2, FUNC(..col1, col2...)", | 75 | # Prepend columns to query, resulting in "col1, col2, FUNC(..col1, col2...)", |
549 | 71 | # unless caller says not to. The only caller that says not to is | 76 | # unless caller says not to. The only caller that says not to is |
550 | 72 | # make_chunk_checksum() which uses this row checksum as part of a larger | 77 | # make_chunk_checksum() which uses this row checksum as part of a larger |
551 | 73 | 78 | ||
552 | === modified file 't/lib/Pingback.t' | |||
553 | --- t/lib/Pingback.t 2012-09-13 13:39:04 +0000 | |||
554 | +++ t/lib/Pingback.t 2012-10-08 18:50:28 +0000 | |||
555 | @@ -126,9 +126,19 @@ | |||
556 | 126 | ); | 126 | ); |
557 | 127 | } | 127 | } |
558 | 128 | 128 | ||
559 | 129 | my $expect_post; | ||
560 | 130 | if ( $args{post} ) { | ||
561 | 131 | $expect_post = join("\n", | ||
562 | 132 | map { "$_->{id};$_->{item};$_->{val}" } | ||
563 | 133 | sort { | ||
564 | 134 | $a->{item} cmp $b->{item} || | ||
565 | 135 | $a->{id} cmp $b->{id} | ||
566 | 136 | } @{$args{post}}); | ||
567 | 137 | $expect_post .= "\n"; | ||
568 | 138 | } | ||
569 | 129 | is( | 139 | is( |
570 | 130 | $post ? ($post->{content} || '') : '', | 140 | $post ? ($post->{content} || '') : '', |
572 | 131 | $args{post}, | 141 | $expect_post || '', |
573 | 132 | "$args{name} client response" | 142 | "$args{name} client response" |
574 | 133 | ); | 143 | ); |
575 | 134 | 144 | ||
576 | @@ -152,7 +162,18 @@ | |||
577 | 152 | } | 162 | } |
578 | 153 | ], | 163 | ], |
579 | 154 | # client should POST this | 164 | # client should POST this |
581 | 155 | post => "$general_id;Data::Dumper;$dd_ver\n$general_id;Perl;$perl_ver\n", | 165 | post => [ |
582 | 166 | { | ||
583 | 167 | item => 'Data::Dumper', | ||
584 | 168 | id => $general_id, | ||
585 | 169 | val => $dd_ver, | ||
586 | 170 | }, | ||
587 | 171 | { | ||
588 | 172 | item => 'Perl', | ||
589 | 173 | id => $general_id, | ||
590 | 174 | val => $perl_ver, | ||
591 | 175 | }, | ||
592 | 176 | ], | ||
593 | 156 | # Server should return these suggetions after the client posts | 177 | # Server should return these suggetions after the client posts |
594 | 157 | sug => [ | 178 | sug => [ |
595 | 158 | 'Data::Printer is nicer.', | 179 | 'Data::Printer is nicer.', |
596 | @@ -174,7 +195,18 @@ | |||
597 | 174 | content => "", | 195 | content => "", |
598 | 175 | } | 196 | } |
599 | 176 | ], | 197 | ], |
601 | 177 | post => "$general_id;Data::Dumper;$dd_ver\n$general_id;Perl;$perl_ver\n", | 198 | post => [ |
602 | 199 | { | ||
603 | 200 | item => 'Data::Dumper', | ||
604 | 201 | id => $general_id, | ||
605 | 202 | val => $dd_ver, | ||
606 | 203 | }, | ||
607 | 204 | { | ||
608 | 205 | item => 'Perl', | ||
609 | 206 | id => $general_id, | ||
610 | 207 | val => $perl_ver, | ||
611 | 208 | }, | ||
612 | 209 | ], | ||
613 | 178 | sug => undef, | 210 | sug => undef, |
614 | 179 | ); | 211 | ); |
615 | 180 | 212 | ||
616 | @@ -184,7 +216,7 @@ | |||
617 | 184 | name => "No response to GET", | 216 | name => "No response to GET", |
618 | 185 | response => [], | 217 | response => [], |
619 | 186 | no_response => 1, | 218 | no_response => 1, |
621 | 187 | post => "", | 219 | post => undef, |
622 | 188 | sug => undef, | 220 | sug => undef, |
623 | 189 | ); | 221 | ); |
624 | 190 | 222 | ||
625 | @@ -199,7 +231,18 @@ | |||
626 | 199 | content => "Perl;perl_version;PERL_VERSION\nData::Dumper;perl_module_version\n", | 231 | content => "Perl;perl_version;PERL_VERSION\nData::Dumper;perl_module_version\n", |
627 | 200 | }, | 232 | }, |
628 | 201 | ], | 233 | ], |
630 | 202 | post => "$general_id;Data::Dumper;$dd_ver\n$general_id;Perl;$perl_ver\n", | 234 | post => [ |
631 | 235 | { | ||
632 | 236 | id => $general_id, | ||
633 | 237 | item => 'Data::Dumper', | ||
634 | 238 | val => $dd_ver, | ||
635 | 239 | }, | ||
636 | 240 | { | ||
637 | 241 | id => $general_id, | ||
638 | 242 | item => 'Perl', | ||
639 | 243 | val => $perl_ver, | ||
640 | 244 | }, | ||
641 | 245 | ], | ||
642 | 203 | sug => undef, | 246 | sug => undef, |
643 | 204 | ); | 247 | ); |
644 | 205 | 248 | ||
645 | @@ -223,7 +266,13 @@ | |||
646 | 223 | } | 266 | } |
647 | 224 | ], | 267 | ], |
648 | 225 | # client should POST this | 268 | # client should POST this |
650 | 226 | post => "$master_id;MySQL;$mysql_ver $mysql_distro\n", | 269 | post => [ |
651 | 270 | { | ||
652 | 271 | id => $master_id, | ||
653 | 272 | item => 'MySQL', | ||
654 | 273 | val => "$mysql_ver $mysql_distro", | ||
655 | 274 | } | ||
656 | 275 | ], | ||
657 | 227 | # Server should return these suggetions after the client posts | 276 | # Server should return these suggetions after the client posts |
658 | 228 | sug => ['Percona Server is fast.'], | 277 | sug => ['Percona Server is fast.'], |
659 | 229 | ); | 278 | ); |
660 | @@ -440,7 +489,18 @@ | |||
661 | 440 | } | 489 | } |
662 | 441 | ], | 490 | ], |
663 | 442 | # client should POST this | 491 | # client should POST this |
665 | 443 | post => "$slave1_id;MySQL;$mysql_ver $mysql_distro\n$master_id;MySQL;$mysql_ver $mysql_distro\n", | 492 | post => [ |
666 | 493 | { | ||
667 | 494 | id => $slave1_id, | ||
668 | 495 | item => 'MySQL', | ||
669 | 496 | val => "$mysql_ver $mysql_distro", | ||
670 | 497 | }, | ||
671 | 498 | { | ||
672 | 499 | id => $master_id, | ||
673 | 500 | item => 'MySQL', | ||
674 | 501 | val => "$mysql_ver $mysql_distro", | ||
675 | 502 | } | ||
676 | 503 | ], | ||
677 | 444 | # Server should return these suggetions after the client posts | 504 | # Server should return these suggetions after the client posts |
678 | 445 | sug => [ | 505 | sug => [ |
679 | 446 | 'Percona Server is fast.', | 506 | 'Percona Server is fast.', |
680 | 447 | 507 | ||
681 | === modified file 't/lib/RowChecksum.t' | |||
682 | --- t/lib/RowChecksum.t 2012-06-03 17:54:32 +0000 | |||
683 | +++ t/lib/RowChecksum.t 2012-10-08 18:50:28 +0000 | |||
684 | @@ -26,9 +26,6 @@ | |||
685 | 26 | if ( !$dbh ) { | 26 | if ( !$dbh ) { |
686 | 27 | plan skip_all => "Cannot connect to sandbox master"; | 27 | plan skip_all => "Cannot connect to sandbox master"; |
687 | 28 | } | 28 | } |
688 | 29 | else { | ||
689 | 30 | plan tests => 29; | ||
690 | 31 | } | ||
691 | 32 | 29 | ||
692 | 33 | $sb->create_dbs($dbh, ['test']); | 30 | $sb->create_dbs($dbh, ['test']); |
693 | 34 | 31 | ||
694 | @@ -421,9 +418,53 @@ | |||
695 | 421 | 'Ignores specified columns' | 418 | 'Ignores specified columns' |
696 | 422 | ); | 419 | ); |
697 | 423 | 420 | ||
698 | 421 | # ############################################################################# | ||
699 | 422 | # crash with --columns if none match / --ignore-columns if everything is ignored | ||
700 | 423 | # https://bugs.launchpad.net/percona-toolkit/+bug/1016131 | ||
701 | 424 | # ############################################################################# | ||
702 | 425 | # Re-using the $tbl from the previous test! | ||
703 | 426 | local @ARGV = ('--ignore-columns', 'a,b,c'); | ||
704 | 427 | $o->get_opts(); | ||
705 | 428 | local $EVAL_ERROR; | ||
706 | 429 | eval { | ||
707 | 430 | $c->make_row_checksum( | ||
708 | 431 | tbl => $tbl, | ||
709 | 432 | func => 'CRC32', | ||
710 | 433 | ); | ||
711 | 434 | }; | ||
712 | 435 | |||
713 | 436 | like( | ||
714 | 437 | $EVAL_ERROR, | ||
715 | 438 | qr/all columns are excluded by --columns or --ignore-columns/, | ||
716 | 439 | "Dies if all columns are ignored by --ignore-columns" | ||
717 | 440 | ); | ||
718 | 441 | |||
719 | 442 | |||
720 | 443 | $tbl = { | ||
721 | 444 | db => 'mysql', | ||
722 | 445 | tbl => 'user', | ||
723 | 446 | tbl_struct => $tp->parse($tp->get_create_table($dbh, 'mysql', 'user')), | ||
724 | 447 | }; | ||
725 | 448 | local @ARGV = qw(--columns some_column_that_doesnt_exist); | ||
726 | 449 | $o->get_opts(); | ||
727 | 450 | local $EVAL_ERROR; | ||
728 | 451 | eval { | ||
729 | 452 | $c->make_row_checksum( | ||
730 | 453 | tbl => $tbl, | ||
731 | 454 | func => 'SHA1', | ||
732 | 455 | ); | ||
733 | 456 | }; | ||
734 | 457 | |||
735 | 458 | like( | ||
736 | 459 | $EVAL_ERROR, | ||
737 | 460 | qr/all columns are excluded by --columns or --ignore-columns/, | ||
738 | 461 | 'Dies if all columns are ignored by --columns' | ||
739 | 462 | ); | ||
740 | 463 | |||
741 | 424 | # ############################################################################ | 464 | # ############################################################################ |
742 | 425 | # Done. | 465 | # Done. |
743 | 426 | # ############################################################################ | 466 | # ############################################################################ |
744 | 427 | $sb->wipe_clean($dbh); | 467 | $sb->wipe_clean($dbh); |
745 | 428 | ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox"); | 468 | ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox"); |
747 | 429 | exit; | 469 | |
748 | 470 | done_testing; | ||
749 | 430 | 471 | ||
750 | === added file 't/pt-stalk/plugin.t' | |||
751 | --- t/pt-stalk/plugin.t 1970-01-01 00:00:00 +0000 | |||
752 | +++ t/pt-stalk/plugin.t 2012-10-08 18:50:28 +0000 | |||
753 | @@ -0,0 +1,74 @@ | |||
754 | 1 | #!/usr/bin/env perl | ||
755 | 2 | |||
756 | 3 | BEGIN { | ||
757 | 4 | die "The PERCONA_TOOLKIT_BRANCH environment variable is not set.\n" | ||
758 | 5 | unless $ENV{PERCONA_TOOLKIT_BRANCH} && -d $ENV{PERCONA_TOOLKIT_BRANCH}; | ||
759 | 6 | unshift @INC, "$ENV{PERCONA_TOOLKIT_BRANCH}/lib"; | ||
760 | 7 | }; | ||
761 | 8 | |||
762 | 9 | use strict; | ||
763 | 10 | use warnings FATAL => 'all'; | ||
764 | 11 | use English qw(-no_match_vars); | ||
765 | 12 | use Test::More; | ||
766 | 13 | use Time::HiRes qw(sleep); | ||
767 | 14 | |||
768 | 15 | use PerconaTest; | ||
769 | 16 | use DSNParser; | ||
770 | 17 | use Sandbox; | ||
771 | 18 | |||
772 | 19 | my $dp = new DSNParser(opts=>$dsn_opts); | ||
773 | 20 | my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp); | ||
774 | 21 | my $dbh = $sb->get_dbh_for('master'); | ||
775 | 22 | |||
776 | 23 | if ( !$dbh ) { | ||
777 | 24 | plan skip_all => 'Cannot connect to sandbox master'; | ||
778 | 25 | } | ||
779 | 26 | |||
780 | 27 | my $cnf = "/tmp/12345/my.sandbox.cnf"; | ||
781 | 28 | my $pid_file = "/tmp/pt-stalk.pid.$PID"; | ||
782 | 29 | my $log_file = "/tmp/pt-stalk.log.$PID"; | ||
783 | 30 | my $dest = "/tmp/pt-stalk.collect.$PID"; | ||
784 | 31 | my $output; | ||
785 | 32 | my $retval; | ||
786 | 33 | my $pid; | ||
787 | 34 | |||
788 | 35 | diag(`rm $pid_file 2>/dev/null`); | ||
789 | 36 | diag(`rm $log_file 2>/dev/null`); | ||
790 | 37 | diag(`mkdir $dest`); | ||
791 | 38 | |||
792 | 39 | # We'll have to watch Uptime since it's the only status var that's going | ||
793 | 40 | # to be predictable. | ||
794 | 41 | my (undef, $uptime) = $dbh->selectrow_array("SHOW STATUS LIKE 'Uptime'"); | ||
795 | 42 | my $threshold = $uptime + 2; | ||
796 | 43 | |||
797 | 44 | $retval = system("$trunk/bin/pt-stalk --iterations 1 --dest $dest --variable Uptime --threshold $threshold --cycles 1 --run-time 2 --pid $pid_file --plugin $trunk/t/pt-stalk/samples/plugin001.sh -- --defaults-file=$cnf >$log_file 2>&1"); | ||
798 | 45 | |||
799 | 46 | PerconaTest::wait_until(sub { !-f $pid_file }); | ||
800 | 47 | |||
801 | 48 | is( | ||
802 | 49 | $retval >> 8, | ||
803 | 50 | 0, | ||
804 | 51 | "Exit 0" | ||
805 | 52 | ); | ||
806 | 53 | |||
807 | 54 | foreach my $hook (qw( | ||
808 | 55 | before_stalk | ||
809 | 56 | before_collect | ||
810 | 57 | after_collect | ||
811 | 58 | after_collect_sleep | ||
812 | 59 | after_stalk | ||
813 | 60 | )) { | ||
814 | 61 | ok( | ||
815 | 62 | -f "$dest/$hook", | ||
816 | 63 | "$hook hook called" | ||
817 | 64 | ); | ||
818 | 65 | } | ||
819 | 66 | |||
820 | 67 | # ############################################################################# | ||
821 | 68 | # Done. | ||
822 | 69 | # ############################################################################# | ||
823 | 70 | diag(`rm $pid_file 2>/dev/null`); | ||
824 | 71 | diag(`rm $log_file 2>/dev/null`); | ||
825 | 72 | diag(`rm -rf $dest 2>/dev/null`); | ||
826 | 73 | ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox"); | ||
827 | 74 | done_testing; | ||
828 | 0 | 75 | ||
829 | === added file 't/pt-stalk/samples/plugin001.sh' | |||
830 | --- t/pt-stalk/samples/plugin001.sh 1970-01-01 00:00:00 +0000 | |||
831 | +++ t/pt-stalk/samples/plugin001.sh 2012-10-08 18:50:28 +0000 | |||
832 | @@ -0,0 +1,21 @@ | |||
833 | 1 | #!/bin/sh | ||
834 | 2 | |||
835 | 3 | before_stalk() { | ||
836 | 4 | date >> "$OPT_DEST/before_stalk" | ||
837 | 5 | } | ||
838 | 6 | |||
839 | 7 | before_collect() { | ||
840 | 8 | date >> "$OPT_DEST/before_collect" | ||
841 | 9 | } | ||
842 | 10 | |||
843 | 11 | after_collect() { | ||
844 | 12 | date >> "$OPT_DEST/after_collect" | ||
845 | 13 | } | ||
846 | 14 | |||
847 | 15 | after_collect_sleep() { | ||
848 | 16 | date >> "$OPT_DEST/after_collect_sleep" | ||
849 | 17 | } | ||
850 | 18 | |||
851 | 19 | after_stalk() { | ||
852 | 20 | date >> "$OPT_DEST/after_stalk" | ||
853 | 21 | } | ||
854 | 0 | 22 | ||
855 | === modified file 't/pt-table-checksum/bugs.t' | |||
856 | --- t/pt-table-checksum/bugs.t 2012-07-27 17:52:24 +0000 | |||
857 | +++ t/pt-table-checksum/bugs.t 2012-10-08 18:50:28 +0000 | |||
858 | @@ -176,6 +176,22 @@ | |||
859 | 176 | ); | 176 | ); |
860 | 177 | 177 | ||
861 | 178 | # ############################################################################# | 178 | # ############################################################################# |
862 | 179 | # pt-table-checksum can crash with --columns if none match | ||
863 | 180 | # https://bugs.launchpad.net/percona-toolkit/+bug/1016131 | ||
864 | 181 | # ############################################################################# | ||
865 | 182 | |||
866 | 183 | ($output) = full_output( | ||
867 | 184 | sub { pt_table_checksum::main(@args, '--tables', 'mysql.user,mysql.host', | ||
868 | 185 | '--columns', 'some_fale_column') }, | ||
869 | 186 | ); | ||
870 | 187 | |||
871 | 188 | like( | ||
872 | 189 | $output, | ||
873 | 190 | qr/\QSkipping table mysql.user because all columns are excluded by --columns or --ignore-columns/, | ||
874 | 191 | "Bug 1016131: ptc should skip tables where all columns are excluded" | ||
875 | 192 | ); | ||
876 | 193 | |||
877 | 194 | # ############################################################################# | ||
878 | 179 | # Done. | 195 | # Done. |
879 | 180 | # ############################################################################# | 196 | # ############################################################################# |
880 | 181 | $sb->wipe_clean($master_dbh); | 197 | $sb->wipe_clean($master_dbh); |
881 | 182 | 198 | ||
882 | === modified file 't/pt-table-checksum/run_time.t' | |||
883 | --- t/pt-table-checksum/run_time.t 2012-07-18 16:07:27 +0000 | |||
884 | +++ t/pt-table-checksum/run_time.t 2012-10-08 18:50:28 +0000 | |||
885 | @@ -38,16 +38,16 @@ | |||
886 | 38 | my $output; | 38 | my $output; |
887 | 39 | my $exit_status; | 39 | my $exit_status; |
888 | 40 | 40 | ||
890 | 41 | # On my 2.4 GHz with SSD this takes a little more than 3s, | 41 | # On my 2.4 GHz with SSD this takes a little more than 5s, |
891 | 42 | # so no test servers should be faster, hopefully. | 42 | # so no test servers should be faster, hopefully. |
892 | 43 | my $t0 = time; | 43 | my $t0 = time; |
893 | 44 | $exit_status = pt_table_checksum::main(@args, | 44 | $exit_status = pt_table_checksum::main(@args, |
895 | 45 | qw(--quiet --quiet -d sakila --chunk-size 100 --run-time 1)); | 45 | qw(--quiet --quiet -d sakila --chunk-size 50 --run-time 1)); |
896 | 46 | my $t = time - $t0; | 46 | my $t = time - $t0; |
897 | 47 | 47 | ||
898 | 48 | ok( | 48 | ok( |
901 | 49 | $t >= 1.5 && $t <= 2.0, | 49 | $t >= 1.5 && $t <= 2.5, |
902 | 50 | "Run in roughly --run-time 1 second" | 50 | "Ran in roughly --run-time 1 second" |
903 | 51 | ) or diag("Actual run time: $t"); | 51 | ) or diag("Actual run time: $t"); |
904 | 52 | 52 | ||
905 | 53 | my $rows = $master_dbh->selectall_arrayref("SELECT DISTINCT CONCAT(db, '.', tbl) FROM percona.checksums ORDER by db, tbl"); | 53 | my $rows = $master_dbh->selectall_arrayref("SELECT DISTINCT CONCAT(db, '.', tbl) FROM percona.checksums ORDER by db, tbl"); |