Merge lp:~percona-toolkit-dev/percona-toolkit/release-2.2.12 into lp:percona-toolkit/2.2

Proposed by Tomislav Plavcic
Status: Merged
Merged at revision: 611
Proposed branch: lp:~percona-toolkit-dev/percona-toolkit/release-2.2.12
Merge into: lp:percona-toolkit/2.2
Diff against target: 2086 lines (+720/-172)
50 files modified
Changelog (+12/-0)
Makefile.PL (+1/-1)
bin/pt-align (+9/-1)
bin/pt-archiver (+13/-2)
bin/pt-config-diff (+24/-5)
bin/pt-deadlock-logger (+24/-5)
bin/pt-diskstats (+2/-2)
bin/pt-duplicate-key-checker (+2/-2)
bin/pt-fifo-split (+9/-1)
bin/pt-find (+2/-2)
bin/pt-fingerprint (+9/-1)
bin/pt-fk-error-logger (+24/-5)
bin/pt-heartbeat (+28/-2)
bin/pt-index-usage (+2/-2)
bin/pt-ioprofile (+5/-2)
bin/pt-kill (+24/-5)
bin/pt-mext (+30/-24)
bin/pt-mysql-summary (+3/-1)
bin/pt-online-schema-change (+61/-8)
bin/pt-pmp (+5/-2)
bin/pt-query-digest (+26/-4)
bin/pt-show-grants (+9/-1)
bin/pt-sift (+5/-2)
bin/pt-slave-delay (+2/-2)
bin/pt-slave-find (+9/-1)
bin/pt-slave-restart (+2/-2)
bin/pt-stalk (+15/-2)
bin/pt-summary (+3/-1)
bin/pt-table-checksum (+58/-14)
bin/pt-table-sync (+2/-2)
bin/pt-table-usage (+9/-1)
bin/pt-upgrade (+24/-5)
bin/pt-variable-advisor (+2/-2)
bin/pt-visual-explain (+9/-1)
config/deb/changelog (+13/-0)
config/sphinx-build/conf.py (+1/-1)
docs/percona-toolkit.pod (+1/-1)
docs/release_notes.rst (+35/-0)
lib/Cxn.pm (+19/-2)
lib/OptionParser.pm (+10/-0)
lib/Percona/Toolkit.pm (+1/-1)
lib/Percona/XtraDB/Cluster.pm (+23/-2)
lib/bash/collect.sh (+9/-0)
lib/bash/parse_options.sh (+3/-0)
t/lib/OptionParser.t (+23/-0)
t/pt-archiver/basics.t (+1/-1)
t/pt-archiver/indexes.t (+1/-1)
t/pt-archiver/samples/issue-248.txt (+2/-2)
t/pt-query-digest/binlog_analyses.t (+21/-1)
t/pt-table-checksum/pxc.t (+93/-47)
To merge this branch: bzr merge lp:~percona-toolkit-dev/percona-toolkit/release-2.2.12
Reviewer Review Type Date Requested Status
Daniel Nichter Pending
Review via email: mp+241804@code.launchpad.net

Description of the change

