munin-mysql icon indicating copy to clipboard operation
munin-mysql copied to clipboard

percona heartbeat table changed

Open Mrten opened this issue 11 years ago • 0 comments

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.

Mrten avatar Oct 29 '13 21:10 Mrten