Bind 9.5.0 - Patch dlz MySQL 5 for auto reconnect

News, Tips Add comments

Here is a quick post of a “quick and dirty” patch for the ISC DNS Server : Bind 9.5.0a6 and its dlz mysql driver. For the quick story, I was using Bind 9.4.1 with dlz MySQL. My MySQL server is a 5.0.41 (with solidDB). While using it, I realize that some times the dns server was returning empty value for the dns queries. I tried many tips but it was still (sometime) giving me empty answer… Of course, I suspected the dlz driver. So, I tried to upgrade to Bind 9.5.0a6 but the problem still happened and the only way to fix was to restart bind !

So I take a look at the dlz driver and make this simple patch for adding the following features:

  • Set option MYSQL_OPT_RECONNECT to 1
  • Add some log error information while doing a ping

In fact, after using the few logs added thru mysql ping, I discover that when the driver lost its connection to the mysql server (due to a small wait_timeout, mysql restart, etc.) it tried to ping but didn’t succeed to reconnect to the server. Hopefully, I just needed to bypass the default option of MYSQL_OPT_RECONNECT while creating the connection.

MYSQL_OPT_RECONNECT

Enable or disable automatic reconnection to the server if the connection is found to have been lost. Reconnect has been off by default since MySQL 5.0.3; this option is new in 5.0.13 and provides a way to set reconnection behavior explicitly.

Now, I didn’t have to run a bloody crontab for checking that my dns server is still answering to its dns queries.

Enjoy. ;-)

Share this post with your network :These icons link to social bookmarking sites where readers can share and discover new web pages.
  • blinkbits
  • BlinkList
  • blogmarks
  • co.mments
  • connotea
  • del.icio.us
  • De.lirio.us
  • digg
  • Fark
  • feedmelinks
  • Furl
  • LinkaGoGo
  • Ma.gnolia
  • NewsVine
  • Netvouz
  • RawSugar
  • Reddit
  • scuttle
  • Shadows
  • Simpy
  • Smarking
  • Spurl
  • TailRank
  • Wists
  • YahooMyWeb

3 Responses to “Bind 9.5.0 - Patch dlz MySQL 5 for auto reconnect”

  1. hdcyly Says:

    Hi, I am using BIND 9.4.1 now. Does the patch also work on this version ?

    Thanks !

  2. Nicolas Brousse Says:

    That should work. You probably have to check that it’s ok with the sources of bind 9.4.1. The main thing to do is to fix the source file “contrib/dlz/drivers/dlz_mysql_driver.c” for setting the mysql option to reconnect (and also some mysql_ping() to do) :

    + if(mysql_options((MYSQL *) dbi->dbconn, MYSQL_OPT_RECONNECT, “1″)) {
    + isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
    + DNS_LOGMODULE_DLZ, ISC_LOG_ERROR,
    + “Could not set database reconnect option”);
    + }

    try to patch directly the sources of mysql 9.4.1, if you don’t succeed I’ll take time to look at it.

  3. Tobias Scherbaum Says:

    Thanks for this patch, Nicolas :) I included the patch as a fix for https://bugs.gentoo.org/show_bug.cgi?id=180720 to Gentoo :) And yeah, it also works with 9.4.2.

Leave a Reply

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Login