A script can now be called in mysql_mon when a master server loses master status.
This commit is contained in:
@ -22,7 +22,7 @@
|
|||||||
* @verbatim
|
* @verbatim
|
||||||
* Revision History
|
* Revision History
|
||||||
*
|
*
|
||||||
* Date Who Description
|
* Date Who Demaster_down_scription
|
||||||
* 08/07/13 Mark Riddoch Initial implementation
|
* 08/07/13 Mark Riddoch Initial implementation
|
||||||
* 11/07/13 Mark Riddoch Addition of code to check replication
|
* 11/07/13 Mark Riddoch Addition of code to check replication
|
||||||
* status
|
* status
|
||||||
@ -185,7 +185,7 @@ CONFIG_PARAMETER* params = (CONFIG_PARAMETER*)opt;
|
|||||||
handle->connect_timeout=DEFAULT_CONNECT_TIMEOUT;
|
handle->connect_timeout=DEFAULT_CONNECT_TIMEOUT;
|
||||||
handle->read_timeout=DEFAULT_READ_TIMEOUT;
|
handle->read_timeout=DEFAULT_READ_TIMEOUT;
|
||||||
handle->write_timeout=DEFAULT_WRITE_TIMEOUT;
|
handle->write_timeout=DEFAULT_WRITE_TIMEOUT;
|
||||||
handle->script = NULL;
|
handle->master_down_script = NULL;
|
||||||
spinlock_init(&handle->lock);
|
spinlock_init(&handle->lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -195,8 +195,18 @@ CONFIG_PARAMETER* params = (CONFIG_PARAMETER*)opt;
|
|||||||
handle->detectStaleMaster = config_truth_value(params->value);
|
handle->detectStaleMaster = config_truth_value(params->value);
|
||||||
else if(!strcmp(params->name,"detect_replication_lag"))
|
else if(!strcmp(params->name,"detect_replication_lag"))
|
||||||
handle->replicationHeartbeat = config_truth_value(params->value);
|
handle->replicationHeartbeat = config_truth_value(params->value);
|
||||||
else if(!strcmp(params->name,"script"))
|
else if(!strcmp(params->name,"master_down_script"))
|
||||||
handle->script = strdup(params->value);
|
{
|
||||||
|
if(access(params->value,F_OK) == 0)
|
||||||
|
{
|
||||||
|
handle->master_down_script = strdup(params->value);
|
||||||
|
handle->master_down_script_called = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
skygw_log_write(LOGFILE_ERROR,"Error: could not find master_down_script file: %s",params->value);
|
||||||
|
}
|
||||||
|
}
|
||||||
params = params->next;
|
params = params->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -688,6 +698,11 @@ int log_no_master = 1;
|
|||||||
"Server %s:%d lost the master status.",
|
"Server %s:%d lost the master status.",
|
||||||
ptr->server->name,
|
ptr->server->name,
|
||||||
ptr->server->port)));
|
ptr->server->port)));
|
||||||
|
if(handle->master_down_script)
|
||||||
|
{
|
||||||
|
if(monitor_exec_cmd(handle->master_down_script))
|
||||||
|
skygw_log_write(LOGFILE_ERROR,"Error: Failed to execute command '%s' on server state change.",handle->master_down_script);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Here we say: If the server's state changed
|
* Here we say: If the server's state changed
|
||||||
@ -700,15 +715,12 @@ int log_no_master = 1;
|
|||||||
!(SERVER_IS_IN_CLUSTER(ptr->server)))
|
!(SERVER_IS_IN_CLUSTER(ptr->server)))
|
||||||
{
|
{
|
||||||
dcb_call_foreach(ptr->server,DCB_REASON_NOT_RESPONDING);
|
dcb_call_foreach(ptr->server,DCB_REASON_NOT_RESPONDING);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
if(handle->script)
|
|
||||||
{
|
|
||||||
if(monitor_exec_cmd(handle->script))
|
|
||||||
skygw_log_write(LOGFILE_ERROR,"Error: Failed to execute command '%s' on server state change.",handle->script);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mon_status_changed(ptr))
|
if (mon_status_changed(ptr))
|
||||||
|
@ -77,7 +77,8 @@ typedef struct {
|
|||||||
int write_timeout; /**< Timeout in seconds for each attempt to write to the server.
|
int write_timeout; /**< Timeout in seconds for each attempt to write to the server.
|
||||||
* There are retries and the total effective timeout value is two times the option value.
|
* There are retries and the total effective timeout value is two times the option value.
|
||||||
*/
|
*/
|
||||||
char *script;0
|
char *master_down_script;
|
||||||
|
int master_down_script_called;
|
||||||
} MYSQL_MONITOR;
|
} MYSQL_MONITOR;
|
||||||
|
|
||||||
#define MONITOR_RUNNING 1
|
#define MONITOR_RUNNING 1
|
||||||
|
Reference in New Issue
Block a user