From b5191a310a483b1a8e8a6c5ca889f209c7138397 Mon Sep 17 00:00:00 2001 From: "Brian Fraser fraserb@gmail.com" <> Date: Tue, 31 Jul 2012 13:33:30 -0300 Subject: [PATCH] Fixes as per Daniel's review; Removed the --quiet usage inpt-osc's nibble_is_safe, as it was ptc cruft --- bin/pt-online-schema-change | 54 ++++++++++++++------------------ t/pt-online-schema-change/bugs.t | 6 ++-- 2 files changed, 27 insertions(+), 33 deletions(-) diff --git a/bin/pt-online-schema-change b/bin/pt-online-schema-change index 1da2e579..749660e4 100755 --- a/bin/pt-online-schema-change +++ b/bin/pt-online-schema-change @@ -6987,14 +6987,12 @@ sub nibble_is_safe { # Ensure that MySQL is using the chunk index if the table is being chunked. if ( !$nibble_iter->one_nibble() - && lc($expl->{key} || '') ne lc($nibble_iter->nibble_index() || '') ) { - if ( !$tbl->{warned}->{not_using_chunk_index}++ - && !$o->get('quiet') ) { - die "Error copying rows at chunk " . $nibble_iter->nibble_number() - . " of $tbl->{db}.$tbl->{tbl} because MySQL chose " - . ($expl->{key} ? "the $expl->{key}" : "no") . " index " - . " instead of the " . $nibble_iter->nibble_index() . "index.\n"; - } + && lc($expl->{key} || '') ne lc($nibble_iter->nibble_index() || '') ) + { + die "Error copying rows at chunk " . $nibble_iter->nibble_number() + . " of $tbl->{db}.$tbl->{tbl} because MySQL chose " + . ($expl->{key} ? "the $expl->{key}" : "no") . " index " + . " instead of the " . $nibble_iter->nibble_index() . "index.\n"; } # Ensure that the chunk isn't too large if there's a --chunk-size-limit. @@ -7007,18 +7005,16 @@ sub nibble_is_safe { : 0; if ( $oversize_chunk && $nibble_iter->identical_boundaries($boundary->{upper}, - $boundary->{next_lower}) ) { - if ( !$tbl->{warned}->{oversize_chunk}++ - && !$o->get('quiet') ) { - die "Error copying rows at chunk " . $nibble_iter->nibble_number() - . " of $tbl->{db}.$tbl->{tbl} because it is oversized. " - . "The current chunk size limit is " - . ($tbl->{chunk_size} * $limit) - . " rows (chunk size=$tbl->{chunk_size}" - . " * chunk size limit=$limit), but MySQL estimates " - . "that there are " . ($expl->{rows} || 0) - . " rows in the chunk.\n"; - } + $boundary->{next_lower}) ) + { + die "Error copying rows at chunk " . $nibble_iter->nibble_number() + . " of $tbl->{db}.$tbl->{tbl} because it is oversized. " + . "The current chunk size limit is " + . ($tbl->{chunk_size} * $limit) + . " rows (chunk size=$tbl->{chunk_size}" + . " * chunk size limit=$limit), but MySQL estimates " + . "that there are " . ($expl->{rows} || 0) + . " rows in the chunk.\n"; } } @@ -7026,16 +7022,14 @@ sub nibble_is_safe { # https://bugs.launchpad.net/percona-toolkit/+bug/1010232 if ( !$nibble_iter->one_nibble() && $tbl->{key_len} - && ($expl->{key_len} || 0) < $tbl->{key_len} ) { - if ( !$tbl->{warned}->{key_len}++ - && !$o->get('quiet') ) { - die "Error copying rows at chunk " . $nibble_iter->nibble_number() - . " of $tbl->{db}.$tbl->{tbl} because MySQL used " - . "only " . ($expl->{key_len} || 0) . " bytes " - . "of the " . ($expl->{key} || '?') . " index instead of " - . $tbl->{key_len} . ". See the --[no]check-plan documentation " - . "for more information.\n"; - } + && ($expl->{key_len} || 0) < $tbl->{key_len} ) + { + die "Error copying rows at chunk " . $nibble_iter->nibble_number() + . " of $tbl->{db}.$tbl->{tbl} because MySQL used " + . "only " . ($expl->{key_len} || 0) . " bytes " + . "of the " . ($expl->{key} || '?') . " index instead of " + . $tbl->{key_len} . ". See the --[no]check-plan documentation " + . "for more information.\n"; } return 1; # safe diff --git a/t/pt-online-schema-change/bugs.t b/t/pt-online-schema-change/bugs.t index 02acbc9f..11128b8d 100644 --- a/t/pt-online-schema-change/bugs.t +++ b/t/pt-online-schema-change/bugs.t @@ -152,10 +152,10 @@ like $output, ); }; - is( + like( $EVAL_ERROR, - '', - "..unless --quiet was specified", + qr/Error copying rows at chunk.*because MySQL chose/, + "...even if --quiet was specified", ); }