Bind 9.5.0 - Patch dlz MySQL 5 for Auto Reconnect

  • HOME
  • >
  • LINUX
  • >
  • Bind 9.5.0 - Patch dlz MySQL 5 for Auto Reconnect
Last Updated: 

👉 This post was initially written in 2007 and referred 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 occurred 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 through 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.

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.

This patch was applied to the Gentoo net-dns/bind package in 2008, see repo/gentoo/historical.git and Bug #180720

Related linux posts that you may like...
The Complete How To Guide of Bash Functions
Learn how to write shell scripts with bash functions. This guide includes examples and best practices on how to define, call, and debug functions in bash.
How To Create Simple Menu with the Shell Select Loop?
The select loop is not a regular shell loop. It can be used in Bash to generate a simple menu from which a user can select numbered options.
What is the Right Way to do Bash Loops?
Looping over a list of numbers or words is a building block in shell scripts. Learn how to write Bash loops, including for loop, while loop, and until loop.
What is the Best Way to Count Files in a Directory?
Learn how to count the number of files in a directory using the Linux command line ls, find, and a native bash shell solution with globs and arrays.