diff --git a/bin/pt-heartbeat b/bin/pt-heartbeat index 35ab1432..122832c7 100755 --- a/bin/pt-heartbeat +++ b/bin/pt-heartbeat @@ -5863,6 +5863,16 @@ short form: -u; type: string User for login if not current user. +=item --utc + +Ignore system time zones and use only UTC. By default pt-heartbeat does +not check or adjust for different system or MySQL time zones which can +cause the tool to compute the lag incorrectly. Specifying this option is +a good idea because it ensures that the tool works correctly regardless of +time zones, but it also makes the tool backwards-incompatible with +pt-heartbeat 2.1.7 and older (unless the older version of pt-heartbeat +is running on a system that uses UTC). + =item --version Show version and exit. diff --git a/t/pt-heartbeat/bugs.t b/t/pt-heartbeat/bugs.t index d50ef976..3969c395 100644 --- a/t/pt-heartbeat/bugs.t +++ b/t/pt-heartbeat/bugs.t @@ -89,7 +89,7 @@ PerconaTest::wait_for_table($slave1_dbh, 'test.heartbeat', 'server_id=12345'); my $slave1_dsn = $sb->dsn_for('slave1'); # Using full_output here to work around a Perl bug: Only the first explicit # tzset works. -($output) = full_output(sub { +($output) = output(sub { local $ENV{TZ} = '-09:00'; tzset(); pt_heartbeat::main($slave1_dsn, qw(--database test --table heartbeat), @@ -107,6 +107,31 @@ like( stop_all_instances(); + +# ############################################################################# +# pt-heartbeat 2.1.8 doesn't use precision/sub-second timestamps +# https://bugs.launchpad.net/percona-toolkit/+bug/1103221 +# ############################################################################# + +$master_dbh->do('truncate table test.heartbeat'); +$sb->wait_for_slaves; + +my $master_dsn = $sb->dsn_for('master'); + +($output) = output( + sub { + pt_heartbeat::main($master_dsn, qw(--database test --update), + qw(--run-time 1)) + }, +); + +my ($row) = $master_dbh->selectrow_hashref('select * from test.heartbeat'); +like( + $row->{ts}, + qr/\d{4}-\d\d-\d\dT\d+:\d+:\d+\.\d+/, + "Hi-res timestamp (bug 1103221)" +); + # ############################################################################ # Done. # ############################################################################