From 92ebfb2eb92d479cc8edb463f34539ec4e9855bf Mon Sep 17 00:00:00 2001 From: MassimilianoPinto Date: Mon, 26 Jan 2015 11:50:24 +0100 Subject: [PATCH] Timeouts handling in NDB Monitor Timeouts handling in NDB Monitor --- server/modules/monitor/galera_mon.c | 2 +- server/modules/monitor/ndbcluster_mon.c | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/server/modules/monitor/galera_mon.c b/server/modules/monitor/galera_mon.c index 3eded9596..61d7cd15b 100644 --- a/server/modules/monitor/galera_mon.c +++ b/server/modules/monitor/galera_mon.c @@ -359,7 +359,7 @@ char *server_string; int rc; int connect_timeout = handle->connect_timeout; int read_timeout = handle->read_timeout; - int write_timeout = handle->write_timeout;; + int write_timeout = handle->write_timeout; database->con = mysql_init(NULL); diff --git a/server/modules/monitor/ndbcluster_mon.c b/server/modules/monitor/ndbcluster_mon.c index 3892d4abe..124eba027 100644 --- a/server/modules/monitor/ndbcluster_mon.c +++ b/server/modules/monitor/ndbcluster_mon.c @@ -148,6 +148,9 @@ MYSQL_MONITOR *handle; handle->defaultPasswd = NULL; handle->id = MONITOR_DEFAULT_ID; handle->interval = MONITOR_INTERVAL; + handle->connect_timeout=DEFAULT_CONNECT_TIMEOUT; + handle->read_timeout=DEFAULT_READ_TIMEOUT; + handle->write_timeout=DEFAULT_WRITE_TIMEOUT; spinlock_init(&handle->lock); } handle->tid = (THREAD)thread_start(monitorMain, handle); @@ -265,6 +268,9 @@ char *sep; } dcb_printf(dcb,"\tSampling interval:\t%lu milliseconds\n", handle->interval); + dcb_printf(dcb,"\tConnect Timeout:\t%i seconds\n", handle->connect_timeout); + dcb_printf(dcb,"\tRead Timeout:\t\t%i seconds\n", handle->read_timeout); + dcb_printf(dcb,"\tWrite Timeout:\t\t%i seconds\n", handle->write_timeout); dcb_printf(dcb, "\tMonitored servers: "); db = handle->databases; @@ -331,10 +337,15 @@ char *server_string; { char *dpwd = decryptPassword(passwd); int rc; - int read_timeout = 1; + int connect_timeout = handle->connect_timeout; + int read_timeout = handle->read_timeout; + int write_timeout = handle->write_timeout; - database->con = mysql_init(NULL); - rc = mysql_options(database->con, MYSQL_OPT_READ_TIMEOUT, (void *)&read_timeout); + database->con = mysql_init(NULL); + + rc = mysql_options(database->con, MYSQL_OPT_CONNECT_TIMEOUT, (void *)&connect_timeout); + rc = mysql_options(database->con, MYSQL_OPT_READ_TIMEOUT, (void *)&read_timeout); + rc = mysql_options(database->con, MYSQL_OPT_WRITE_TIMEOUT, (void *)&write_timeout); if (mysql_real_connect(database->con, database->server->name, uname, dpwd, NULL, database->server->port, NULL, 0) == NULL)