pt-table-sync division by zero error with varchar primary key
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Percona Toolkit moved to https://jira.percona.com/projects/PT |
Fix Released
|
High
|
Brian Fraser |
Bug Description
When using pt-table-sync 2.1.2 to sync a table with a varchar primary key, I am receiving the following errors at times:
- Failed to prepare TableSyncChunk plugin: Illegal division by zero at /usr/bin/
- Failed to prepare TableSyncChunk plugin: Use of uninitialized value in join or string at /usr/bin/
I attached a reproduce table for the "Illegal division by zero" error, but I'm having difficulty narrowing down a reproduce table for the 2nd error without it having thousands of rows. I believe both issues relate to the distribution of values in some form as it seems to be very intermittent based on the data in my table.
My sync script is:
pt-table-sync --execute h=localhost,
Please let me know if this is enough to investigate, or if you need more details. Thanks.
Related branches
- Daniel Nichter: Approve
-
Diff: 137 lines (+74/-4) (has conflicts)4 files modifiedbin/pt-table-sync (+10/-0)
lib/TableChunker.pm (+7/-0)
t/lib/TableChunker.t (+37/-4)
t/lib/samples/bug_1034717.sql (+20/-0)
Changed in percona-toolkit: | |
status: | New → Confirmed |
Changed in percona-toolkit: | |
importance: | Undecided → Medium |
milestone: | none → 2.1.4 |
tags: | added: chunking crash pt-table-sync |
Changed in percona-toolkit: | |
importance: | Medium → High |
Changed in percona-toolkit: | |
assignee: | nobody → Brian Fraser (fraserbn) |
Changed in percona-toolkit: | |
status: | Confirmed → In Progress |
Changed in percona-toolkit: | |
status: | In Progress → Fix Committed |
summary: |
- pt-table-sync errors with varchar primary key + pt-table-sync division by zero error with varchar primary key |
Changed in percona-toolkit: | |
status: | Fix Committed → Fix Released |
Reproduced as follows:
mysql -e 'create database test1;'
mysql test < reproduce.sql
mysql test1 < reproduce.sql
pt-table-sync --execute h=localhost, P=3306, D=test, t=table1 D=test1
It is failing here: my $highest_power = floor(log( $n)/log( $base)) ; when $base=1 the denom. is zero. That may be because the ord of '1001' and '10873' (the first and last column values) is same.
This seems to be fixing it:
======= ======= ======= ====
diff -u bin/pt-table-sync /tmp/pt-table-sync required_ args};
--- bin/pt-table-sync 2012-08-08 11:52:07.869453000 +0530
+++ /tmp/pt-table-sync 2012-08-09 16:51:41.673466697 +0530
@@ -4438,7 +4438,7 @@
}
my ($n, $base, $symbols) = @args{@
- return $symbols->[0] if $n == 0;
+ return $symbols->[0] if $n == 0 || $base == 1;
my $highest_power = floor(log( $n)/log( $base)) ;
if ( $highest_power == 0 ){
=================
Tested with different values.