Bind 9.5.0 - Patch dlz MySQL 5 for Auto Reconnect
👉 This post was initially written in 2007 and refered to specific software versions. When troubleshooting your system, always consider which version and environment you are using.
This post cover a patch for the ISC DNS Server Bind version 9.5.0a6 and its dlz MySQL driver. For the quick story, I was using Bind 9.4.1 with the dlz MySQL driver. This allowed me to manage DNS records directly in MySQL. The MySQL server was a 5.0.41 with solidDB. While using it, I found out that some times the dns server was returning empty values for the dns queries. As I suspected the dlz driver but couldn't get to the bottom of the issue, I decided to upgrade to Bind 9.5.0a6 in a hope to get latest fixes but the problem still occured and the only way to fix was to restart bind on a regular basis. Not good!
To solve the issue, I had to go a bit deeper and take a look at the dlz driver source code which lead me to produce this simple patch to add the following features:
- Set option MYSQL_OPT_RECONNECT to 1
- Add Error Logs messages while doing a MySQL ping
After using the few logs added thru a mysql ping, I discovered 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. This is what lead me to adding the MYSQL_OPT_RECONNECT option while creating the connection in the driver.
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.