Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

percona heartbeat table changed #64

Open
Mrten opened this issue Oct 29, 2013 · 0 comments
Open

percona heartbeat table changed #64

Mrten opened this issue Oct 29, 2013 · 0 comments

Comments

@Mrten
Copy link

Mrten commented Oct 29, 2013

With 2.2.x, the format of the heartbeat db changed. Instead of a DATETIME, it is now a VARCHAR(26) with an iso-like timestamp in it.

--- mysql.old   2013-10-29 21:44:25.245704247 +0100
+++ mysql   2013-10-29 22:00:11.197708057 +0100
@@ -480,7 +480,7 @@
     # The TIME_TO_SEC(TIMEDIFF in the query is necessary as mysql
     # otherwise calculates the wrong difference (simply substracting
     # won't work)
-    my $heartbeat_query = "SELECT TIME_TO_SEC(TIMEDIFF(NOW(), ts)) AS seconds_behind_master
+    my $heartbeat_query = "SELECT TIME_TO_SEC(TIMEDIFF(NOW(), STR_TO_DATE( ts, '%Y-%m-%dT%H:%i:%s' ))) AS seconds_behind_master
           FROM $config{maatkit_heartbeat_table}
          LIMIT 1";
     my $sth = $dbh->prepare($heartbeat_query);

This is not the way to solve this, it's not backwards compatible but works for me because I don't have old percona-toolkits around.

There is another problem this patch does not touch: you can now have multiple masters that run pt-heartbeat, and consequently have multiple rows in the heartbeat db. This is caught for the moment by the LIMIT 1, but that needs reconsideration because, without an ORDER you can't know which row mysql picks so the delay in the graph might jump around.

Perhaps you should configure an server_id that you want graphed, or perhaps this could graph all such rows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant