divison by zero errors on default Gentoo mysql

Bug #1050737 reported by Brian Fraser
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Percona Toolkit moved to https://jira.percona.com/projects/PT
Fix Released
Medium
Brian Fraser

Bug Description

On a new gentoo box:
$ sudo emerge --sync
$ sudo emerge portage
$ sudo emerge -Du world
$ sudo emerge dev-perl/DBD-mysql
$ sudo emerge bzr
$ bzr branch lp:percona-toolkit
$ cd percona-toolkit/
$ PERCONA_TOOLKIT_BRANCH=`pwd` PERCONA_TOOLKIT_SANDBOX=/usr PATH=$PERCONA_TOOLKIT_SANDBOX/bin:$PATH LD_LIBRARY_PATH=$PERCONA_TOOLKIT_SANDBOX/lib prove t/pt-table-checksum/resume.t
t/pt-table-checksum/resume.t .. 30/48 09-14T06:59:25 Error checksumming table test.t3: Illegal division by zero at /home/vagrant/portable-test-suite/bin/pt-table-checksum line 8933.

This diff fixes it, although I haven't dug any further than that:
=== modified file 'bin/pt-table-checksum'
--- bin/pt-table-checksum 2012-08-29 23:00:34 +0000
+++ bin/pt-table-checksum 2012-09-14 04:45:08 +0000
@@ -8929,7 +8929,7 @@
             # Update the rate of rows per second for the entire server.
             # This is used for the initial chunk size of the next table.
             $total_rows += $cnt;
- $total_time += $tbl->{nibble_time};
+ $total_time += $tbl->{nibble_time} || 1;
             $total_rate = int($total_rows / $total_time);
             PTDEBUG && _d('Total avg rate:', $total_rate);

There's also a similar bug in pt-osc and this:
t/pt-archiver/issue_131.t ............ Illegal division by zero at /home/vagrant/portable-test-suite/bin/pt-archiver line 5784.

Which is $stat_total:
      foreach my $stat (
         reverse sort { $a->{time} <=> $b->{time} } values %summary )
      {
         my $pct = $stat->{time} / $stat_total * 100;
         printf($fmt, @{$stat}{qw(action count time)}, $pct);
         $total2 += $stat->{time};
      }

---

I've actually investigated a bit further. It may come down to this:
Ubuntu 12.04:
$ perl -MTime::HiRes=time -E '$t = time(); sleep 0.900; $t2 = time(); printf "%.6f\n%.6f\n", $t, $t2; printf "%.6f\n", ($t2 - $t)'
1347624407.872023
1347624407.872031
0.000008

Gentoo:
$ perl -MTime::HiRes=time -E '$t = time(); sleep 0.900; $t2 = time(); printf "%.6f\n%.6f\n", $t, $t2; printf "%.6f\n", ($t2 - $t)'
1347624428.420000
1347624428.420000
0.000000

Maybe Gentoo doesn't have a gettimeofday()? Or has it but with less precision than the spec describes? I don't know how to detect this from Perl, but I figure that defaulting to 0.009 should do the trick -- 1 second would throw the statistics out of the window, and looks like at least two microseconds are guaranteed.

Related branches

Brian Fraser (fraserbn)
tags: added: gentoo pt-table-checksum
Brian Fraser (fraserbn)
description: updated
summary: - pt-table-checksum fails on default Gentoo mysql
+ divison by zero errors on default Gentoo mysql
Brian Fraser (fraserbn)
description: updated
Brian Fraser (fraserbn)
tags: added: pt-archiver pt-online-schema-change
Revision history for this message
Brian Fraser (fraserbn) wrote :

Fixed for pt-table-checksum in 2.1.8

tags: removed: pt-table-checksum
Changed in percona-toolkit:
status: Triaged → Fix Committed
assignee: nobody → Brian Fraser (fraserbn)
Revision history for this message
Daniel Nichter (daniel-nichter) wrote :

I think we failed to mention this in the 2.1.8 Changelog, but that's ok.

Changed in percona-toolkit:
status: Fix Committed → Fix Released
Revision history for this message
Shahriyar Rzayev (rzayev-sehriyar) wrote :

Percona now uses JIRA for bug reports so this bug report is migrated to: https://jira.percona.com/browse/PT-581

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.