pt-table-checksum doesn't use non-unique index with highest cardinality
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Percona Toolkit moved to https://jira.percona.com/projects/PT |
Fix Released
|
High
|
Daniel Nichter | ||
2.1 |
Fix Released
|
Medium
|
Daniel Nichter | ||
2.2 |
Fix Released
|
High
|
Daniel Nichter |
Bug Description
If there are only non-unique index, pt-table-checksum should choose the one with the highest cardinality, but it doesn't. In NIbbleIterator.pm:
if ( !$best_index && @possible_indexes ) {
PTDEBUG && _d('No PRIMARY or unique indexes;',
'will use index with highest cardinality');
foreach my $index ( @possible_indexes ) {
%args,
index => $index,
);
}
@
# Prefer the index with the highest cardinality.
my $cmp
= $indexes-
if ( $cmp == 0 ) {
# Indexes have the same cardinality; prefer the one with
# more columns.
$cmp = scalar @{$indexes-
<=> scalar @{$indexes-
}
$cmp;
} @possible_indexes;
$best_index = $possible_
}
We need to test that block.
Related branches
- Daniel Nichter: Approve
-
Diff: 139 lines (+73/-7)5 files modifiedbin/pt-online-schema-change (+1/-1)
bin/pt-table-checksum (+1/-1)
lib/NibbleIterator.pm (+1/-1)
t/lib/NibbleIterator.t (+21/-4)
t/lib/samples/cardinality.sql (+49/-0)
- Daniel Nichter: Approve
-
Diff: 139 lines (+73/-7)5 files modifiedbin/pt-online-schema-change (+1/-1)
bin/pt-table-checksum (+1/-1)
lib/NibbleIterator.pm (+1/-1)
t/lib/NibbleIterator.t (+21/-4)
t/lib/samples/cardinality.sql (+49/-0)
Changed in percona-toolkit: | |
assignee: | nobody → Daniel Nichter (daniel-nichter) |
Simple fix, can you spot it? :
my $cmp >{$b}-> {cardinality} <=> $indexes- >{$b}-> {cardinality} ;
= $indexes-
If not, see the branches.