mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-28 00:21:56 +00:00
Merged fix-1022628-standarize-pt-osc-quiet
This commit is contained in:
@@ -6987,15 +6987,13 @@ sub nibble_is_safe {
|
|||||||
|
|
||||||
# Ensure that MySQL is using the chunk index if the table is being chunked.
|
# Ensure that MySQL is using the chunk index if the table is being chunked.
|
||||||
if ( !$nibble_iter->one_nibble()
|
if ( !$nibble_iter->one_nibble()
|
||||||
&& lc($expl->{key} || '') ne lc($nibble_iter->nibble_index() || '') ) {
|
&& lc($expl->{key} || '') ne lc($nibble_iter->nibble_index() || '') )
|
||||||
if ( !$tbl->{warned}->{not_using_chunk_index}++
|
{
|
||||||
&& $o->get('quiet') < 2 ) {
|
|
||||||
die "Error copying rows at chunk " . $nibble_iter->nibble_number()
|
die "Error copying rows at chunk " . $nibble_iter->nibble_number()
|
||||||
. " of $tbl->{db}.$tbl->{tbl} because MySQL chose "
|
. " of $tbl->{db}.$tbl->{tbl} because MySQL chose "
|
||||||
. ($expl->{key} ? "the $expl->{key}" : "no") . " index "
|
. ($expl->{key} ? "the $expl->{key}" : "no") . " index "
|
||||||
. " instead of the " . $nibble_iter->nibble_index() . "index.\n";
|
. " instead of the " . $nibble_iter->nibble_index() . "index.\n";
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
# Ensure that the chunk isn't too large if there's a --chunk-size-limit.
|
# Ensure that the chunk isn't too large if there's a --chunk-size-limit.
|
||||||
# If single-chunking the table, this has already been checked, so it
|
# If single-chunking the table, this has already been checked, so it
|
||||||
@@ -7007,9 +7005,8 @@ sub nibble_is_safe {
|
|||||||
: 0;
|
: 0;
|
||||||
if ( $oversize_chunk
|
if ( $oversize_chunk
|
||||||
&& $nibble_iter->identical_boundaries($boundary->{upper},
|
&& $nibble_iter->identical_boundaries($boundary->{upper},
|
||||||
$boundary->{next_lower}) ) {
|
$boundary->{next_lower}) )
|
||||||
if ( !$tbl->{warned}->{oversize_chunk}++
|
{
|
||||||
&& $o->get('quiet') < 2 ) {
|
|
||||||
die "Error copying rows at chunk " . $nibble_iter->nibble_number()
|
die "Error copying rows at chunk " . $nibble_iter->nibble_number()
|
||||||
. " of $tbl->{db}.$tbl->{tbl} because it is oversized. "
|
. " of $tbl->{db}.$tbl->{tbl} because it is oversized. "
|
||||||
. "The current chunk size limit is "
|
. "The current chunk size limit is "
|
||||||
@@ -7020,15 +7017,13 @@ sub nibble_is_safe {
|
|||||||
. " rows in the chunk.\n";
|
. " rows in the chunk.\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
# Ensure that MySQL is still using the entire index.
|
# Ensure that MySQL is still using the entire index.
|
||||||
# https://bugs.launchpad.net/percona-toolkit/+bug/1010232
|
# https://bugs.launchpad.net/percona-toolkit/+bug/1010232
|
||||||
if ( !$nibble_iter->one_nibble()
|
if ( !$nibble_iter->one_nibble()
|
||||||
&& $tbl->{key_len}
|
&& $tbl->{key_len}
|
||||||
&& ($expl->{key_len} || 0) < $tbl->{key_len} ) {
|
&& ($expl->{key_len} || 0) < $tbl->{key_len} )
|
||||||
if ( !$tbl->{warned}->{key_len}++
|
{
|
||||||
&& $o->get('quiet') < 2 ) {
|
|
||||||
die "Error copying rows at chunk " . $nibble_iter->nibble_number()
|
die "Error copying rows at chunk " . $nibble_iter->nibble_number()
|
||||||
. " of $tbl->{db}.$tbl->{tbl} because MySQL used "
|
. " of $tbl->{db}.$tbl->{tbl} because MySQL used "
|
||||||
. "only " . ($expl->{key_len} || 0) . " bytes "
|
. "only " . ($expl->{key_len} || 0) . " bytes "
|
||||||
@@ -7036,7 +7031,6 @@ sub nibble_is_safe {
|
|||||||
. $tbl->{key_len} . ". See the --[no]check-plan documentation "
|
. $tbl->{key_len} . ". See the --[no]check-plan documentation "
|
||||||
. "for more information.\n";
|
. "for more information.\n";
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return 1; # safe
|
return 1; # safe
|
||||||
}
|
}
|
||||||
|
@@ -28,9 +28,6 @@ if ( !$master_dbh ) {
|
|||||||
elsif ( !$slave_dbh ) {
|
elsif ( !$slave_dbh ) {
|
||||||
plan skip_all => 'Cannot connect to sandbox slave1';
|
plan skip_all => 'Cannot connect to sandbox slave1';
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
plan tests => 7;
|
|
||||||
}
|
|
||||||
|
|
||||||
# The sandbox servers run with lock_wait_timeout=3 and it's not dynamic
|
# The sandbox servers run with lock_wait_timeout=3 and it's not dynamic
|
||||||
# so we need to specify --lock-wait-timeout=3 else the tool will die.
|
# so we need to specify --lock-wait-timeout=3 else the tool will die.
|
||||||
@@ -111,9 +108,61 @@ like $output,
|
|||||||
qr/\QNot updating foreign key constraints because this is a dry run./,
|
qr/\QNot updating foreign key constraints because this is a dry run./,
|
||||||
"Bug 1003315: But now we do get an explanation from --dry-run";
|
"Bug 1003315: But now we do get an explanation from --dry-run";
|
||||||
|
|
||||||
|
# ############################################################################
|
||||||
|
# This fakes the conditions to trigger the chunk index error
|
||||||
|
# ############################################################################
|
||||||
|
{
|
||||||
|
my $o = new OptionParser(file => "$trunk/bin/pt-table-checksum");
|
||||||
|
$o->get_specs();
|
||||||
|
no warnings;
|
||||||
|
local *pt_online_schema_change::explain_statement = sub {
|
||||||
|
return { key => 'some_key' }
|
||||||
|
};
|
||||||
|
{
|
||||||
|
package PerconaTest::Fake::NibbleIterator;
|
||||||
|
sub AUTOLOAD {
|
||||||
|
our $AUTOLOAD = $AUTOLOAD;
|
||||||
|
return if $AUTOLOAD =~ /one_nibble/;
|
||||||
|
return { lower => [], upper => [] }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
eval {
|
||||||
|
pt_online_schema_change::nibble_is_safe(
|
||||||
|
Cxn => 1,
|
||||||
|
tbl => {qw( db some_db tbl some_table )},
|
||||||
|
NibbleIterator => bless({}, "PerconaTest::Fake::NibbleIterator"),
|
||||||
|
OptionParser => $o,
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
like(
|
||||||
|
$EVAL_ERROR,
|
||||||
|
qr/Error copying rows at chunk.*because MySQL chose/,
|
||||||
|
"Dies if MySQL isn't using the chunk index"
|
||||||
|
);
|
||||||
|
|
||||||
|
$o->set('quiet', 1);
|
||||||
|
eval {
|
||||||
|
pt_online_schema_change::nibble_is_safe(
|
||||||
|
Cxn => 1,
|
||||||
|
tbl => {qw( db some_db tbl some_table )},
|
||||||
|
NibbleIterator => bless({}, "PerconaTest::Fake::NibbleIterator"),
|
||||||
|
OptionParser => $o,
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
like(
|
||||||
|
$EVAL_ERROR,
|
||||||
|
qr/Error copying rows at chunk.*because MySQL chose/,
|
||||||
|
"...even if --quiet was specified",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
# Done.
|
# Done.
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
$sb->wipe_clean($master_dbh);
|
$sb->wipe_clean($master_dbh);
|
||||||
ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox");
|
ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox");
|
||||||
exit;
|
|
||||||
|
done_testing;
|
||||||
|
@@ -9,7 +9,7 @@ BEGIN {
|
|||||||
use strict;
|
use strict;
|
||||||
use warnings FATAL => 'all';
|
use warnings FATAL => 'all';
|
||||||
use English qw(-no_match_vars);
|
use English qw(-no_match_vars);
|
||||||
use Test::More tests => 8;
|
use Test::More;
|
||||||
|
|
||||||
use PerconaTest;
|
use PerconaTest;
|
||||||
|
|
||||||
@@ -75,4 +75,4 @@ like(
|
|||||||
# #############################################################################
|
# #############################################################################
|
||||||
# Done.
|
# Done.
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
exit;
|
done_testing;
|
||||||
|
Reference in New Issue
Block a user