mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-09 18:30:16 +00:00
Merged fix-1034717-divison-by-zero-base-1
This commit is contained in:
@@ -3978,6 +3978,12 @@ sub _chunk_char {
|
|||||||
}
|
}
|
||||||
PTDEBUG && _d("Base", $base, "chars:", @chars);
|
PTDEBUG && _d("Base", $base, "chars:", @chars);
|
||||||
|
|
||||||
|
die "Cannot chunk table $db_tbl using the character column "
|
||||||
|
. "$chunk_col, most likely because all values start with the "
|
||||||
|
. "same character. This table must be synced separately by "
|
||||||
|
. "specifying a list of --algorithms without the Chunk algorithm"
|
||||||
|
if $base == 1;
|
||||||
|
|
||||||
|
|
||||||
$sql = "SELECT MAX(LENGTH($qchunk_col)) FROM $db_tbl "
|
$sql = "SELECT MAX(LENGTH($qchunk_col)) FROM $db_tbl "
|
||||||
. ($args{where} ? "WHERE $args{where} " : "")
|
. ($args{where} ? "WHERE $args{where} " : "")
|
||||||
@@ -11192,6 +11198,10 @@ primary key columns and a checksum are sent over the network, not the entire
|
|||||||
row. If a row is found to be different, the entire row will be fetched, but not
|
row. If a row is found to be different, the entire row will be fetched, but not
|
||||||
before.
|
before.
|
||||||
|
|
||||||
|
Note that this algorithm will not work if chunking a char column where all
|
||||||
|
the values start with the same character. In that case, the tool will exit
|
||||||
|
and suggest picking a different algorithm.
|
||||||
|
|
||||||
=item Nibble
|
=item Nibble
|
||||||
|
|
||||||
Finds an index and ascends the index in fixed-size nibbles of L<"--chunk-size">
|
Finds an index and ascends the index in fixed-size nibbles of L<"--chunk-size">
|
||||||
|
@@ -627,6 +627,13 @@ sub _chunk_char {
|
|||||||
}
|
}
|
||||||
PTDEBUG && _d("Base", $base, "chars:", @chars);
|
PTDEBUG && _d("Base", $base, "chars:", @chars);
|
||||||
|
|
||||||
|
# See https://bugs.launchpad.net/percona-toolkit/+bug/1034717
|
||||||
|
die "Cannot chunk table $db_tbl using the character column "
|
||||||
|
. "$chunk_col, most likely because all values start with the "
|
||||||
|
. "same character. This table must be synced separately by "
|
||||||
|
. "specifying a list of --algorithms without the Chunk algorithm"
|
||||||
|
if $base == 1;
|
||||||
|
|
||||||
# Now we begin calculating how to chunk the char column. This is
|
# Now we begin calculating how to chunk the char column. This is
|
||||||
# completely different from _chunk_numeric because we're not dealing
|
# completely different from _chunk_numeric because we're not dealing
|
||||||
# with the values to chunk directly (the characters) but rather a map.
|
# with the values to chunk directly (the characters) but rather a map.
|
||||||
|
@@ -25,9 +25,6 @@ my $dbh = $sb->get_dbh_for('master');
|
|||||||
if ( !$dbh ) {
|
if ( !$dbh ) {
|
||||||
plan skip_all => 'Cannot connect to sandbox master';
|
plan skip_all => 'Cannot connect to sandbox master';
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
plan tests => 94;
|
|
||||||
}
|
|
||||||
|
|
||||||
$sb->create_dbs($dbh, ['test']);
|
$sb->create_dbs($dbh, ['test']);
|
||||||
|
|
||||||
@@ -1358,11 +1355,10 @@ is_deeply(
|
|||||||
"Caclulate chunks for `key` col (bug 967451)"
|
"Caclulate chunks for `key` col (bug 967451)"
|
||||||
);
|
);
|
||||||
|
|
||||||
# #############################################################################
|
# ############################################################################# ">
|
||||||
# base_count fails on n = 1000, base = 10
|
# base_count fails on n = 1000, base = 10
|
||||||
# https://bugs.launchpad.net/percona-toolkit/+bug/1028710
|
# https://bugs.launchpad.net/percona-toolkit/+bug/1028710
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
|
|
||||||
my $res = TableChunker->base_count(
|
my $res = TableChunker->base_count(
|
||||||
count_to => 1000,
|
count_to => 1000,
|
||||||
base => 10,
|
base => 10,
|
||||||
@@ -1375,9 +1371,43 @@ is(
|
|||||||
"base_count's floor()s account for floating point arithmetics",
|
"base_count's floor()s account for floating point arithmetics",
|
||||||
);
|
);
|
||||||
|
|
||||||
|
# #############################################################################
|
||||||
|
# Bug 1034717: Divison by zero error when all columns tsart with the same char
|
||||||
|
# https://bugs.launchpad.net/percona-toolkit/+bug/1034717
|
||||||
|
# #############################################################################
|
||||||
|
$sb->load_file('master', "t/lib/samples/bug_1034717.sql", 'test');
|
||||||
|
$t = $tp->parse( $tp->get_create_table($dbh, 'bug_1034717', 'table1') );
|
||||||
|
|
||||||
|
%params = $c->get_range_statistics(
|
||||||
|
dbh => $dbh,
|
||||||
|
db => 'bug_1034717',
|
||||||
|
tbl => 'table1',
|
||||||
|
chunk_col => 'field1',
|
||||||
|
tbl_struct => $t,
|
||||||
|
);
|
||||||
|
|
||||||
|
local $EVAL_ERROR;
|
||||||
|
eval {
|
||||||
|
$c->calculate_chunks(
|
||||||
|
dbh => $dbh,
|
||||||
|
db => 'bug_1034717',
|
||||||
|
tbl => 'table1',
|
||||||
|
tbl_struct => $t,
|
||||||
|
chunk_col => 'field1',
|
||||||
|
chunk_size => '50',
|
||||||
|
%params,
|
||||||
|
);
|
||||||
|
};
|
||||||
|
like(
|
||||||
|
$EVAL_ERROR,
|
||||||
|
qr/^\QCannot chunk table `bug_1034717`.`table1` using the character column field1, most likely because all values start with the /,
|
||||||
|
"Bug 1034717: Catches the base == 1 case and dies"
|
||||||
|
);
|
||||||
|
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
# Done.
|
# Done.
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
$sb->wipe_clean($dbh);
|
$sb->wipe_clean($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;
|
||||||
|
20
t/lib/samples/bug_1034717.sql
Normal file
20
t/lib/samples/bug_1034717.sql
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user