Release branch for version 2.2.12

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Changelog'
2--- Changelog 2014-09-25 13:48:22 +0000
3+++ Changelog 2014-11-14 14:12:25 +0000
4@@ -1,5 +1,17 @@
5 Changelog for Percona Toolkit
6
7+v2.2.12 released 2014-11-14
8+
9+
10+ * Fixed bug 1376561: pt-archiver is not able to archive all the rows when a table has a hash partition
11+ * Fixed bug 1328686: pt-heartbeat check-read-only option does not prevent creates or inserts
12+ * Fixed bug 1269695: pt-online-schema-change does not allow ALTER for a table without a non-unique, while manual does not explain this
13+ * Fixed bug 1217466: pt-table-checksum refuses to run on PXC if server_id is the same on all nodes
14+ * Fixed bug 1373937: pt-table-checksum requires recursion when working with and XtraDB Cluster node
15+ * Fixed bug 1377888: pt-query-digest manual for --type binlog is ambiguous
16+ * Fixed bug 1349086: pt-stalk should also gather dmesg output
17+ * Fixed bug 1361293: Some scripts fail when no-version-check option is put in global config file
18+
19 v2.2.11 released 2014-09-26
20
21 * Fixed bug 1262456: pt-query-digest doesn't report host details
22
23=== modified file 'Makefile.PL'
24--- Makefile.PL 2014-09-25 13:48:22 +0000
25+++ Makefile.PL 2014-11-14 14:12:25 +0000
26@@ -2,7 +2,7 @@
27
28 WriteMakefile(
29 NAME => 'percona-toolkit',
30- VERSION => '2.2.11',
31+ VERSION => '2.2.12',
32 EXE_FILES => [ <bin/*> ],
33 MAN1PODS => {
34 'docs/percona-toolkit.pod' => 'blib/man1/percona-toolkit.1p',
35
36=== modified file 'bin/pt-align'
37--- bin/pt-align 2014-09-25 13:48:22 +0000
38+++ bin/pt-align 2014-11-14 14:12:25 +0000
39@@ -901,6 +901,14 @@
40 $parse = 0;
41 next LINE;
42 }
43+
44+ if ( $parse
45+ && !$self->has('version-check')
46+ && $line =~ /version-check/
47+ ) {
48+ next LINE;
49+ }
50+
51 if ( $parse
52 && (my($opt, $arg) = $line =~ m/^\s*([^=\s]+?)(?:\s*=\s*(.*?)\s*)?$/)
53 ) {
54@@ -1323,6 +1331,6 @@
55
56 =head1 VERSION
57
58-pt-align 2.2.11
59+pt-align 2.2.12
60
61 =cut
62
63=== modified file 'bin/pt-archiver'
64--- bin/pt-archiver 2014-09-25 13:48:22 +0000
65+++ bin/pt-archiver 2014-11-14 14:12:25 +0000
66@@ -43,7 +43,7 @@
67 {
68 package Percona::Toolkit;
69
70-our $VERSION = '2.2.11';
71+our $VERSION = '2.2.12';
72
73 use strict;
74 use warnings FATAL => 'all';
75@@ -5811,7 +5811,18 @@
76 $next_sql .= " AND $sel_stmt->{where}";
77 }
78
79+ # Obtain index cols so we can order them when ascending
80+ # this ensures returned sets are disjoint when ran on partitioned tables
81+ # issue 1376561
82+ my $index_cols;
83+ if ( $sel_stmt->{index}
84+ && $src->{info}->{keys}->{$sel_stmt->{index}}->{cols}
85+ ) {
86+ $index_cols = $src->{info}->{keys}->{$sel_stmt->{index}}->{colnames};
87+ }
88+
89 foreach my $thing ( $first_sql, $next_sql ) {
90+ $thing .= " ORDER BY $index_cols" if $index_cols;
91 $thing .= " LIMIT $limit";
92 if ( $o->get('for-update') ) {
93 $thing .= ' FOR UPDATE';
94@@ -7892,6 +7903,6 @@
95
96 =head1 VERSION
97
98-pt-archiver 2.2.11
99+pt-archiver 2.2.12
100
101 =cut
102
103=== modified file 'bin/pt-config-diff'
104--- bin/pt-config-diff 2014-09-25 13:48:22 +0000
105+++ bin/pt-config-diff 2014-11-14 14:12:25 +0000
106@@ -43,7 +43,7 @@
107 {
108 package Percona::Toolkit;
109
110-our $VERSION = '2.2.11';
111+our $VERSION = '2.2.12';
112
113 use strict;
114 use warnings FATAL => 'all';
115@@ -2295,7 +2295,7 @@
116 set => $args{set},
117 NAME_lc => defined($args{NAME_lc}) ? $args{NAME_lc} : 1,
118 dbh_set => 0,
119- ask_pass => $o->get('ask-pass'),
120+ ask_pass => $args{ask_pass},
121 DSNParser => $dp,
122 is_cluster_node => undef,
123 parent => $args{parent},
124@@ -2306,7 +2306,7 @@
125
126 sub connect {
127 my ( $self, %opts ) = @_;
128- my $dsn = $self->{dsn};
129+ my $dsn = $opts{dsn} || $self->{dsn};
130 my $dp = $self->{DSNParser};
131
132 my $dbh = $self->{dbh};
133@@ -2325,6 +2325,13 @@
134 }
135
136 $dbh = $self->set_dbh($dbh);
137+ if ( $opts{dsn} ) {
138+ $self->{dsn} = $dsn;
139+ $self->{dsn_name} = $dp->as_string($dsn, [qw(h P S)])
140+ || $dp->as_string($dsn, [qw(F)])
141+ || '';
142+
143+ }
144 PTDEBUG && _d($dbh, 'Connected dbh to', $self->{hostname},$self->{dsn_name});
145 return $dbh;
146 }
147@@ -2386,6 +2393,17 @@
148 return $self->{hostname} || $self->{dsn_name} || 'unknown host';
149 }
150
151+sub is_cluster_node {
152+ my ($self, $cxn) = @_;
153+
154+ my $sql = "SHOW VARIABLES LIKE 'wsrep\_on'";
155+ PTDEBUG && _d($cxn->name, $sql);
156+ my $row = $cxn->dbh->selectrow_arrayref($sql);
157+ PTDEBUG && _d(Dumper($row));
158+ return $row && $row->[1] && ($row->[1] eq 'ON' || $row->[1] eq '1') ? 1 : 0;
159+
160+}
161+
162 sub remove_duplicate_cxns {
163 my ($self, %args) = @_;
164 my @cxns = @{$args{cxns}};
165@@ -2395,7 +2413,8 @@
166
167 for my $cxn ( @cxns ) {
168 my $dbh = $cxn->dbh();
169- my $sql = q{SELECT @@server_id};
170+
171+ my $sql = $self->is_cluster_node($cxn) ? q{SELECT @@wsrep_node_incoming_address} : q{SELECT @@server_id};
172 PTDEBUG && _d($sql);
173 my ($id) = $dbh->selectrow_array($sql);
174 PTDEBUG && _d('Server ID for ', $cxn->name, ': ', $id);
175@@ -5733,6 +5752,6 @@
176
177 =head1 VERSION
178
179-pt-config-diff 2.2.11
180+pt-config-diff 2.2.12
181
182 =cut
183
184=== modified file 'bin/pt-deadlock-logger'
185--- bin/pt-deadlock-logger 2014-09-25 13:48:22 +0000
186+++ bin/pt-deadlock-logger 2014-11-14 14:12:25 +0000
187@@ -42,7 +42,7 @@
188 {
189 package Percona::Toolkit;
190
191-our $VERSION = '2.2.11';
192+our $VERSION = '2.2.12';
193
194 use strict;
195 use warnings FATAL => 'all';
196@@ -2639,7 +2639,7 @@
197 set => $args{set},
198 NAME_lc => defined($args{NAME_lc}) ? $args{NAME_lc} : 1,
199 dbh_set => 0,
200- ask_pass => $o->get('ask-pass'),
201+ ask_pass => $args{ask_pass},
202 DSNParser => $dp,
203 is_cluster_node => undef,
204 parent => $args{parent},
205@@ -2650,7 +2650,7 @@
206
207 sub connect {
208 my ( $self, %opts ) = @_;
209- my $dsn = $self->{dsn};
210+ my $dsn = $opts{dsn} || $self->{dsn};
211 my $dp = $self->{DSNParser};
212
213 my $dbh = $self->{dbh};
214@@ -2669,6 +2669,13 @@
215 }
216
217 $dbh = $self->set_dbh($dbh);
218+ if ( $opts{dsn} ) {
219+ $self->{dsn} = $dsn;
220+ $self->{dsn_name} = $dp->as_string($dsn, [qw(h P S)])
221+ || $dp->as_string($dsn, [qw(F)])
222+ || '';
223+
224+ }
225 PTDEBUG && _d($dbh, 'Connected dbh to', $self->{hostname},$self->{dsn_name});
226 return $dbh;
227 }
228@@ -2730,6 +2737,17 @@
229 return $self->{hostname} || $self->{dsn_name} || 'unknown host';
230 }
231
232+sub is_cluster_node {
233+ my ($self, $cxn) = @_;
234+
235+ my $sql = "SHOW VARIABLES LIKE 'wsrep\_on'";
236+ PTDEBUG && _d($cxn->name, $sql);
237+ my $row = $cxn->dbh->selectrow_arrayref($sql);
238+ PTDEBUG && _d(Dumper($row));
239+ return $row && $row->[1] && ($row->[1] eq 'ON' || $row->[1] eq '1') ? 1 : 0;
240+
241+}
242+
243 sub remove_duplicate_cxns {
244 my ($self, %args) = @_;
245 my @cxns = @{$args{cxns}};
246@@ -2739,7 +2757,8 @@
247
248 for my $cxn ( @cxns ) {
249 my $dbh = $cxn->dbh();
250- my $sql = q{SELECT @@server_id};
251+
252+ my $sql = $self->is_cluster_node($cxn) ? q{SELECT @@wsrep_node_incoming_address} : q{SELECT @@server_id};
253 PTDEBUG && _d($sql);
254 my ($id) = $dbh->selectrow_array($sql);
255 PTDEBUG && _d('Server ID for ', $cxn->name, ': ', $id);
256@@ -5523,6 +5542,6 @@
257
258 =head1 VERSION
259
260-pt-deadlock-logger 2.2.11
261+pt-deadlock-logger 2.2.12
262
263 =cut
264
265=== modified file 'bin/pt-diskstats'
266--- bin/pt-diskstats 2014-09-25 13:48:22 +0000
267+++ bin/pt-diskstats 2014-11-14 14:12:25 +0000
268@@ -38,7 +38,7 @@
269 {
270 package Percona::Toolkit;
271
272-our $VERSION = '2.2.11';
273+our $VERSION = '2.2.12';
274
275 use strict;
276 use warnings FATAL => 'all';
277@@ -5579,6 +5579,6 @@
278
279 =head1 VERSION
280
281-pt-diskstats 2.2.11
282+pt-diskstats 2.2.12
283
284 =cut
285
286=== modified file 'bin/pt-duplicate-key-checker'
287--- bin/pt-duplicate-key-checker 2014-09-25 13:48:22 +0000
288+++ bin/pt-duplicate-key-checker 2014-11-14 14:12:25 +0000
289@@ -39,7 +39,7 @@
290 {
291 package Percona::Toolkit;
292
293-our $VERSION = '2.2.11';
294+our $VERSION = '2.2.12';
295
296 use strict;
297 use warnings FATAL => 'all';
298@@ -5600,6 +5600,6 @@
299
300 =head1 VERSION
301
302-pt-duplicate-key-checker 2.2.11
303+pt-duplicate-key-checker 2.2.12
304
305 =cut
306
307=== modified file 'bin/pt-fifo-split'
308--- bin/pt-fifo-split 2014-09-25 13:48:22 +0000
309+++ bin/pt-fifo-split 2014-11-14 14:12:25 +0000
310@@ -902,6 +902,14 @@
311 $parse = 0;
312 next LINE;
313 }
314+
315+ if ( $parse
316+ && !$self->has('version-check')
317+ && $line =~ /version-check/
318+ ) {
319+ next LINE;
320+ }
321+
322 if ( $parse
323 && (my($opt, $arg) = $line =~ m/^\s*([^=\s]+?)(?:\s*=\s*(.*?)\s*)?$/)
324 ) {
325@@ -1612,6 +1620,6 @@
326
327 =head1 VERSION
328
329-pt-fifo-split 2.2.11
330+pt-fifo-split 2.2.12
331
332 =cut
333
334=== modified file 'bin/pt-find'
335--- bin/pt-find 2014-09-25 13:48:22 +0000
336+++ bin/pt-find 2014-11-14 14:12:25 +0000
337@@ -35,7 +35,7 @@
338 {
339 package Percona::Toolkit;
340
341-our $VERSION = '2.2.11';
342+our $VERSION = '2.2.12';
343
344 use strict;
345 use warnings FATAL => 'all';
346@@ -4984,6 +4984,6 @@
347
348 =head1 VERSION
349
350-pt-find 2.2.11
351+pt-find 2.2.12
352
353 =cut
354
355=== modified file 'bin/pt-fingerprint'
356--- bin/pt-fingerprint 2014-09-25 13:48:22 +0000
357+++ bin/pt-fingerprint 2014-11-14 14:12:25 +0000
358@@ -903,6 +903,14 @@
359 $parse = 0;
360 next LINE;
361 }
362+
363+ if ( $parse
364+ && !$self->has('version-check')
365+ && $line =~ /version-check/
366+ ) {
367+ next LINE;
368+ }
369+
370 if ( $parse
371 && (my($opt, $arg) = $line =~ m/^\s*([^=\s]+?)(?:\s*=\s*(.*?)\s*)?$/)
372 ) {
373@@ -2203,6 +2211,6 @@
374
375 =head1 VERSION
376
377-pt-fingerprint 2.2.11
378+pt-fingerprint 2.2.12
379
380 =cut
381
382=== modified file 'bin/pt-fk-error-logger'
383--- bin/pt-fk-error-logger 2014-09-25 13:48:22 +0000
384+++ bin/pt-fk-error-logger 2014-11-14 14:12:25 +0000
385@@ -37,7 +37,7 @@
386 {
387 package Percona::Toolkit;
388
389-our $VERSION = '2.2.11';
390+our $VERSION = '2.2.12';
391
392 use strict;
393 use warnings FATAL => 'all';
394@@ -1791,7 +1791,7 @@
395 set => $args{set},
396 NAME_lc => defined($args{NAME_lc}) ? $args{NAME_lc} : 1,
397 dbh_set => 0,
398- ask_pass => $o->get('ask-pass'),
399+ ask_pass => $args{ask_pass},
400 DSNParser => $dp,
401 is_cluster_node => undef,
402 parent => $args{parent},
403@@ -1802,7 +1802,7 @@
404
405 sub connect {
406 my ( $self, %opts ) = @_;
407- my $dsn = $self->{dsn};
408+ my $dsn = $opts{dsn} || $self->{dsn};
409 my $dp = $self->{DSNParser};
410
411 my $dbh = $self->{dbh};
412@@ -1821,6 +1821,13 @@
413 }
414
415 $dbh = $self->set_dbh($dbh);
416+ if ( $opts{dsn} ) {
417+ $self->{dsn} = $dsn;
418+ $self->{dsn_name} = $dp->as_string($dsn, [qw(h P S)])
419+ || $dp->as_string($dsn, [qw(F)])
420+ || '';
421+
422+ }
423 PTDEBUG && _d($dbh, 'Connected dbh to', $self->{hostname},$self->{dsn_name});
424 return $dbh;
425 }
426@@ -1882,6 +1889,17 @@
427 return $self->{hostname} || $self->{dsn_name} || 'unknown host';
428 }
429
430+sub is_cluster_node {
431+ my ($self, $cxn) = @_;
432+
433+ my $sql = "SHOW VARIABLES LIKE 'wsrep\_on'";
434+ PTDEBUG && _d($cxn->name, $sql);
435+ my $row = $cxn->dbh->selectrow_arrayref($sql);
436+ PTDEBUG && _d(Dumper($row));
437+ return $row && $row->[1] && ($row->[1] eq 'ON' || $row->[1] eq '1') ? 1 : 0;
438+
439+}
440+
441 sub remove_duplicate_cxns {
442 my ($self, %args) = @_;
443 my @cxns = @{$args{cxns}};
444@@ -1891,7 +1909,8 @@
445
446 for my $cxn ( @cxns ) {
447 my $dbh = $cxn->dbh();
448- my $sql = q{SELECT @@server_id};
449+
450+ my $sql = $self->is_cluster_node($cxn) ? q{SELECT @@wsrep_node_incoming_address} : q{SELECT @@server_id};
451 PTDEBUG && _d($sql);
452 my ($id) = $dbh->selectrow_array($sql);
453 PTDEBUG && _d('Server ID for ', $cxn->name, ': ', $id);
454@@ -4509,6 +4528,6 @@
455
456 =head1 VERSION
457
458-pt-fk-error-logger 2.2.11
459+pt-fk-error-logger 2.2.12
460
461 =cut
462
463=== modified file 'bin/pt-heartbeat'
464--- bin/pt-heartbeat 2014-09-25 13:48:22 +0000
465+++ bin/pt-heartbeat 2014-11-14 14:12:25 +0000
466@@ -38,7 +38,7 @@
467 {
468 package Percona::Toolkit;
469
470-our $VERSION = '2.2.11';
471+our $VERSION = '2.2.12';
472
473 use strict;
474 use warnings FATAL => 'all';
475@@ -4892,6 +4892,32 @@
476 $dbh->do("USE `$db`");
477
478 # ########################################################################
479+ # If --check-read-only option was given and we are in --update mode
480+ # we wait until server is writable , or run-time is over, or sentinel file
481+ # We also do this check after daemon is up and running, but it is necessary
482+ # to check this before attempting to create the table and inserting rows
483+ # https://bugs.launchpad.net/percona-toolkit/+bug/1328686
484+ # #######################################################################
485+ if ( $o->get('check-read-only') && $o->get('update') ) {
486+ PTDEBUG && _d('Checking if server is read_only');
487+ if ( server_is_readonly($dbh) && PTDEBUG ) {
488+ _d('Server is read-only, waiting')
489+ }
490+ my $start_time = time;
491+ my $run_time = $o->get('run-time');
492+ my $interval = $o->get('interval') || 5;
493+ while (server_is_readonly($dbh)) {
494+ sleep($interval);
495+ if (
496+ ($run_time && $run_time < time - $start_time)
497+ || -f $sentinel
498+ ) {
499+ return 0;
500+ }
501+ }
502+ }
503+
504+ # ########################################################################
505 # Create the heartbeat table if --create-table was given.
506 # ########################################################################
507 my $utc = $o->get('utc');
508@@ -6192,6 +6218,6 @@
509
510 =head1 VERSION
511
512-pt-heartbeat 2.2.11
513+pt-heartbeat 2.2.12
514
515 =cut
516
517=== modified file 'bin/pt-index-usage'
518--- bin/pt-index-usage 2014-09-25 13:48:22 +0000
519+++ bin/pt-index-usage 2014-11-14 14:12:25 +0000
520@@ -45,7 +45,7 @@
521 {
522 package Percona::Toolkit;
523
524-our $VERSION = '2.2.11';
525+our $VERSION = '2.2.12';
526
527 use strict;
528 use warnings FATAL => 'all';
529@@ -7548,6 +7548,6 @@
530
531 =head1 VERSION
532
533-pt-index-usage 2.2.11
534+pt-index-usage 2.2.12
535
536 =cut
537
538=== modified file 'bin/pt-ioprofile'
539--- bin/pt-ioprofile 2014-09-25 13:48:22 +0000
540+++ bin/pt-ioprofile 2014-11-14 14:12:25 +0000
541@@ -86,9 +86,10 @@
542
543 usage_or_errors() {
544 local file="$1"
545+ local version=""
546
547 if [ "$OPT_VERSION" ]; then
548- local version=$(grep '^pt-[^ ]\+ [0-9]' "$file")
549+ version=$(grep '^pt-[^ ]\+ [0-9]' "$file")
550 echo "$version"
551 return 1
552 fi
553@@ -310,6 +311,8 @@
554
555 [ "$config_opt" = "" ] && continue
556
557+ echo "$config_opt" | grep -v 'version-check' >/dev/null 2>&1 || continue
558+
559 if ! [ "$HAVE_EXT_ARGV" ]; then
560 config_opt="--$config_opt"
561 fi
562@@ -1119,7 +1122,7 @@
563
564 =head1 VERSION
565
566-pt-ioprofile 2.2.11
567+pt-ioprofile 2.2.12
568
569 =cut
570
571
572=== modified file 'bin/pt-kill'
573--- bin/pt-kill 2014-09-25 13:48:22 +0000
574+++ bin/pt-kill 2014-11-14 14:12:25 +0000
575@@ -47,7 +47,7 @@
576 {
577 package Percona::Toolkit;
578
579-our $VERSION = '2.2.11';
580+our $VERSION = '2.2.12';
581
582 use strict;
583 use warnings FATAL => 'all';
584@@ -5158,7 +5158,7 @@
585 set => $args{set},
586 NAME_lc => defined($args{NAME_lc}) ? $args{NAME_lc} : 1,
587 dbh_set => 0,
588- ask_pass => $o->get('ask-pass'),
589+ ask_pass => $args{ask_pass},
590 DSNParser => $dp,
591 is_cluster_node => undef,
592 parent => $args{parent},
593@@ -5169,7 +5169,7 @@
594
595 sub connect {
596 my ( $self, %opts ) = @_;
597- my $dsn = $self->{dsn};
598+ my $dsn = $opts{dsn} || $self->{dsn};
599 my $dp = $self->{DSNParser};
600
601 my $dbh = $self->{dbh};
602@@ -5188,6 +5188,13 @@
603 }
604
605 $dbh = $self->set_dbh($dbh);
606+ if ( $opts{dsn} ) {
607+ $self->{dsn} = $dsn;
608+ $self->{dsn_name} = $dp->as_string($dsn, [qw(h P S)])
609+ || $dp->as_string($dsn, [qw(F)])
610+ || '';
611+
612+ }
613 PTDEBUG && _d($dbh, 'Connected dbh to', $self->{hostname},$self->{dsn_name});
614 return $dbh;
615 }
616@@ -5249,6 +5256,17 @@
617 return $self->{hostname} || $self->{dsn_name} || 'unknown host';
618 }
619
620+sub is_cluster_node {
621+ my ($self, $cxn) = @_;
622+
623+ my $sql = "SHOW VARIABLES LIKE 'wsrep\_on'";
624+ PTDEBUG && _d($cxn->name, $sql);
625+ my $row = $cxn->dbh->selectrow_arrayref($sql);
626+ PTDEBUG && _d(Dumper($row));
627+ return $row && $row->[1] && ($row->[1] eq 'ON' || $row->[1] eq '1') ? 1 : 0;
628+
629+}
630+
631 sub remove_duplicate_cxns {
632 my ($self, %args) = @_;
633 my @cxns = @{$args{cxns}};
634@@ -5258,7 +5276,8 @@
635
636 for my $cxn ( @cxns ) {
637 my $dbh = $cxn->dbh();
638- my $sql = q{SELECT @@server_id};
639+
640+ my $sql = $self->is_cluster_node($cxn) ? q{SELECT @@wsrep_node_incoming_address} : q{SELECT @@server_id};
641 PTDEBUG && _d($sql);
642 my ($id) = $dbh->selectrow_array($sql);
643 PTDEBUG && _d('Server ID for ', $cxn->name, ': ', $id);
644@@ -8183,6 +8202,6 @@
645
646 =head1 VERSION
647
648-pt-kill 2.2.11
649+pt-kill 2.2.12
650
651 =cut
652
653=== modified file 'bin/pt-mext'
654--- bin/pt-mext 2014-09-25 13:48:22 +0000
655+++ bin/pt-mext 2014-11-14 14:12:25 +0000
656@@ -251,34 +251,38 @@
657 _parse_pod() {
658 local file="$1"
659
660- cat "$file" | PO_DIR="$PO_DIR" perl -ne '
661- BEGIN { $/ = ""; }
662- next unless $_ =~ m/^=head1 OPTIONS/;
663- while ( defined(my $para = <>) ) {
664- last if $para =~ m/^=head1/;
665- chomp;
666- if ( $para =~ m/^=item --(\S+)/ ) {
667- my $opt = $1;
668- my $file = "$ENV{PO_DIR}/$opt";
669- open my $opt_fh, ">", $file or die "Cannot open $file: $!";
670- print $opt_fh "long:$opt\n";
671- $para = <>;
672+ PO_FILE="$file" PO_DIR="$PO_DIR" perl -e '
673+ $/ = "";
674+ my $file = $ENV{PO_FILE};
675+ open my $fh, "<", $file or die "Cannot open $file: $!";
676+ while ( defined(my $para = <$fh>) ) {
677+ next unless $para =~ m/^=head1 OPTIONS/;
678+ while ( defined(my $para = <$fh>) ) {
679+ last if $para =~ m/^=head1/;
680 chomp;
681- if ( $para =~ m/^[a-z ]+:/ ) {
682- map {
683+ if ( $para =~ m/^=item --(\S+)/ ) {
684+ my $opt = $1;
685+ my $file = "$ENV{PO_DIR}/$opt";
686+ open my $opt_fh, ">", $file or die "Cannot open $file: $!";
687+ print $opt_fh "long:$opt\n";
688+ $para = <$fh>;
689+ chomp;
690+ if ( $para =~ m/^[a-z ]+:/ ) {
691+ map {
692+ chomp;
693+ my ($attrib, $val) = split(/: /, $_);
694+ print $opt_fh "$attrib:$val\n";
695+ } split(/; /, $para);
696+ $para = <$fh>;
697 chomp;
698- my ($attrib, $val) = split(/: /, $_);
699- print $opt_fh "$attrib:$val\n";
700- } split(/; /, $para);
701- $para = <>;
702- chomp;
703+ }
704+ my ($desc) = $para =~ m/^([^?.]+)/;
705+ print $opt_fh "desc:$desc.\n";
706+ close $opt_fh;
707 }
708- my ($desc) = $para =~ m/^([^?.]+)/;
709- print $opt_fh "desc:$desc.\n";
710- close $opt_fh;
711 }
712+ last;
713 }
714- last;
715 '
716 }
717
718@@ -348,6 +352,8 @@
719
720 [ "$config_opt" = "" ] && continue
721
722+ echo "$config_opt" | grep -v 'version-check' >/dev/null 2>&1 || continue
723+
724 if ! [ "$HAVE_EXT_ARGV" ]; then
725 config_opt="--$config_opt"
726 fi
727@@ -792,7 +798,7 @@
728
729 =head1 VERSION
730
731-pt-mext 2.2.11
732+pt-mext 2.2.12
733
734 =cut
735
736
737=== modified file 'bin/pt-mysql-summary'
738--- bin/pt-mysql-summary 2014-09-25 13:48:22 +0000
739+++ bin/pt-mysql-summary 2014-11-14 14:12:25 +0000
740@@ -313,6 +313,8 @@
741
742 [ "$config_opt" = "" ] && continue
743
744+ echo "$config_opt" | grep -v 'version-check' >/dev/null 2>&1 || continue
745+
746 if ! [ "$HAVE_EXT_ARGV" ]; then
747 config_opt="--$config_opt"
748 fi
749@@ -3083,7 +3085,7 @@
750
751 =head1 VERSION
752
753-pt-mysql-summary 2.2.11
754+pt-mysql-summary 2.2.12
755
756 =cut
757
758
759=== modified file 'bin/pt-online-schema-change'
760--- bin/pt-online-schema-change 2014-09-25 13:48:22 +0000
761+++ bin/pt-online-schema-change 2014-11-14 14:12:25 +0000
762@@ -54,7 +54,7 @@
763 {
764 package Percona::Toolkit;
765
766-our $VERSION = '2.2.11';
767+our $VERSION = '2.2.12';
768
769 use strict;
770 use warnings FATAL => 'all';
771@@ -3755,7 +3755,7 @@
772 set => $args{set},
773 NAME_lc => defined($args{NAME_lc}) ? $args{NAME_lc} : 1,
774 dbh_set => 0,
775- ask_pass => $o->get('ask-pass'),
776+ ask_pass => $args{ask_pass},
777 DSNParser => $dp,
778 is_cluster_node => undef,
779 parent => $args{parent},
780@@ -3766,12 +3766,12 @@
781
782 sub connect {
783 my ( $self, %opts ) = @_;
784- my $dsn = $self->{dsn};
785+ my $dsn = $opts{dsn} || $self->{dsn};
786 my $dp = $self->{DSNParser};
787
788 my $dbh = $self->{dbh};
789 if ( !$dbh || !$dbh->ping() ) {
790- if ( $self->{ask_pass} && !$self->{asked_for_pass} && !defined $dsn->{p}) {
791+ if ( $self->{ask_pass} && !$self->{asked_for_pass} ) {
792 $dsn->{p} = OptionParser::prompt_noecho("Enter MySQL password: ");
793 $self->{asked_for_pass} = 1;
794 }
795@@ -3785,6 +3785,13 @@
796 }
797
798 $dbh = $self->set_dbh($dbh);
799+ if ( $opts{dsn} ) {
800+ $self->{dsn} = $dsn;
801+ $self->{dsn_name} = $dp->as_string($dsn, [qw(h P S)])
802+ || $dp->as_string($dsn, [qw(F)])
803+ || '';
804+
805+ }
806 PTDEBUG && _d($dbh, 'Connected dbh to', $self->{hostname},$self->{dsn_name});
807 return $dbh;
808 }
809@@ -3846,6 +3853,17 @@
810 return $self->{hostname} || $self->{dsn_name} || 'unknown host';
811 }
812
813+sub is_cluster_node {
814+ my ($self, $cxn) = @_;
815+
816+ my $sql = "SHOW VARIABLES LIKE 'wsrep\_on'";
817+ PTDEBUG && _d($cxn->name, $sql);
818+ my $row = $cxn->dbh->selectrow_arrayref($sql);
819+ PTDEBUG && _d(Dumper($row));
820+ return $row && $row->[1] && ($row->[1] eq 'ON' || $row->[1] eq '1') ? 1 : 0;
821+
822+}
823+
824 sub remove_duplicate_cxns {
825 my ($self, %args) = @_;
826 my @cxns = @{$args{cxns}};
827@@ -3855,7 +3873,8 @@
828
829 for my $cxn ( @cxns ) {
830 my $dbh = $cxn->dbh();
831- my $sql = q{SELECT @@server_id};
832+
833+ my $sql = $self->is_cluster_node($cxn) ? q{SELECT @@wsrep_node_incoming_address} : q{SELECT @@server_id};
834 PTDEBUG && _d($sql);
835 my ($id) = $dbh->selectrow_array($sql);
836 PTDEBUG && _d('Server ID for ', $cxn->name, ': ', $id);
837@@ -7638,8 +7657,26 @@
838 sub remove_duplicate_cxns {
839 my ($self, %args) = @_;
840 my @cxns = @{$args{cxns}};
841- my $seen_ids = $args{seen_ids};
842- return Cxn->remove_duplicate_cxns(%args);
843+ my $seen_ids = $args{seen_ids} || {};
844+ PTDEBUG && _d("Removing duplicates nodes from ", join(" ", map { $_->name } @cxns));
845+ my @trimmed_cxns;
846+
847+ for my $cxn ( @cxns ) {
848+ my $dbh = $cxn->dbh();
849+ my $sql = $self->is_cluster_node($cxn) ? q{SELECT @@wsrep_node_incoming_address} : q{SELECT @@server_id};
850+ PTDEBUG && _d($sql);
851+ my ($id) = $dbh->selectrow_array($sql);
852+ PTDEBUG && _d('Server ID for ', $cxn->name, ': ', $id);
853+
854+ if ( ! $seen_ids->{$id}++ ) {
855+ push @trimmed_cxns, $cxn
856+ }
857+ else {
858+ PTDEBUG && _d("Removing ", $cxn->name,
859+ ", ID ", $id, ", because we've already seen it");
860+ }
861+ }
862+ return \@trimmed_cxns;
863 }
864
865 sub same_cluster {
866@@ -10556,6 +10593,12 @@
867
868 =item *
869
870+In most cases the tool will refuse to operate unless a PRIMARY KEY or UNIQUE INDEX is
871+present in the table. See L<"--alter"> for details.
872+
873+
874+=item *
875+
876 The tool refuses to operate if it detects replication filters. See
877 L<"--[no]check-replication-filters"> for details.
878
879@@ -10634,6 +10677,16 @@
880
881 =item *
882
883+In almost all cases a PRIMARY KEY or UNIQUE INDEX needs to be present in the table.
884+This is necessary because the tool creates a DELETE trigger to keep the new table
885+updated while the process is running.
886+
887+A notable exception is when a PRIMARY KEY or UNIQUE INDEX is being created from
888+B<existing columns> as part of the ALTER clause; in that case it will use these
889+column(s) for the DELETE trigger.
890+
891+=item *
892+
893 The C<RENAME> clause cannot be used to rename the table.
894
895 =item *
896@@ -11563,6 +11616,6 @@
897
898 =head1 VERSION
899
900-pt-online-schema-change 2.2.11
901+pt-online-schema-change 2.2.12
902
903 =cut
904
905=== modified file 'bin/pt-pmp'
906--- bin/pt-pmp 2014-09-25 13:48:22 +0000
907+++ bin/pt-pmp 2014-11-14 14:12:25 +0000
908@@ -129,9 +129,10 @@
909
910 usage_or_errors() {
911 local file="$1"
912+ local version=""
913
914 if [ "$OPT_VERSION" ]; then
915- local version=$(grep '^pt-[^ ]\+ [0-9]' "$file")
916+ version=$(grep '^pt-[^ ]\+ [0-9]' "$file")
917 echo "$version"
918 return 1
919 fi
920@@ -353,6 +354,8 @@
921
922 [ "$config_opt" = "" ] && continue
923
924+ echo "$config_opt" | grep -v 'version-check' >/dev/null 2>&1 || continue
925+
926 if ! [ "$HAVE_EXT_ARGV" ]; then
927 config_opt="--$config_opt"
928 fi
929@@ -889,7 +892,7 @@
930
931 =head1 VERSION
932
933-pt-pmp 2.2.11
934+pt-pmp 2.2.12
935
936 =cut
937
938
939=== modified file 'bin/pt-query-digest'
940--- bin/pt-query-digest 2014-09-25 13:48:22 +0000
941+++ bin/pt-query-digest 2014-11-14 14:12:25 +0000
942@@ -64,7 +64,7 @@
943 {
944 package Percona::Toolkit;
945
946-our $VERSION = '2.2.11';
947+our $VERSION = '2.2.12';
948
949 use strict;
950 use warnings FATAL => 'all';
951@@ -13181,6 +13181,13 @@
952 if ( $fh ) {
953 PTDEBUG && _d('Reading', $filename);
954 PTDEBUG && _d('File size:', $filesize);
955+ # catch if user is trying to use an uncoverted (raw) binlog # issue 1377888
956+ if ( $filename && $o->get('type')->[0] eq 'binlog') {
957+ if (is_raw_binlog($filename)) {
958+ warn "Binlog file $filename must first be converted to text format using mysqlbinlog";
959+ return 1;
960+ }
961+ }
962 push @read_files, { name => ($filename || "STDIN"), size => $filesize };
963
964 # Read the file offset for --resume.
965@@ -14722,6 +14729,14 @@
966 return;
967 }
968
969+# make an effort to check if file is a raw binlog
970+# (i.e. was not converted to text using mysqlbinlog)
971+sub is_raw_binlog {
972+ my $filename = shift;
973+
974+ return -B $filename;
975+}
976+
977 sub _d {
978 my ($package, undef, $line) = caller 0;
979 @_ = map { (my $temp = $_) =~ s/\n/\n# /g; $temp; }
980@@ -14798,7 +14813,8 @@
981
982 pt-query-digest is a sophisticated but easy to use tool for analyzing
983 MySQL queries. It can analyze queries from MySQL slow, general, and binary
984-logs, as well as C<SHOW PROCESSLIST> and MySQL protocol data from tcpdump.
985+logs. (Binary logs must first be converted to text, see L<"--type">).
986+It can also use C<SHOW PROCESSLIST> and MySQL protocol data from tcpdump.
987 By default, the tool reports which queries are the slowest, and therefore
988 the most important to optimize. More complex and custom-tailored reports
989 can be created by using options like L<"--group-by">, L<"--filter">, and
990@@ -16134,7 +16150,13 @@
991
992 =item binlog
993
994-Parse a binary log file.
995+Parse a binary log file that has first been converted to text using mysqlbinlog.
996+
997+For example:
998+
999+ mysqlbinlog mysql-bin.000441 > mysql-bin.000441.txt
1000+
1001+ pt-query-digest --type binlog mysql-bin.000441.txt
1002
1003 =item genlog
1004
1005@@ -16595,6 +16617,6 @@
1006
1007 =head1 VERSION
1008
1009-pt-query-digest 2.2.11
1010+pt-query-digest 2.2.12
1011
1012 =cut
1013
1014=== modified file 'bin/pt-show-grants'
1015--- bin/pt-show-grants 2014-09-25 13:48:22 +0000
1016+++ bin/pt-show-grants 2014-11-14 14:12:25 +0000
1017@@ -903,6 +903,14 @@
1018 $parse = 0;
1019 next LINE;
1020 }
1021+
1022+ if ( $parse
1023+ && !$self->has('version-check')
1024+ && $line =~ /version-check/
1025+ ) {
1026+ next LINE;
1027+ }
1028+
1029 if ( $parse
1030 && (my($opt, $arg) = $line =~ m/^\s*([^=\s]+?)(?:\s*=\s*(.*?)\s*)?$/)
1031 ) {
1032@@ -2406,6 +2414,6 @@
1033
1034 =head1 VERSION
1035
1036-pt-show-grants 2.2.11
1037+pt-show-grants 2.2.12
1038
1039 =cut
1040
1041=== modified file 'bin/pt-sift'
1042--- bin/pt-sift 2014-09-25 13:48:22 +0000
1043+++ bin/pt-sift 2014-11-14 14:12:25 +0000
1044@@ -127,9 +127,10 @@
1045
1046 usage_or_errors() {
1047 local file="$1"
1048+ local version=""
1049
1050 if [ "$OPT_VERSION" ]; then
1051- local version=$(grep '^pt-[^ ]\+ [0-9]' "$file")
1052+ version=$(grep '^pt-[^ ]\+ [0-9]' "$file")
1053 echo "$version"
1054 return 1
1055 fi
1056@@ -351,6 +352,8 @@
1057
1058 [ "$config_opt" = "" ] && continue
1059
1060+ echo "$config_opt" | grep -v 'version-check' >/dev/null 2>&1 || continue
1061+
1062 if ! [ "$HAVE_EXT_ARGV" ]; then
1063 config_opt="--$config_opt"
1064 fi
1065@@ -1237,7 +1240,7 @@
1066
1067 =head1 VERSION
1068
1069-pt-sift 2.2.11
1070+pt-sift 2.2.12
1071
1072 =cut
1073
1074
1075=== modified file 'bin/pt-slave-delay'
1076--- bin/pt-slave-delay 2014-09-25 13:48:22 +0000
1077+++ bin/pt-slave-delay 2014-11-14 14:12:25 +0000
1078@@ -40,7 +40,7 @@
1079 {
1080 package Percona::Toolkit;
1081
1082-our $VERSION = '2.2.11';
1083+our $VERSION = '2.2.12';
1084
1085 use strict;
1086 use warnings FATAL => 'all';
1087@@ -4869,6 +4869,6 @@
1088
1089 =head1 VERSION
1090
1091-pt-slave-delay 2.2.11
1092+pt-slave-delay 2.2.12
1093
1094 =cut
1095
1096=== modified file 'bin/pt-slave-find'
1097--- bin/pt-slave-find 2014-09-25 13:48:22 +0000
1098+++ bin/pt-slave-find 2014-11-14 14:12:25 +0000
1099@@ -911,6 +911,14 @@
1100 $parse = 0;
1101 next LINE;
1102 }
1103+
1104+ if ( $parse
1105+ && !$self->has('version-check')
1106+ && $line =~ /version-check/
1107+ ) {
1108+ next LINE;
1109+ }
1110+
1111 if ( $parse
1112 && (my($opt, $arg) = $line =~ m/^\s*([^=\s]+?)(?:\s*=\s*(.*?)\s*)?$/)
1113 ) {
1114@@ -4334,6 +4342,6 @@
1115
1116 =head1 VERSION
1117
1118-pt-slave-find 2.2.11
1119+pt-slave-find 2.2.12
1120
1121 =cut
1122
1123=== modified file 'bin/pt-slave-restart'
1124--- bin/pt-slave-restart 2014-09-25 13:48:22 +0000
1125+++ bin/pt-slave-restart 2014-11-14 14:12:25 +0000
1126@@ -41,7 +41,7 @@
1127 {
1128 package Percona::Toolkit;
1129
1130-our $VERSION = '2.2.11';
1131+our $VERSION = '2.2.12';
1132
1133 use strict;
1134 use warnings FATAL => 'all';
1135@@ -5937,6 +5937,6 @@
1136
1137 =head1 VERSION
1138
1139-pt-slave-restart 2.2.11
1140+pt-slave-restart 2.2.12
1141
1142 =cut
1143
1144=== modified file 'bin/pt-stalk'
1145--- bin/pt-stalk 2014-09-25 13:48:22 +0000
1146+++ bin/pt-stalk 2014-11-14 14:12:25 +0000
1147@@ -140,9 +140,10 @@
1148
1149 usage_or_errors() {
1150 local file="$1"
1151+ local version=""
1152
1153 if [ "$OPT_VERSION" ]; then
1154- local version=$(grep '^pt-[^ ]\+ [0-9]' "$file")
1155+ version=$(grep '^pt-[^ ]\+ [0-9]' "$file")
1156 echo "$version"
1157 return 1
1158 fi
1159@@ -364,6 +365,8 @@
1160
1161 [ "$config_opt" = "" ] && continue
1162
1163+ echo "$config_opt" | grep -v 'version-check' >/dev/null 2>&1 || continue
1164+
1165 if ! [ "$HAVE_EXT_ARGV" ]; then
1166 config_opt="--$config_opt"
1167 fi
1168@@ -779,6 +782,7 @@
1169 CMD_SYSCTL="${CMD_SYSCTL:-"$(_which sysctl)"}"
1170 CMD_TCPDUMP="${CMD_TCPDUMP:-"$(_which tcpdump)"}"
1171 CMD_VMSTAT="${CMD_VMSTAT:-"$(_which vmstat)"}"
1172+CMD_DMESG="${CMD_DMESG:-"$(_which dmesg)"}"
1173
1174 [ -z "$CMD_SYSCTL" -a -x "/sbin/sysctl" ] && CMD_SYSCTL="/sbin/sysctl"
1175
1176@@ -862,6 +866,14 @@
1177 if [ "$CMD_SYSCTL" ]; then
1178 $CMD_SYSCTL -a >> "$d/$p-sysctl" &
1179 fi
1180+
1181+ # collect dmesg events from 60 seconds ago until present
1182+ if [ "$CMD_DMESG" ]; then
1183+ local UPTIME=`cat /proc/uptime | awk '{ print $1 }'`
1184+ local START_TIME=$(echo "$UPTIME 60" | awk '{print ($1 - $2)}')
1185+ $CMD_DMESG | perl -ne 'm/\[\s*(\d+)\./; if ($1 > '${START_TIME}') { print }' >> "$d/$p-dmesg" &
1186+ fi
1187+
1188 local cnt=$(($OPT_RUN_TIME / $OPT_SLEEP_COLLECT))
1189 if [ "$CMD_VMSTAT" ]; then
1190 $CMD_VMSTAT $OPT_SLEEP_COLLECT $cnt >> "$d/$p-vmstat" &
1191@@ -876,6 +888,7 @@
1192 $CMD_MPSTAT -P ALL $OPT_RUN_TIME 1 >> "$d/$p-mpstat-overall" &
1193 fi
1194
1195+
1196 $CMD_MYSQLADMIN $EXT_ARGV ext -i$OPT_SLEEP_COLLECT -c$cnt >>"$d/$p-mysqladmin" &
1197 local mysqladmin_pid=$!
1198
1199@@ -2225,7 +2238,7 @@
1200
1201 =head1 VERSION
1202
1203-pt-stalk 2.2.11
1204+pt-stalk 2.2.12
1205
1206 =cut
1207
1208
1209=== modified file 'bin/pt-summary'
1210--- bin/pt-summary 2014-09-25 13:48:22 +0000
1211+++ bin/pt-summary 2014-11-14 14:12:25 +0000
1212@@ -320,6 +320,8 @@
1213
1214 [ "$config_opt" = "" ] && continue
1215
1216+ echo "$config_opt" | grep -v 'version-check' >/dev/null 2>&1 || continue
1217+
1218 if ! [ "$HAVE_EXT_ARGV" ]; then
1219 config_opt="--$config_opt"
1220 fi
1221@@ -2691,7 +2693,7 @@
1222
1223 =head1 VERSION
1224
1225-pt-summary 2.2.11
1226+pt-summary 2.2.12
1227
1228 =cut
1229
1230
1231=== modified file 'bin/pt-table-checksum'
1232--- bin/pt-table-checksum 2014-09-25 13:48:22 +0000
1233+++ bin/pt-table-checksum 2014-11-14 14:12:25 +0000
1234@@ -57,7 +57,7 @@
1235 {
1236 package Percona::Toolkit;
1237
1238-our $VERSION = '2.2.11';
1239+our $VERSION = '2.2.12';
1240
1241 use strict;
1242 use warnings FATAL => 'all';
1243@@ -3533,7 +3533,7 @@
1244 set => $args{set},
1245 NAME_lc => defined($args{NAME_lc}) ? $args{NAME_lc} : 1,
1246 dbh_set => 0,
1247- ask_pass => $o->get('ask-pass'),
1248+ ask_pass => $args{ask_pass},
1249 DSNParser => $dp,
1250 is_cluster_node => undef,
1251 parent => $args{parent},
1252@@ -3544,7 +3544,7 @@
1253
1254 sub connect {
1255 my ( $self, %opts ) = @_;
1256- my $dsn = $self->{dsn};
1257+ my $dsn = $opts{dsn} || $self->{dsn};
1258 my $dp = $self->{DSNParser};
1259
1260 my $dbh = $self->{dbh};
1261@@ -3563,6 +3563,13 @@
1262 }
1263
1264 $dbh = $self->set_dbh($dbh);
1265+ if ( $opts{dsn} ) {
1266+ $self->{dsn} = $dsn;
1267+ $self->{dsn_name} = $dp->as_string($dsn, [qw(h P S)])
1268+ || $dp->as_string($dsn, [qw(F)])
1269+ || '';
1270+
1271+ }
1272 PTDEBUG && _d($dbh, 'Connected dbh to', $self->{hostname},$self->{dsn_name});
1273 return $dbh;
1274 }
1275@@ -3624,6 +3631,17 @@
1276 return $self->{hostname} || $self->{dsn_name} || 'unknown host';
1277 }
1278
1279+sub is_cluster_node {
1280+ my ($self, $cxn) = @_;
1281+
1282+ my $sql = "SHOW VARIABLES LIKE 'wsrep\_on'";
1283+ PTDEBUG && _d($cxn->name, $sql);
1284+ my $row = $cxn->dbh->selectrow_arrayref($sql);
1285+ PTDEBUG && _d(Dumper($row));
1286+ return $row && $row->[1] && ($row->[1] eq 'ON' || $row->[1] eq '1') ? 1 : 0;
1287+
1288+}
1289+
1290 sub remove_duplicate_cxns {
1291 my ($self, %args) = @_;
1292 my @cxns = @{$args{cxns}};
1293@@ -3633,7 +3651,8 @@
1294
1295 for my $cxn ( @cxns ) {
1296 my $dbh = $cxn->dbh();
1297- my $sql = q{SELECT @@server_id};
1298+
1299+ my $sql = $self->is_cluster_node($cxn) ? q{SELECT @@wsrep_node_incoming_address} : q{SELECT @@server_id};
1300 PTDEBUG && _d($sql);
1301 my ($id) = $dbh->selectrow_array($sql);
1302 PTDEBUG && _d('Server ID for ', $cxn->name, ': ', $id);
1303@@ -3788,8 +3807,26 @@
1304 sub remove_duplicate_cxns {
1305 my ($self, %args) = @_;
1306 my @cxns = @{$args{cxns}};
1307- my $seen_ids = $args{seen_ids};
1308- return Cxn->remove_duplicate_cxns(%args);
1309+ my $seen_ids = $args{seen_ids} || {};
1310+ PTDEBUG && _d("Removing duplicates nodes from ", join(" ", map { $_->name } @cxns));
1311+ my @trimmed_cxns;
1312+
1313+ for my $cxn ( @cxns ) {
1314+ my $dbh = $cxn->dbh();
1315+ my $sql = $self->is_cluster_node($cxn) ? q{SELECT @@wsrep_node_incoming_address} : q{SELECT @@server_id};
1316+ PTDEBUG && _d($sql);
1317+ my ($id) = $dbh->selectrow_array($sql);
1318+ PTDEBUG && _d('Server ID for ', $cxn->name, ': ', $id);
1319+
1320+ if ( ! $seen_ids->{$id}++ ) {
1321+ push @trimmed_cxns, $cxn
1322+ }
1323+ else {
1324+ PTDEBUG && _d("Removing ", $cxn->name,
1325+ ", ID ", $id, ", because we've already seen it");
1326+ }
1327+ }
1328+ return \@trimmed_cxns;
1329 }
1330
1331 sub same_cluster {
1332@@ -9286,7 +9323,8 @@
1333 my %seen_ids;
1334 for my $cxn ($master_cxn, @$slaves) {
1335 my $dbh = $cxn->dbh();
1336- my $sql = q{SELECT @@server_id};
1337+ # if it's a cluster node we use its incoming address as id ( see https://bugs.launchpad.net/percona-toolkit/+bug/1217466 )
1338+ my $sql = $cluster->is_cluster_node($cxn) ? q{SELECT @@wsrep_node_incoming_address} : q{SELECT @@server_id};
1339 PTDEBUG && _d($cxn, $dbh, $sql);
1340 my ($id) = $dbh->selectrow_array($sql);
1341 $seen_ids{$id}++;
1342@@ -9363,9 +9401,11 @@
1343
1344 if ( $cluster_name_for{$master_cxn} ) {
1345 if ( !@$slaves ) {
1346- die $master_cxn->name() . " is a cluster node but no other nodes "
1347- . "or regular replicas were found. Use --recursion-method=dsn "
1348- . "to specify the other nodes in the cluster.\n";
1349+ if ( ($o->get('recursion-method')->[0] || '') ne 'none' ) {
1350+ die $master_cxn->name() . " is a cluster node but no other nodes "
1351+ . "or regular replicas were found. Use --recursion-method=dsn "
1352+ . "to specify the other nodes in the cluster.\n";
1353+ }
1354 }
1355
1356 # Make sure the master and all node are in the same cluster.
1357@@ -12240,9 +12280,13 @@
1358 The C<dsn> column contains a replica DSN like it would be given on the command
1359 line, for example: C<"h=replica_host,u=repl_user,p=repl_pass">.
1360
1361-The C<none> method prevents the tool from connecting to any replicas.
1362-This effectively disables all the L<"REPLICA CHECKS"> because there will
1363-not be any replicas to check. Therefore, this method is not recommended.
1364+The C<none> method makes the tool ignore all slaves and cluster nodes. This
1365+method is not recommended because it effectively disables the
1366+L<"REPLICA CHECKS"> and no differences can be found. It is useful, however, if
1367+you only need to write checksums on the master or a single cluster node. The
1368+safer alternative is C<--no-replicate-check>: the tool finds replicas and
1369+cluster nodes, performs the L<"REPLICA CHECKS">, but does not check for
1370+differences. See L<"--[no]replicate-check">.
1371
1372 =item --replicate
1373
1374@@ -12698,6 +12742,6 @@
1375
1376 =head1 VERSION
1377
1378-pt-table-checksum 2.2.11
1379+pt-table-checksum 2.2.12
1380
1381 =cut
1382
1383=== modified file 'bin/pt-table-sync'
1384--- bin/pt-table-sync 2014-09-25 13:48:22 +0000
1385+++ bin/pt-table-sync 2014-11-14 14:12:25 +0000
1386@@ -55,7 +55,7 @@
1387 {
1388 package Percona::Toolkit;
1389
1390-our $VERSION = '2.2.11';
1391+our $VERSION = '2.2.12';
1392
1393 use strict;
1394 use warnings FATAL => 'all';
1395@@ -12768,6 +12768,6 @@
1396
1397 =head1 VERSION
1398
1399-pt-table-sync 2.2.11
1400+pt-table-sync 2.2.12
1401
1402 =cut
1403
1404=== modified file 'bin/pt-table-usage'
1405--- bin/pt-table-usage 2014-09-25 13:48:22 +0000
1406+++ bin/pt-table-usage 2014-11-14 14:12:25 +0000
1407@@ -1340,6 +1340,14 @@
1408 $parse = 0;
1409 next LINE;
1410 }
1411+
1412+ if ( $parse
1413+ && !$self->has('version-check')
1414+ && $line =~ /version-check/
1415+ ) {
1416+ next LINE;
1417+ }
1418+
1419 if ( $parse
1420 && (my($opt, $arg) = $line =~ m/^\s*([^=\s]+?)(?:\s*=\s*(.*?)\s*)?$/)
1421 ) {
1422@@ -7563,6 +7571,6 @@
1423
1424 =head1 VERSION
1425
1426-pt-table-usage 2.2.11
1427+pt-table-usage 2.2.12
1428
1429 =cut
1430
1431=== modified file 'bin/pt-upgrade'
1432--- bin/pt-upgrade 2014-09-25 13:48:22 +0000
1433+++ bin/pt-upgrade 2014-11-14 14:12:25 +0000
1434@@ -61,7 +61,7 @@
1435 {
1436 package Percona::Toolkit;
1437
1438-our $VERSION = '2.2.11';
1439+our $VERSION = '2.2.12';
1440
1441 use strict;
1442 use warnings FATAL => 'all';
1443@@ -2464,7 +2464,7 @@
1444 set => $args{set},
1445 NAME_lc => defined($args{NAME_lc}) ? $args{NAME_lc} : 1,
1446 dbh_set => 0,
1447- ask_pass => $o->get('ask-pass'),
1448+ ask_pass => $args{ask_pass},
1449 DSNParser => $dp,
1450 is_cluster_node => undef,
1451 parent => $args{parent},
1452@@ -2475,7 +2475,7 @@
1453
1454 sub connect {
1455 my ( $self, %opts ) = @_;
1456- my $dsn = $self->{dsn};
1457+ my $dsn = $opts{dsn} || $self->{dsn};
1458 my $dp = $self->{DSNParser};
1459
1460 my $dbh = $self->{dbh};
1461@@ -2494,6 +2494,13 @@
1462 }
1463
1464 $dbh = $self->set_dbh($dbh);
1465+ if ( $opts{dsn} ) {
1466+ $self->{dsn} = $dsn;
1467+ $self->{dsn_name} = $dp->as_string($dsn, [qw(h P S)])
1468+ || $dp->as_string($dsn, [qw(F)])
1469+ || '';
1470+
1471+ }
1472 PTDEBUG && _d($dbh, 'Connected dbh to', $self->{hostname},$self->{dsn_name});
1473 return $dbh;
1474 }
1475@@ -2555,6 +2562,17 @@
1476 return $self->{hostname} || $self->{dsn_name} || 'unknown host';
1477 }
1478
1479+sub is_cluster_node {
1480+ my ($self, $cxn) = @_;
1481+
1482+ my $sql = "SHOW VARIABLES LIKE 'wsrep\_on'";
1483+ PTDEBUG && _d($cxn->name, $sql);
1484+ my $row = $cxn->dbh->selectrow_arrayref($sql);
1485+ PTDEBUG && _d(Dumper($row));
1486+ return $row && $row->[1] && ($row->[1] eq 'ON' || $row->[1] eq '1') ? 1 : 0;
1487+
1488+}
1489+
1490 sub remove_duplicate_cxns {
1491 my ($self, %args) = @_;
1492 my @cxns = @{$args{cxns}};
1493@@ -2564,7 +2582,8 @@
1494
1495 for my $cxn ( @cxns ) {
1496 my $dbh = $cxn->dbh();
1497- my $sql = q{SELECT @@server_id};
1498+
1499+ my $sql = $self->is_cluster_node($cxn) ? q{SELECT @@wsrep_node_incoming_address} : q{SELECT @@server_id};
1500 PTDEBUG && _d($sql);
1501 my ($id) = $dbh->selectrow_array($sql);
1502 PTDEBUG && _d('Server ID for ', $cxn->name, ': ', $id);
1503@@ -11240,6 +11259,6 @@
1504
1505 =head1 VERSION
1506
1507-pt-upgrade 2.2.11
1508+pt-upgrade 2.2.12
1509
1510 =cut
1511
1512=== modified file 'bin/pt-variable-advisor'
1513--- bin/pt-variable-advisor 2014-09-25 13:48:22 +0000
1514+++ bin/pt-variable-advisor 2014-11-14 14:12:25 +0000
1515@@ -44,7 +44,7 @@
1516 {
1517 package Percona::Toolkit;
1518
1519-our $VERSION = '2.2.11';
1520+our $VERSION = '2.2.12';
1521
1522 use strict;
1523 use warnings FATAL => 'all';
1524@@ -6138,6 +6138,6 @@
1525
1526 =head1 VERSION
1527
1528-pt-variable-advisor 2.2.11
1529+pt-variable-advisor 2.2.12
1530
1531 =cut
1532
1533=== modified file 'bin/pt-visual-explain'
1534--- bin/pt-visual-explain 2014-09-25 13:48:22 +0000
1535+++ bin/pt-visual-explain 2014-11-14 14:12:25 +0000
1536@@ -1577,6 +1577,14 @@
1537 $parse = 0;
1538 next LINE;
1539 }
1540+
1541+ if ( $parse
1542+ && !$self->has('version-check')
1543+ && $line =~ /version-check/
1544+ ) {
1545+ next LINE;
1546+ }
1547+
1548 if ( $parse
1549 && (my($opt, $arg) = $line =~ m/^\s*([^=\s]+?)(?:\s*=\s*(.*?)\s*)?$/)
1550 ) {
1551@@ -3243,6 +3251,6 @@
1552
1553 =head1 VERSION
1554
1555-pt-visual-explain 2.2.11
1556+pt-visual-explain 2.2.12
1557
1558 =cut
1559
1560=== modified file 'config/deb/changelog'
1561--- config/deb/changelog 2014-09-25 13:48:22 +0000
1562+++ config/deb/changelog 2014-11-14 14:12:25 +0000
1563@@ -1,3 +1,16 @@
1564+percona-toolkit (2.2.12) unstable; urgency=low
1565+
1566+ * Fixed bug 1376561: pt-archiver is not able to archive all the rows when a table has a hash partition
1567+ * Fixed bug 1328686: pt-heartbeat check-read-only option does not prevent creates or inserts
1568+ * Fixed bug 1269695: pt-online-schema-change does not allow ALTER for a table without a non-unique, while manual does not explain this
1569+ * Fixed bug 1217466: pt-table-checksum refuses to run on PXC if server_id is the same on all nodes
1570+ * Fixed bug 1373937: pt-table-checksum requires recursion when working with and XtraDB Cluster node
1571+ * Fixed bug 1377888: pt-query-digest manual for --type binlog is ambiguous
1572+ * Fixed bug 1349086: pt-stalk should also gather dmesg output
1573+ * Fixed bug 1361293: Some scripts fail when no-version-check option is put in global config file
1574+
1575+ -- Percona Toolkit Developers <toolkit-dev@percona.com> Tue, 11 Nov 2014 13:02:51 +0000
1576+
1577 percona-toolkit (2.2.11) unstable; urgency=low
1578
1579 * Fixed bug 1262456: pt-query-digest doesn't report host details
1580
1581=== modified file 'config/sphinx-build/conf.py'
1582--- config/sphinx-build/conf.py 2014-09-25 13:48:22 +0000
1583+++ config/sphinx-build/conf.py 2014-11-14 14:12:25 +0000
1584@@ -50,7 +50,7 @@
1585 # The short X.Y version.
1586 version = '2.2'
1587 # The full version, including alpha/beta/rc tags.
1588-release = '2.2.11'
1589+release = '2.2.12'
1590
1591 # The language for content autogenerated by Sphinx. Refer to documentation
1592 # for a list of supported languages.
1593
1594=== modified file 'docs/percona-toolkit.pod'
1595--- docs/percona-toolkit.pod 2014-09-25 13:48:22 +0000
1596+++ docs/percona-toolkit.pod 2014-11-14 14:12:25 +0000
1597@@ -557,6 +557,6 @@
1598
1599 =head1 VERSION
1600
1601-Percona Toolkit v2.2.11 released 2014-09-25
1602+Percona Toolkit v2.2.12 released 2014-11-11
1603
1604 =cut
1605
1606=== modified file 'docs/release_notes.rst'
1607--- docs/release_notes.rst 2014-09-25 13:48:22 +0000
1608+++ docs/release_notes.rst 2014-11-14 14:12:25 +0000
1609@@ -1,6 +1,41 @@
1610 Release Notes
1611 *************
1612
1613+v2.2.12 released 2014-11-14
1614+===========================
1615+
1616+Percona Toolkit 2.2.12 has been released. This release contains one new feature and seven bug fixes.
1617+
1618+New Features:
1619+
1620+* pt-stalk now gathers ``dmesg`` output from up to 60 seconds before the triggering event.
1621+
1622+Bugs Fixed:
1623+
1624+* Fixed bug 1376561: pt-archiver was not able to archive all the rows when a table had a hash partition. Fixed by implementing support for tables which have primary or unique indexes.
1625+
1626+* Fixed bug 1217466: pt-table-checksum would refuses to run on Percona XtraDB Cluster if ``server_id`` was the same on all nodes. Fixed by using the ``wsrep_node_incoming_address`` as a unique identifier for cluster nodes, instead of relying on ``server_id``.
1627+
1628+* Fixed bug 1269695: pt-online-schema-change documentation now contains more information about limitations on why it isn't running ``ALTER TABLE`` for a table which has only a non-unique index.
1629+
1630+* Fixed bug 1328686: Running pt-hearbeat with --check-read-only option would cause an error when running on server with ``read_only`` option. Tool now waits for server ``read_only`` status to be disabled before starting to run.
1631+
1632+* Fixed bug 1373937: pt-table-checksum now supports ``none`` as valid ``--recursion-method`` when using with Percona XtraDB Cluster.
1633+
1634+* Fixed bug 1377888: Documentation was stating that pt-query-digest is able to parse a raw binary log file, while it can only parse a file which was decoded with ``mysqlbinlog`` tool before. Fixed by improving the documentation and adding a check for binary file and providing a relevant error message.
1635+
1636+Changelog
1637+---------
1638+
1639+* Fixed bug 1376561: pt-archiver is not able to archive all the rows when a table has a hash partition
1640+* Fixed bug 1328686: pt-heartbeat check-read-only option does not prevent creates or inserts
1641+* Fixed bug 1269695: pt-online-schema-change does not allow ALTER for a table without a non-unique, while manual does not explain this
1642+* Fixed bug 1217466: pt-table-checksum refuses to run on PXC if server_id is the same on all nodes
1643+* Fixed bug 1373937: pt-table-checksum requires recursion when working with and XtraDB Cluster node
1644+* Fixed bug 1377888: pt-query-digest manual for --type binlog is ambiguous
1645+* Fixed bug 1349086: pt-stalk should also gather dmesg output
1646+* Fixed bug 1361293: Some scripts fail when no-version-check option is put in global config file
1647+
1648 v2.2.11 released 2014-09-26
1649 ===========================
1650
1651
1652=== modified file 'lib/Cxn.pm'
1653--- lib/Cxn.pm 2013-12-05 00:14:17 +0000
1654+++ lib/Cxn.pm 2014-11-14 14:12:25 +0000
1655@@ -226,6 +226,19 @@
1656 return $self->{hostname} || $self->{dsn_name} || 'unknown host';
1657 }
1658
1659+# This is used to help remove_duplicate_cxns detect cluster nodes
1660+# (which often have unreliable server_id's)
1661+sub is_cluster_node {
1662+ my ($self, $cxn) = @_;
1663+
1664+ my $sql = "SHOW VARIABLES LIKE 'wsrep\_on'";
1665+ PTDEBUG && _d($cxn->name, $sql);
1666+ my $row = $cxn->dbh->selectrow_arrayref($sql);
1667+ PTDEBUG && _d(Dumper($row));
1668+ return $row && $row->[1] && ($row->[1] eq 'ON' || $row->[1] eq '1') ? 1 : 0;
1669+
1670+}
1671+
1672 # There's two reasons why there might be dupes:
1673 # If the "master" is a cluster node, then a DSN table might have been
1674 # used, and it may have all nodes' DSNs so the user can run the tool
1675@@ -233,7 +246,7 @@
1676 # on the command line.
1677 # On the other hand, maybe find_cluster_nodes worked, in which case
1678 # we definitely have a dupe for the master cxn, but we may also have a
1679-# dupe for every other node if this was unsed in conjunction with a
1680+# dupe for every other node if this was used in conjunction with a
1681 # DSN table.
1682 # So try to detect and remove those.
1683 sub remove_duplicate_cxns {
1684@@ -245,7 +258,11 @@
1685
1686 for my $cxn ( @cxns ) {
1687 my $dbh = $cxn->dbh();
1688- my $sql = q{SELECT @@server_id};
1689+
1690+ # Very often cluster nodes are configured with matching server_id's
1691+ # So in that case we'll use its incoming address as its unique identifier
1692+ # Note: this relies on "seen_ids" being populated using the same strategy
1693+ my $sql = $self->is_cluster_node($cxn) ? q{SELECT @@wsrep_node_incoming_address} : q{SELECT @@server_id};
1694 PTDEBUG && _d($sql);
1695 my ($id) = $dbh->selectrow_array($sql);
1696 PTDEBUG && _d('Server ID for ', $cxn->name, ': ', $id);
1697
1698=== modified file 'lib/OptionParser.pm'
1699--- lib/OptionParser.pm 2014-05-24 21:36:33 +0000
1700+++ lib/OptionParser.pm 2014-11-14 14:12:25 +0000
1701@@ -1132,6 +1132,16 @@
1702 $parse = 0;
1703 next LINE;
1704 }
1705+
1706+ # Silently ignore option [no]-version-check if it is unsupported and it comes from a config file
1707+ # TODO: Ideally , this should be generalized for all unsupported options that come from global files
1708+ if ( $parse
1709+ && !$self->has('version-check')
1710+ && $line =~ /version-check/
1711+ ) {
1712+ next LINE;
1713+ }
1714+
1715 if ( $parse
1716 && (my($opt, $arg) = $line =~ m/^\s*([^=\s]+?)(?:\s*=\s*(.*?)\s*)?$/)
1717 ) {
1718
1719=== modified file 'lib/Percona/Toolkit.pm'
1720--- lib/Percona/Toolkit.pm 2014-09-24 15:06:32 +0000
1721+++ lib/Percona/Toolkit.pm 2014-11-14 14:12:25 +0000
1722@@ -18,7 +18,7 @@
1723 # ###########################################################################
1724 package Percona::Toolkit;
1725
1726-our $VERSION = '2.2.11';
1727+our $VERSION = '2.2.12';
1728
1729 use strict;
1730 use warnings FATAL => 'all';
1731
1732=== modified file 'lib/Percona/XtraDB/Cluster.pm'
1733--- lib/Percona/XtraDB/Cluster.pm 2013-04-16 20:40:32 +0000
1734+++ lib/Percona/XtraDB/Cluster.pm 2014-11-14 14:12:25 +0000
1735@@ -132,8 +132,29 @@
1736 sub remove_duplicate_cxns {
1737 my ($self, %args) = @_;
1738 my @cxns = @{$args{cxns}};
1739- my $seen_ids = $args{seen_ids};
1740- return Cxn->remove_duplicate_cxns(%args);
1741+ my $seen_ids = $args{seen_ids} || {};
1742+ PTDEBUG && _d("Removing duplicates nodes from ", join(" ", map { $_->name } @cxns));
1743+ my @trimmed_cxns;
1744+
1745+ for my $cxn ( @cxns ) {
1746+ my $dbh = $cxn->dbh();
1747+ # Very often cluster nodes are configured with matching server_id's
1748+ # So in that case we'll use its incoming address as its unique identifier
1749+ # Note: This relies on "seen_ids" being populated using the same strategy
1750+ my $sql = $self->is_cluster_node($cxn) ? q{SELECT @@wsrep_node_incoming_address} : q{SELECT @@server_id};
1751+ PTDEBUG && _d($sql);
1752+ my ($id) = $dbh->selectrow_array($sql);
1753+ PTDEBUG && _d('Server ID for ', $cxn->name, ': ', $id);
1754+
1755+ if ( ! $seen_ids->{$id}++ ) {
1756+ push @trimmed_cxns, $cxn
1757+ }
1758+ else {
1759+ PTDEBUG && _d("Removing ", $cxn->name,
1760+ ", ID ", $id, ", because we've already seen it");
1761+ }
1762+ }
1763+ return \@trimmed_cxns;
1764 }
1765
1766 sub same_cluster {
1767
1768=== modified file 'lib/bash/collect.sh'
1769--- lib/bash/collect.sh 2013-12-14 04:19:51 +0000
1770+++ lib/bash/collect.sh 2014-11-14 14:12:25 +0000
1771@@ -40,6 +40,7 @@
1772 CMD_SYSCTL="${CMD_SYSCTL:-"$(_which sysctl)"}"
1773 CMD_TCPDUMP="${CMD_TCPDUMP:-"$(_which tcpdump)"}"
1774 CMD_VMSTAT="${CMD_VMSTAT:-"$(_which vmstat)"}"
1775+CMD_DMESG="${CMD_DMESG:-"$(_which dmesg)"}"
1776
1777 # Try to find command manually.
1778 [ -z "$CMD_SYSCTL" -a -x "/sbin/sysctl" ] && CMD_SYSCTL="/sbin/sysctl"
1779@@ -146,6 +147,14 @@
1780 if [ "$CMD_SYSCTL" ]; then
1781 $CMD_SYSCTL -a >> "$d/$p-sysctl" &
1782 fi
1783+
1784+ # collect dmesg events from 60 seconds ago until present
1785+ if [ "$CMD_DMESG" ]; then
1786+ local UPTIME=`cat /proc/uptime | awk '{ print $1 }'`
1787+ local START_TIME=$(echo "$UPTIME 60" | awk '{print ($1 - $2)}')
1788+ $CMD_DMESG | perl -ne 'm/\[\s*(\d+)\./; if ($1 > '${START_TIME}') { print }' >> "$d/$p-dmesg" &
1789+ fi
1790+
1791 local cnt=$(($OPT_RUN_TIME / $OPT_SLEEP_COLLECT))
1792 if [ "$CMD_VMSTAT" ]; then
1793 $CMD_VMSTAT $OPT_SLEEP_COLLECT $cnt >> "$d/$p-vmstat" &
1794
1795=== modified file 'lib/bash/parse_options.sh'
1796--- lib/bash/parse_options.sh 2014-07-10 20:15:13 +0000
1797+++ lib/bash/parse_options.sh 2014-11-14 14:12:25 +0000
1798@@ -347,6 +347,9 @@
1799 # Skip blank lines.
1800 [ "$config_opt" = "" ] && continue
1801
1802+ # Skip global option [no]version-check which don't apply
1803+ echo "$config_opt" | grep -v 'version-check' >/dev/null 2>&1 || continue
1804+
1805 # Options in a config file are not prefixed with --,
1806 # but command line options are, so one or the other has
1807 # to add or remove the -- prefix. We add it for config
1808
1809=== modified file 't/lib/OptionParser.t'
1810--- t/lib/OptionParser.t 2014-05-24 21:36:33 +0000
1811+++ t/lib/OptionParser.t 2014-11-14 14:12:25 +0000
1812@@ -2141,6 +2141,29 @@
1813 'prompt_no_echo outputs prompt to STDERR'
1814 );
1815
1816+# #############################################################################
1817+# Issue 1361293: Global config file with no-version-check option makes tools
1818+# that don't recognize the option fail.
1819+# #############################################################################
1820+diag(`echo "no-version-check" > ~/.OptionParser.t.conf`);
1821+$o = new OptionParser(
1822+ description => 'OptionParser.t parses command line options.',
1823+ usage => "$PROGRAM_NAME <options>"
1824+);
1825+$o->get_specs("$trunk/bin/pt-slave-find"), # doesn't have version-check option
1826+$output = output(
1827+ sub {
1828+ $o->get_opts();
1829+ },
1830+ stderr=>1
1831+ );
1832+unlike(
1833+ $output,
1834+ qr/Unknown option: no-version-check/,
1835+ 'no-version-check ignored if unsupported and in config file. issue 1361293'
1836+);
1837+diag(`rm -rf ~/.OptionParser.t.conf`);
1838+
1839
1840
1841 # #############################################################################
1842
1843=== added file 't/lib/samples/binlogs/raw_binlog.log'
1844Binary files t/lib/samples/binlogs/raw_binlog.log 1970-01-01 00:00:00 +0000 and t/lib/samples/binlogs/raw_binlog.log 2014-11-14 14:12:25 +0000 differ
1845=== modified file 't/pt-archiver/basics.t'
1846--- t/pt-archiver/basics.t 2012-11-21 16:21:30 +0000
1847+++ t/pt-archiver/basics.t 2014-11-14 14:12:25 +0000
1848@@ -161,7 +161,7 @@
1849 my $t = time - $t0;
1850
1851 ok(
1852- $t >= 2 && $t <= 3.5,
1853+ $t >= 2 && $t <= ($ENV{PERCONA_SLOW_BOX} ? 5 : 3),
1854 "--sleep between SELECT (bug 979092)"
1855 ) or diag($output, "t=", $t);
1856
1857
1858=== modified file 't/pt-archiver/indexes.t'
1859--- t/pt-archiver/indexes.t 2012-06-03 17:54:32 +0000
1860+++ t/pt-archiver/indexes.t 2014-11-14 14:12:25 +0000
1861@@ -97,7 +97,7 @@
1862
1863 # Check ascending only first column
1864 $output = `$cmd --where 1=1 --dry-run --ascend-first --source D=test,t=table_5,F=$cnf --purge --limit 50 2>&1`;
1865-like ( $output, qr/WHERE \(1=1\) AND \(\(`a` >= \?\)\) LIMIT/, 'Can ascend just first column');
1866+like ( $output, qr/WHERE \(1=1\) AND \(\(`a` >= \?\)\) ORDER BY `a`,`b`,`c`,`d` LIMIT/, 'Can ascend just first column');
1867
1868 # #############################################################################
1869 # Done.
1870
1871=== modified file 't/pt-archiver/samples/issue-248.txt'
1872--- t/pt-archiver/samples/issue-248.txt 2011-06-24 22:02:05 +0000
1873+++ t/pt-archiver/samples/issue-248.txt 2014-11-14 14:12:25 +0000
1874@@ -1,3 +1,3 @@
1875-SELECT /*!40001 SQL_NO_CACHE */ `film_id`,`title`,`description`,`release_year`,`language_id`,`original_language_id`,`rental_duration`,`rental_rate`,`length`,`replacement_cost`,`rating`,`special_features`,`last_update` FROM `sakila`.`film` FORCE INDEX(`PRIMARY`) WHERE (film_id < 100) AND (`film_id` < '1000') LIMIT 1
1876-SELECT /*!40001 SQL_NO_CACHE */ `film_id`,`title`,`description`,`release_year`,`language_id`,`original_language_id`,`rental_duration`,`rental_rate`,`length`,`replacement_cost`,`rating`,`special_features`,`last_update` FROM `sakila`.`film` FORCE INDEX(`PRIMARY`) WHERE (film_id < 100) AND (`film_id` < '1000') AND ((`film_id` >= ?)) LIMIT 1
1877+SELECT /*!40001 SQL_NO_CACHE */ `film_id`,`title`,`description`,`release_year`,`language_id`,`original_language_id`,`rental_duration`,`rental_rate`,`length`,`replacement_cost`,`rating`,`special_features`,`last_update` FROM `sakila`.`film` FORCE INDEX(`PRIMARY`) WHERE (film_id < 100) AND (`film_id` < '1000') ORDER BY `film_id` LIMIT 1
1878+SELECT /*!40001 SQL_NO_CACHE */ `film_id`,`title`,`description`,`release_year`,`language_id`,`original_language_id`,`rental_duration`,`rental_rate`,`length`,`replacement_cost`,`rating`,`special_features`,`last_update` FROM `sakila`.`film` FORCE INDEX(`PRIMARY`) WHERE (film_id < 100) AND (`film_id` < '1000') AND ((`film_id` >= ?)) ORDER BY `film_id` LIMIT 1
1879 DELETE FROM `sakila`.`film` WHERE (`film_id` = ?)
1880
1881=== modified file 't/pt-query-digest/binlog_analyses.t'
1882--- t/pt-query-digest/binlog_analyses.t 2014-07-02 20:55:31 +0000
1883+++ t/pt-query-digest/binlog_analyses.t 2014-11-14 14:12:25 +0000
1884@@ -9,7 +9,7 @@
1885 use strict;
1886 use warnings FATAL => 'all';
1887 use English qw(-no_match_vars);
1888-use Test::More tests => 3;
1889+use Test::More tests => 4;
1890
1891 use PerconaTest;
1892 require "$trunk/bin/pt-query-digest";
1893@@ -46,6 +46,26 @@
1894 'Analysis for binlog011 - Handles 5.6 binlog with checksum CRC32',
1895 ) or diag($test_diff);
1896
1897+
1898+
1899+# #############################################################################
1900+# Issue 1377888: refuse to parse raw binary log
1901+# #############################################################################
1902+
1903+my $output = output(
1904+ sub { pt_query_digest::main(@args, "$trunk/t/lib/samples/binlogs/raw_binlog.log") },
1905+ stderr => 1
1906+);
1907+
1908+like(
1909+ $output,
1910+ qr/mysqlbinlog/i,
1911+ 'Refuses to parse raw binlog file'
1912+);
1913+
1914+
1915+
1916+
1917 # #############################################################################
1918 # Done.
1919 # #############################################################################
1920
1921=== modified file 't/pt-table-checksum/pxc.t'
1922--- t/pt-table-checksum/pxc.t 2013-04-12 15:58:10 +0000
1923+++ t/pt-table-checksum/pxc.t 2014-11-14 14:12:25 +0000
1924@@ -81,6 +81,17 @@
1925 "Dies if no other nodes are found"
1926 );
1927
1928+
1929+($output, $exit_status) = full_output(
1930+ sub { pt_table_checksum::main(@args, '--recursion-method', 'none') },
1931+ stderr => 1,
1932+);
1933+
1934+ok (
1935+ $output =~ qr/WARNING/i && !$exit_status,
1936+ "Warns but doesn't die if --recursion-method=none - issue #1373937"
1937+);
1938+
1939 for my $args (
1940 ["using recusion-method=dsn", '--recursion-method', "dsn=$node1_dsn,D=dsns,t=dsns"],
1941 ["using recursion-method=cluster", '--recursion-method', 'cluster']
1942@@ -144,54 +155,89 @@
1943 "Node3 not changed"
1944 );
1945
1946-for my $args (
1947- ["using recusion-method=dsn", '--recursion-method', "dsn=$node1_dsn,D=dsns,t=dsns"],
1948- ["using recursion-method=cluster", '--recursion-method', 'cluster']
1949- )
1950-{
1951- my $test = shift @$args;
1952-
1953- $output = output(
1954- sub { pt_table_checksum::main(@args,
1955- @$args)
1956- },
1957- stderr => 1,
1958- );
1959-
1960- is(
1961- PerconaTest::count_checksum_results($output, 'errors'),
1962- 0,
1963- "1 diff: no errors ($test)"
1964- );
1965-
1966- is(
1967- PerconaTest::count_checksum_results($output, 'skipped'),
1968- 0,
1969- "1 diff: no skips ($test)"
1970- );
1971-
1972- is(
1973- PerconaTest::count_checksum_results($output, 'diffs'),
1974- 1,
1975- "1 diff: 1 diff ($test)"
1976- ) or diag($output);
1977-
1978- # 11-17T13:02:54 0 1 26 1 0 0.021 test.t
1979- like(
1980- $output,
1981- qr/^\S+\s+ # ts
1982- 0\s+ # errors
1983- 1\s+ # diffs
1984- 26\s+ # rows
1985- \d+\s+ # chunks
1986- 0\s+ # skipped
1987- \S+\s+ # time
1988- test.t$ # table
1989- /xm,
1990- "1 diff: it's in test.t ($test)"
1991- );
1992+sub test_recursion_methods {
1993+ my $same_ids = shift;
1994+
1995+ my ($orig_id_1, $orig_id_2, $orig_id_3);
1996+
1997+ if ($same_ids) {
1998+ # save original values
1999+ my $sql = 'SELECT @@server_id';
2000+ ($orig_id_1) = $node1->selectrow_array($sql);
2001+ ($orig_id_2) = $node2->selectrow_array($sql);
2002+ ($orig_id_3) = $node3->selectrow_array($sql);
2003+ # set server_id value to 1 on all nodes
2004+ $sql = 'SET GLOBAL server_id = 1';
2005+ $node1->do($sql);
2006+ $node2->do($sql);
2007+ $node3->do($sql);
2008+ }
2009+
2010+ for my $args (
2011+ ["using recusion-method=dsn", '--recursion-method', "dsn=$node1_dsn,D=dsns,t=dsns"],
2012+ ["using recursion-method=cluster", '--recursion-method', 'cluster']
2013+ )
2014+ {
2015+ my $test = shift @$args;
2016+ $test = $same_ids ? $test.' - Nodes with different ids' : $test.' - Nodes with same ids';
2017+
2018+ $output = output(
2019+ sub { pt_table_checksum::main(@args,
2020+ @$args)
2021+ },
2022+ stderr => 1,
2023+ );
2024+
2025+ is(
2026+ PerconaTest::count_checksum_results($output, 'errors'),
2027+ 0,
2028+ "1 diff: no errors ($test)"
2029+ );
2030+
2031+ is(
2032+ PerconaTest::count_checksum_results($output, 'skipped'),
2033+ 0,
2034+ "1 diff: no skips ($test)"
2035+ );
2036+
2037+ is(
2038+ PerconaTest::count_checksum_results($output, 'diffs'),
2039+ 1,
2040+ "1 diff: 1 diff ($test)"
2041+ ) or diag($output);
2042+
2043+ # 11-17T13:02:54 0 1 26 1 0 0.021 test.t
2044+ like(
2045+ $output,
2046+ qr/^\S+\s+ # ts
2047+ 0\s+ # errors
2048+ 1\s+ # diffs
2049+ 26\s+ # rows
2050+ \d+\s+ # chunks
2051+ 0\s+ # skipped
2052+ \S+\s+ # time
2053+ test.t$ # table
2054+ /xm,
2055+ "1 diff: it's in test.t ($test)"
2056+ );
2057+ }
2058+
2059+ if ($same_ids) {
2060+ # reset server_id's to original values
2061+ $node1->do("SET GLOBAL server_id = $orig_id_1");
2062+ $node2->do("SET GLOBAL server_id = $orig_id_2");
2063+ $node3->do("SET GLOBAL server_id = $orig_id_3");
2064+ }
2065+
2066 }
2067
2068+# test recursion methods
2069+test_recursion_methods(0);
2070+
2071+# test recursion methods when all nodes have the same id
2072+test_recursion_methods(1);
2073+
2074+
2075 # #############################################################################
2076 # cluster, node1 -> slave, run on node1
2077 # #############################################################################
2078@@ -232,7 +278,7 @@
2079 # Wait for the slave to apply the binlogs from node1 (its master).
2080 # Then change it so it's not consistent.
2081 PerconaTest::wait_for_table($slave_dbh, 'test.t');
2082- $sb->wait_for_slaves('cslave1');
2083+ $sb->wait_for_slaves(master => 'node1', slave => 'cslave1');
2084 $slave_dbh->do("update test.t set c='zebra' where c='z'");
2085
2086 $output = output(

Subscribers

People subscribed via source and target branches