@ -229,7 +229,6 @@ typedef struct router_instance {
|
|||||||
} ROUTER_INSTANCE;
|
} ROUTER_INSTANCE;
|
||||||
|
|
||||||
#define BACKEND_TYPE(b) (SERVER_IS_MASTER((b)->backend_server) ? BE_MASTER : \
|
#define BACKEND_TYPE(b) (SERVER_IS_MASTER((b)->backend_server) ? BE_MASTER : \
|
||||||
(SERVER_IS_SLAVE((b)->backend_server) ? BE_SLAVE : \
|
(SERVER_IS_SLAVE((b)->backend_server) ? BE_SLAVE : BE_UNDEFINED));
|
||||||
(SERVER_IS_JOINED((b)->backend_server) ? BE_JOINED : BE_UNDEFINED)));
|
|
||||||
|
|
||||||
#endif /*< _RWSPLITROUTER_H */
|
#endif /*< _RWSPLITROUTER_H */
|
||||||
|
@ -317,10 +317,22 @@ char *server_string;
|
|||||||
if (database->con == NULL || mysql_ping(database->con) != 0)
|
if (database->con == NULL || mysql_ping(database->con) != 0)
|
||||||
{
|
{
|
||||||
char *dpwd = decryptPassword(passwd);
|
char *dpwd = decryptPassword(passwd);
|
||||||
|
int rc;
|
||||||
|
int read_timeout = 1;
|
||||||
|
|
||||||
database->con = mysql_init(NULL);
|
database->con = mysql_init(NULL);
|
||||||
|
rc = mysql_options(database->con, MYSQL_OPT_READ_TIMEOUT, (void *)&read_timeout);
|
||||||
|
|
||||||
if (mysql_real_connect(database->con, database->server->name,
|
if (mysql_real_connect(database->con, database->server->name,
|
||||||
uname, dpwd, NULL, database->server->port, NULL, 0) == NULL)
|
uname, dpwd, NULL, database->server->port, NULL, 0) == NULL)
|
||||||
{
|
{
|
||||||
|
LOGIF(LE, (skygw_log_write_flush(
|
||||||
|
LOGFILE_ERROR,
|
||||||
|
"Error : Monitor was unable to connect to "
|
||||||
|
"server %s:%d : \"%s\"",
|
||||||
|
database->server->name,
|
||||||
|
database->server->port,
|
||||||
|
mysql_error(database->con))));
|
||||||
server_clear_status(database->server, SERVER_RUNNING);
|
server_clear_status(database->server, SERVER_RUNNING);
|
||||||
database->server->node_id = -1;
|
database->server->node_id = -1;
|
||||||
free(dpwd);
|
free(dpwd);
|
||||||
@ -416,6 +428,7 @@ long master_id;
|
|||||||
|
|
||||||
while (ptr)
|
while (ptr)
|
||||||
{
|
{
|
||||||
|
unsigned int prev_status = ptr->server->status;
|
||||||
monitorDatabase(ptr, handle->defaultUser, handle->defaultPasswd);
|
monitorDatabase(ptr, handle->defaultUser, handle->defaultPasswd);
|
||||||
|
|
||||||
/* set master_id to the lowest value of ptr->server->node_id */
|
/* set master_id to the lowest value of ptr->server->node_id */
|
||||||
@ -433,6 +446,16 @@ long master_id;
|
|||||||
server_clear_status(ptr->server, SERVER_SLAVE);
|
server_clear_status(ptr->server, SERVER_SLAVE);
|
||||||
server_clear_status(ptr->server, SERVER_MASTER);
|
server_clear_status(ptr->server, SERVER_MASTER);
|
||||||
}
|
}
|
||||||
|
if (ptr->server->status != prev_status ||
|
||||||
|
SERVER_IS_DOWN(ptr->server))
|
||||||
|
{
|
||||||
|
LOGIF(LM, (skygw_log_write_flush(
|
||||||
|
LOGFILE_MESSAGE,
|
||||||
|
"Backend server %s:%d state : %s",
|
||||||
|
ptr->server->name,
|
||||||
|
ptr->server->port,
|
||||||
|
STRSRVSTATUS(ptr->server))));
|
||||||
|
}
|
||||||
ptr = ptr->next;
|
ptr = ptr->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -332,7 +332,11 @@ int replication_heartbeat = handle->replicationHeartbeat;
|
|||||||
if (database->con == NULL || mysql_ping(database->con) != 0)
|
if (database->con == NULL || mysql_ping(database->con) != 0)
|
||||||
{
|
{
|
||||||
char *dpwd = decryptPassword(passwd);
|
char *dpwd = decryptPassword(passwd);
|
||||||
|
int rc;
|
||||||
|
int read_timeout = 1;
|
||||||
database->con = mysql_init(NULL);
|
database->con = mysql_init(NULL);
|
||||||
|
rc = mysql_options(database->con, MYSQL_OPT_READ_TIMEOUT, (void *)&read_timeout);
|
||||||
|
|
||||||
if (mysql_real_connect(database->con,
|
if (mysql_real_connect(database->con,
|
||||||
database->server->name,
|
database->server->name,
|
||||||
uname,
|
uname,
|
||||||
@ -342,6 +346,14 @@ int replication_heartbeat = handle->replicationHeartbeat;
|
|||||||
NULL,
|
NULL,
|
||||||
0) == NULL)
|
0) == NULL)
|
||||||
{
|
{
|
||||||
|
LOGIF(LE, (skygw_log_write_flush(
|
||||||
|
LOGFILE_ERROR,
|
||||||
|
"Error : Monitor was unable to connect to "
|
||||||
|
"server %s:%d : \"%s\"",
|
||||||
|
database->server->name,
|
||||||
|
database->server->port,
|
||||||
|
mysql_error(database->con))));
|
||||||
|
|
||||||
free(dpwd);
|
free(dpwd);
|
||||||
server_clear_status(database->server, SERVER_RUNNING);
|
server_clear_status(database->server, SERVER_RUNNING);
|
||||||
return;
|
return;
|
||||||
@ -626,7 +638,6 @@ int replication_heartbeat = handle->replicationHeartbeat;
|
|||||||
server_clear_status(database->server, SERVER_SLAVE);
|
server_clear_status(database->server, SERVER_SLAVE);
|
||||||
server_clear_status(database->server, SERVER_MASTER);
|
server_clear_status(database->server, SERVER_MASTER);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -661,7 +672,21 @@ MONITOR_SERVERS *ptr;
|
|||||||
ptr = handle->databases;
|
ptr = handle->databases;
|
||||||
while (ptr)
|
while (ptr)
|
||||||
{
|
{
|
||||||
|
unsigned int prev_status = ptr->server->status;
|
||||||
|
|
||||||
monitorDatabase(handle, ptr);
|
monitorDatabase(handle, ptr);
|
||||||
|
|
||||||
|
if (ptr->server->status != prev_status ||
|
||||||
|
SERVER_IS_DOWN(ptr->server))
|
||||||
|
{
|
||||||
|
LOGIF(LM, (skygw_log_write_flush(
|
||||||
|
LOGFILE_MESSAGE,
|
||||||
|
"Backend server %s:%d state : %s",
|
||||||
|
ptr->server->name,
|
||||||
|
ptr->server->port,
|
||||||
|
STRSRVSTATUS(ptr->server))));
|
||||||
|
}
|
||||||
|
|
||||||
ptr = ptr->next;
|
ptr = ptr->next;
|
||||||
}
|
}
|
||||||
thread_millisleep(handle->interval);
|
thread_millisleep(handle->interval);
|
||||||
@ -676,10 +701,10 @@ MONITOR_SERVERS *ptr;
|
|||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
defaultId(void *arg, unsigned long id)
|
defaultId(void *arg, unsigned long id)
|
||||||
{
|
{
|
||||||
MYSQL_MONITOR *handle = (MYSQL_MONITOR *)arg;
|
MYSQL_MONITOR *handle = (MYSQL_MONITOR *)arg;
|
||||||
memcpy(&handle->id, &id, sizeof(unsigned long));
|
memcpy(&handle->id, &id, sizeof(unsigned long));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the monitor sampling interval.
|
* Set the monitor sampling interval.
|
||||||
@ -692,7 +717,7 @@ setInterval(void *arg, unsigned long interval)
|
|||||||
{
|
{
|
||||||
MYSQL_MONITOR *handle = (MYSQL_MONITOR *)arg;
|
MYSQL_MONITOR *handle = (MYSQL_MONITOR *)arg;
|
||||||
memcpy(&handle->interval, &interval, sizeof(unsigned long));
|
memcpy(&handle->interval, &interval, sizeof(unsigned long));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enable/Disable the MySQL Replication hearbeat, detecting slave lag behind master.
|
* Enable/Disable the MySQL Replication hearbeat, detecting slave lag behind master.
|
||||||
|
@ -808,7 +808,7 @@ static bool get_dcb(
|
|||||||
}
|
}
|
||||||
ss_dassert(succp);
|
ss_dassert(succp);
|
||||||
}
|
}
|
||||||
else if (btype == BE_MASTER || BE_JOINED)
|
else if (btype == BE_MASTER)
|
||||||
{
|
{
|
||||||
for (i=0; i<rses->rses_nbackends; i++)
|
for (i=0; i<rses->rses_nbackends; i++)
|
||||||
{
|
{
|
||||||
|
@ -229,6 +229,12 @@ typedef enum skygw_chk_t {
|
|||||||
((c) == LEAST_ROUTER_CONNECTIONS ? "LEAST_ROUTER_CONNECTIONS" : \
|
((c) == LEAST_ROUTER_CONNECTIONS ? "LEAST_ROUTER_CONNECTIONS" : \
|
||||||
((c) == LEAST_BEHIND_MASTER ? "LEAST_BEHIND_MASTER" : "Unknown criteria"))))
|
((c) == LEAST_BEHIND_MASTER ? "LEAST_BEHIND_MASTER" : "Unknown criteria"))))
|
||||||
|
|
||||||
|
#define STRSRVSTATUS(s) ((SERVER_IS_RUNNING(s) && SERVER_IS_MASTER(s)) ? "RUNNING MASTER" : \
|
||||||
|
((SERVER_IS_RUNNING(s) && SERVER_IS_SLAVE(s)) ? "RUNNING SLAVE" : \
|
||||||
|
((SERVER_IS_RUNNING(s) && SERVER_IS_JOINED(s)) ? "RUNNING JOINED" : \
|
||||||
|
((SERVER_IS_RUNNING(s) && SERVER_IS_MAINT(s)) ? "RUNNING MAINTENANCE" : \
|
||||||
|
(SERVER_IS_RUNNING(s) ? "RUNNING (only)" : "NO STATUS")))))
|
||||||
|
|
||||||
#define CHK_MLIST(l) { \
|
#define CHK_MLIST(l) { \
|
||||||
ss_info_dassert((l->mlist_chk_top == CHK_NUM_MLIST && \
|
ss_info_dassert((l->mlist_chk_top == CHK_NUM_MLIST && \
|
||||||
l->mlist_chk_tail == CHK_NUM_MLIST), \
|
l->mlist_chk_tail == CHK_NUM_MLIST), \
|
||||||
|
Reference in New Issue
Block a user