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. ;-)


























January 19th, 2008 at 3:14 pm
Hi, I am using BIND 9.4.1 now. Does the patch also work on this version ?
Thanks !
January 22nd, 2008 at 7:02 pm
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.
May 3rd, 2008 at 9:17 pm
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.