Hi,
If the mysql server stops responding (anything short of sending a tcp
reset), the gmysql backend hangs until the tcp connection times out
(many minutes by default).
Attached is a patch to set the mysql library read and write timeouts so
that if the mysql server stops responding, pdns learns about it quickly.
Coupled with the MYSQL_OPT_RECONNECT added in pdns 3, it just reconnects
automatically.
This patch sets the timeout at 10 seconds and the mysql library will
retry 3 times by default, so it should be 30 seconds max before a
reconnect.
pdns 3 does now read the mysql config file, but I can't find any way to
set these particular options using it - I'm pretty certain they need to
be set like this, in the code.
We've used pdns in conjunction with both mysql-proxy and haproxy for
high availability and it's basically useless without this patch, as they
both depend on the client timing out and reconnecting when a backend
server goes down.
John.
--
http://beta.brightbox.com
diff --git a/modules/gmysqlbackend/smysql.cc b/modules/gmysqlbackend/smysql.cc
index 1412dc0..439d290 100644
--- a/modules/gmysqlbackend/smysql.cc
+++ b/modules/gmysqlbackend/smysql.cc
@@ -18,6 +18,9 @@ SMySQL::SMySQL(const string &database, const string &host, uint16_t port, const
mysql_options(&d_db, MYSQL_READ_DEFAULT_GROUP, "client");
my_bool reconnect = 1;
mysql_options(&d_db, MYSQL_OPT_RECONNECT, &reconnect);
+ unsigned int timeout = 10;
+ mysql_options(&d_db, MYSQL_OPT_READ_TIMEOUT, &timeout);
+ mysql_options(&d_db, MYSQL_OPT_WRITE_TIMEOUT, &timeout);
if (!mysql_real_connect(&d_db, host.empty() ? 0 : host.c_str(),
user.empty() ? 0 : user.c_str(),
_______________________________________________
Pdns-dev mailing list
[email protected]
http://mailman.powerdns.com/mailman/listinfo/pdns-dev