Monday, March 28, 2011

MySQL Timezone support: Updating and Monitoring

How old is your timezone info?
As the timezone database gets updated frequently, it's important to update the internal timezone database in MySQL. This is needed for the CONVERT_TZ() function for work properly.

It's not easy to determine if the data in mysql is older than the data from the tzdata database. It get's a bit better if you use this hack before importing the zone database:
I've created Bug #60675 to get the system database updated.

Which database serves still need timezone info?
Use MySQL Enterprise Monitor with custom rules.

1. Add data query
Open /opt/mysql/enterprise/agent/share/mysql-monitor-agent/items/custom.xml in an editor and add this:
<query><!--[CDATA[SELECT CONVERT_TZ(NOW(),'GMT','MET') IS NOT NULL]]--></query>

2. Restart the mysql-monitor-agent

3. Create a custom rule in the MySQL Enterprise Dashboard (Advisor→Manage Rules→create rule):

Rule Name: Timezone data is not loaded.
Expression: %tzdata_avail% == THRESHOLD
Critical: 0
Variable Assignment
Variable: %tzdata_avail%
Data Item: mysql:tzdata_available:tzdata_available
Instance: local
Default Frequency: 30 minutes

Problem Description: "There is no timezone info loaded in mysql. This causes the CONVERT_TZ() function to return NULL instead of the requested conversion."

Advice: "None Specified"

Recommended Action: "Use the mysql_tzinfo_to_sql utility to convert the zoneinfo database to SQL and load the converted data into the mysql database."
Links and Further Reading:
* {moreInfo:mysql_tzinfo_to_sql — Load the Time Zone Tables|}
* {moreInfo:MySQL Server Time Zone Support|}

4. Add the rule to a schedule


  1. Nice, we should probably add this check by default.. :)

    Want to open a bug for it?

  2. Never mind, I see Bug#60676 came in as well.. :)

  3. Payday advances are a transient loan, when it is required the most...usually between paydays! Payday credits are an awesome method to get some money to hold you over to your next paycheck. The objective of payday advances is to help you with accounts to meet that unforseen prerequisite. Payday Loans

  4. Roku device is the best service in the USA, Do you have an issue with your Roku Device? Get instant solution and support by Roku Helpline Number. We are dealing with a wide range of Roku streaming players and provide a complete solution for Roku devices. visit here
    Roku Help Phone Number
    Change Roku Stick Factory Setting Without Remote
    How to Fix Common Roku Error Codes
    Roku Customer Service Phone Number
    Contact Roku Customer Service Number