From 66c0abfe8ec2097d98283779d9fa5166d0f4b28c Mon Sep 17 00:00:00 2001 From: Daniel Nichter Date: Tue, 27 Dec 2011 10:24:35 -0700 Subject: [PATCH] Don't reset @crc or @cnt. Docu output of --replicate-check-only. --- bin/pt-table-checksum | 67 ++++++++++++++++++++++++----- t/pt-table-checksum/basics.t | 2 +- t/pt-table-checksum/option_sanity.t | 4 +- 3 files changed, 60 insertions(+), 13 deletions(-) diff --git a/bin/pt-table-checksum b/bin/pt-table-checksum index 77141d01..48390f7b 100755 --- a/bin/pt-table-checksum +++ b/bin/pt-table-checksum @@ -6767,11 +6767,6 @@ sub exec_nibble { # ################################################################### my $t_start = time; - # Reset the BIT_XOR user vars. - my $sql = 'SET @crc := "", @cnt := 0'; - MKDEBUG && _d($sql); - $dbh->do($sql); - # Execute the REPLACE...SELECT checksum query. MKDEBUG && _d($sth->{nibble}->{Statement}, 'lower boundary:', @{$boundary->{lower}}, @@ -7527,9 +7522,9 @@ progress. =item DIFFS -The number of chunks that differ from the master on one or more replicas. If ---no-replicate-check is specified, this column will always have zeros. -If --replicate-check-only is specified, then only tables with differences +The number of chunks that differ from the master on one or more replicas. +If C<--no-replicate-check> is specified, this column will always have zeros. +If L<"--replicate-check-only"> is specified, then only tables with differences are printed. =item ROWS @@ -7556,6 +7551,58 @@ The database and table that was checksummed. =back +If L<"--replicate-check-only"> is specified, only checksum differences on +detected replicas are printed. The output is different: one paragraph per +replica, one checksum difference per line, and values are separted by spaces: + + Differences on h=127.0.0.1,P=12346 + TABLE CHUNK CNT_DIFF CRC_DIFF CHUNK_INDEX LOWER_BOUNDARY UPPER_BOUNDARY + db1.tbl1 1 0 1 PRIMARY 1 100 + db1.tbl1 6 0 1 PRIMARY 501 600 + + Differences on h=127.0.0.1,P=12347 + TABLE CHUNK CNT_DIFF CRC_DIFF CHUNK_INDEX LOWER_BOUNDARY UPPER_BOUNDARY + db1.tbl1 1 0 1 PRIMARY 1 100 + db2.tbl2 9 5 0 PRIMARY 101 200 + +The first line of a paragraph indicates the replica with differences. +In this example there are two: h=127.0.0.1,P=12346 and h=127.0.0.1,P=12347. +The columns are as follows: + +=over + +=item TABLE + +The database and table that differs from the master. + +=item CHUNK + +The chunk number of the table that differs from the master. + +=item CNT_DIFF + +The number of chunk rows on the replica minus the number of chunk rows +on the master. + +=item CRC_DIFF + +1 if the CRC of the chunk on the replica is different than the CRC of the +chunk on the master, else 0. + +=item CHUNK_INDEX + +The index used to chunk the table. + +=item LOWER_BOUNDARY + +The index values that define the lower boundary of the chunk. + +=item UPPER_BOUNDARY + +The index values that define the upper boundary of the chunk. + +=back + =head1 EXIT STATUS A non-zero exit status indicates errors, warnings, or checksum differences. @@ -8040,7 +8087,7 @@ table to L<"--ignore-tables">). default: yes Check replicas for data differences after finishing each table. The tool finds -differences by executing a simple SELECT statement on all connected replicas. +differences by executing a simple SELECT statement on all detected replicas. The query compares the replica's checksum results to the master's checksum results. It reports differences in the DIFFS column of the output. @@ -8048,7 +8095,7 @@ results. It reports differences in the DIFFS column of the output. Check replicas for consistency without executing checksum queries. This option is used only with L<"--[no]replicate-check">. If specified, -pt-table-checksum doesn't checksum any tables. It checks replicas for +pt-table-checksum doesn't checksum any tables. It checks replicas for differences found by previous checksumming, and then exits. It might be useful if you run pt-table-checksum quietly in a cron job, for example, and later want a report on the results of the cron job, perhaps to implement a Nagios check. diff --git a/t/pt-table-checksum/basics.t b/t/pt-table-checksum/basics.t index dffbdad8..7c5e6e74 100644 --- a/t/pt-table-checksum/basics.t +++ b/t/pt-table-checksum/basics.t @@ -196,7 +196,7 @@ $slave_dbh->do("update percona.checksums set this_crc='' where db='sakila' and t ok( no_diff( - sub { pt_table_checksum::main(@args, qw(--no-recheck)) }, + sub { pt_table_checksum::main(@args, qw(--replicate-check-only)) }, "$sample/no-recheck.txt", ), "--no-recheck (just --replicate-check)" diff --git a/t/pt-table-checksum/option_sanity.t b/t/pt-table-checksum/option_sanity.t index 210e0743..5a1046ce 100644 --- a/t/pt-table-checksum/option_sanity.t +++ b/t/pt-table-checksum/option_sanity.t @@ -79,8 +79,8 @@ like( like( $output, - qr/^ --recheck\s+TRUE$/m, - "Default --recheck=TRUE" + qr/^ --replicate-check-only\s+FALSE$/m, + "Default --replicate-check-only=FALSE" ); like(