Modifications to galera monitor to control whether selection of master is wanted.
This commit is contained in:
parent
8bc004db26
commit
03badb9b7b
1
.gitignore
vendored
1
.gitignore
vendored
@ -34,3 +34,4 @@ depend.mk
|
||||
|
||||
# Vi swap files
|
||||
.*.swp
|
||||
/build/
|
@ -440,6 +440,7 @@ backend_write_timeout=2
|
||||
# galeramon specific options
|
||||
disable_master_failback=0
|
||||
available_when_donor=0
|
||||
disable_master_role_setting=0
|
||||
```
|
||||
|
||||
#### `module`
|
||||
@ -510,6 +511,13 @@ This option if set to 1 will allow Galera monitor to keep a node in `Donor` stat
|
||||
|
||||
As xtrabackup is a non-locking SST method, a node in `Donor` status can still be considered in sync. This option is not enabled by default and should be used as the administrator's discretion.
|
||||
|
||||
#### `disable_master_role_setting`
|
||||
|
||||
This option if set to 1 will stop the Galera monitor from setting the status of
|
||||
backend servers to master or slave. It is applicable when the Galera router is
|
||||
being used to spread writes across multiple nodes, so that no server is to be
|
||||
nominated as the master.
|
||||
|
||||
#### `backend_connect_timeout`
|
||||
|
||||
This option, with default value of `3` sets the monitor connect timeout to backends.
|
||||
@ -1367,11 +1375,11 @@ Example:
|
||||
```
|
||||
[Galera Listener]
|
||||
type=listener
|
||||
address=192.1681.3.33
|
||||
address=192.168.3.33
|
||||
port=4408
|
||||
socket=/servers/maxscale/galera.sock
|
||||
```
|
||||
|
||||
TCP/IP Traffic must be permitted to 192.1681.3.33 port 4408
|
||||
TCP/IP Traffic must be permitted to 192.168.3.33 port 4408
|
||||
|
||||
For Unix socket, the socket file path (example: `/servers/maxscale/galera.sock`) must be writable by the Unix user MaxScale runs as.
|
||||
|
@ -43,6 +43,7 @@
|
||||
* 20/02/15 Markus Mäkelä Added connection_timeout parameter for services
|
||||
* 05/03/15 Massimiliano Pinto Added notification_feedback support
|
||||
* 20/04/15 Guillaume Lefranc Added available_when_donor parameter
|
||||
* 22/04/15 Martin Brampton Added disable_master_role_setting parameter
|
||||
*
|
||||
* @endverbatim
|
||||
*/
|
||||
@ -1895,6 +1896,7 @@ static char *monitor_params[] =
|
||||
"backend_read_timeout",
|
||||
"backend_write_timeout",
|
||||
"available_when_donor",
|
||||
"disable_master_role_setting",
|
||||
NULL
|
||||
};
|
||||
/**
|
||||
|
@ -160,6 +160,7 @@ CONFIG_PARAMETER* params = (CONFIG_PARAMETER*)opt;
|
||||
handle->interval = MONITOR_INTERVAL;
|
||||
handle->disableMasterFailback = 0;
|
||||
handle->availableWhenDonor = 0;
|
||||
handle->disableMasterRoleSetting = 0;
|
||||
handle->master = NULL;
|
||||
handle->connect_timeout=DEFAULT_CONNECT_TIMEOUT;
|
||||
handle->read_timeout=DEFAULT_READ_TIMEOUT;
|
||||
@ -172,8 +173,10 @@ CONFIG_PARAMETER* params = (CONFIG_PARAMETER*)opt;
|
||||
{
|
||||
if(!strcmp(params->name,"disable_master_failback"))
|
||||
handle->disableMasterFailback = config_truth_value(params->value);
|
||||
if(!strcmp(params->name,"available_when_donor"))
|
||||
else if(!strcmp(params->name,"available_when_donor"))
|
||||
handle->availableWhenDonor = config_truth_value(params->value);
|
||||
else if(!strcmp(params->name,"disable_master_role_setting"))
|
||||
handle->disableMasterRoleSetting = config_truth_value(params->value);
|
||||
params = params->next;
|
||||
}
|
||||
|
||||
@ -294,6 +297,7 @@ char *sep;
|
||||
dcb_printf(dcb,"\tSampling interval:\t%lu milliseconds\n", handle->interval);
|
||||
dcb_printf(dcb,"\tMaster Failback:\t%s\n", (handle->disableMasterFailback == 1) ? "off" : "on");
|
||||
dcb_printf(dcb,"\tAvailable when Donor:\t%s\n", (handle->availableWhenDonor == 1) ? "on" : "off");
|
||||
dcb_printf(dcb,"\tMaster Role Setting Disabled:\t%s\n", (handle->disableMasterRoleSetting == 1) ? "on" : "off");
|
||||
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);
|
||||
@ -596,40 +600,47 @@ int log_no_members = 1;
|
||||
* Decision depends on master_stickiness value set in configuration
|
||||
*/
|
||||
|
||||
/* get the candidate master, followinf MIN(node_id) rule */
|
||||
/* get the candidate master, following MIN(node_id) rule */
|
||||
candidate_master = get_candidate_master(handle->databases);
|
||||
|
||||
/* Select the master, based on master_stickiness */
|
||||
handle->master = set_cluster_master(handle->master, candidate_master, master_stickiness);
|
||||
if (1 == handle->disableMasterRoleSetting) {
|
||||
handle->master = NULL;
|
||||
}
|
||||
else {
|
||||
handle->master = set_cluster_master(handle->master, candidate_master, master_stickiness);
|
||||
}
|
||||
|
||||
ptr = handle->databases;
|
||||
|
||||
while (ptr && handle->master) {
|
||||
while (ptr) {
|
||||
if (!SERVER_IS_JOINED(ptr->server) || SERVER_IN_MAINT(ptr->server)) {
|
||||
ptr = ptr->next;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ptr != handle->master) {
|
||||
if (handle->master) {
|
||||
if (ptr != handle->master) {
|
||||
/* set the Slave role */
|
||||
server_set_status(ptr->server, SERVER_SLAVE);
|
||||
server_clear_status(ptr->server, SERVER_MASTER);
|
||||
|
||||
/* clear master stickyness */
|
||||
/* clear master stickiness */
|
||||
server_clear_status(ptr->server, SERVER_MASTER_STICKINESS);
|
||||
} else {
|
||||
} else {
|
||||
/* set the Master role */
|
||||
server_set_status(handle->master->server, SERVER_MASTER);
|
||||
server_clear_status(handle->master->server, SERVER_SLAVE);
|
||||
|
||||
if (candidate_master && handle->master->server->node_id != candidate_master->server->node_id) {
|
||||
/* set master stickyness */
|
||||
/* set master stickiness */
|
||||
server_set_status(handle->master->server, SERVER_MASTER_STICKINESS);
|
||||
} else {
|
||||
/* clear master stickyness */
|
||||
/* clear master stickiness */
|
||||
server_clear_status(ptr->server, SERVER_MASTER_STICKINESS);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
is_cluster++;
|
||||
|
||||
|
@ -35,7 +35,8 @@
|
||||
* 28/08/14 Massimiliano Pinto Addition of detectStaleMaster
|
||||
* 30/10/14 Massimiliano Pinto Addition of disableMasterFailback
|
||||
* 07/11/14 Massimiliano Pinto Addition of NetworkTimeout: connect, read, write
|
||||
* 20/05/15 Guillaume Lefranc Addition of availableWhenDonor
|
||||
* 20/04/15 Guillaume Lefranc Addition of availableWhenDonor
|
||||
* 22/04/15 Martin Brampton Addition of disableMasterRoleSetting
|
||||
*
|
||||
* @endverbatim
|
||||
*/
|
||||
@ -70,6 +71,7 @@ typedef struct {
|
||||
int detectStaleMaster; /**< Monitor flag for MySQL replication Stale Master detection */
|
||||
int disableMasterFailback; /**< Monitor flag for Galera Cluster Master failback */
|
||||
int availableWhenDonor; /**< Monitor flag for Galera Cluster Donor availability */
|
||||
int disableMasterRoleSetting; /**< Monitor flag to disable setting master role */
|
||||
MONITOR_SERVERS *master; /**< Master server for MySQL Master/Slave replication */
|
||||
MONITOR_SERVERS *databases; /**< Linked list of servers to monitor */
|
||||
int connect_timeout; /**< Connect timeout in seconds for mysql_real_connect */
|
||||
|
@ -243,24 +243,23 @@ static int hashcmpfun(
|
||||
/**
|
||||
* Convert a length encoded string into a C string.
|
||||
* @param data Pointer to the first byte of the string
|
||||
* @param len Pointer to an integer where the length of the string will be stored. On errors this will be set to -1.
|
||||
* @return Pointer to the newly allocated string or NULL if the value is NULL or an error occurred
|
||||
*/
|
||||
char* get_lenenc_str(void* data, int* len)
|
||||
char* get_lenenc_str(void* data)
|
||||
{
|
||||
unsigned char* ptr = (unsigned char*)data;
|
||||
char* rval;
|
||||
long size, offset;
|
||||
uintptr_t size;
|
||||
long offset;
|
||||
|
||||
if(data == NULL || len == NULL)
|
||||
if(data == NULL)
|
||||
{
|
||||
*len = -1;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(*ptr < 251)
|
||||
{
|
||||
size = *ptr;
|
||||
size = (uintptr_t)*ptr;
|
||||
offset = 1;
|
||||
}
|
||||
else
|
||||
@ -268,7 +267,6 @@ char* get_lenenc_str(void* data, int* len)
|
||||
switch(*(ptr))
|
||||
{
|
||||
case 0xfb:
|
||||
*len = 1;
|
||||
return NULL;
|
||||
case 0xfc:
|
||||
size = *(ptr + 1) + (*(ptr + 2) << 8);
|
||||
@ -280,8 +278,8 @@ char* get_lenenc_str(void* data, int* len)
|
||||
break;
|
||||
case 0xfe:
|
||||
size = *ptr + ((*(ptr + 2) << 8)) + (*(ptr + 3) << 16) +
|
||||
(*(ptr + 4) << 24) + (*(ptr + 5) << 32) + (*(ptr + 6) << 40) +
|
||||
(*(ptr + 7) << 48) + (*(ptr + 8) << 56);
|
||||
(*(ptr + 4) << 24) + ((uintptr_t)*(ptr + 5) << 32) + ((uintptr_t)*(ptr + 6) << 40) +
|
||||
((uintptr_t)*(ptr + 7) << 48) + ((uintptr_t)*(ptr + 8) << 56);
|
||||
offset = 8;
|
||||
break;
|
||||
default:
|
||||
@ -297,7 +295,6 @@ char* get_lenenc_str(void* data, int* len)
|
||||
memset(rval + size,0,1);
|
||||
|
||||
}
|
||||
*len = size + offset;
|
||||
return rval;
|
||||
}
|
||||
|
||||
@ -360,8 +357,7 @@ bool parse_showdb_response(ROUTER_CLIENT_SES* rses, backend_ref_t* bref, GWBUF**
|
||||
{
|
||||
int payloadlen = gw_mysql_get_byte3(ptr);
|
||||
int packetlen = payloadlen + 4;
|
||||
int len = 0;
|
||||
char* data = get_lenenc_str(ptr+4,&len);
|
||||
char* data = get_lenenc_str(ptr+4);
|
||||
|
||||
if(data)
|
||||
{
|
||||
|
@ -262,25 +262,23 @@ hashcmpfun(
|
||||
/**
|
||||
* Convert a length encoded string into a C string.
|
||||
* @param data Pointer to the first byte of the string
|
||||
* @param len Pointer to an integer where the length of the string will be stored. On errors this will be set to -1.
|
||||
* @return Pointer to the newly allocated string or NULL if the value is NULL or an error occurred
|
||||
*/
|
||||
char* get_lenenc_str(void* data, int* len)
|
||||
char* get_lenenc_str(void* data)
|
||||
{
|
||||
unsigned char* ptr = (unsigned char*)data;
|
||||
char* rval;
|
||||
long size, offset;
|
||||
uintptr_t size;
|
||||
long offset;
|
||||
|
||||
if(data == NULL || len == NULL)
|
||||
if(data == NULL)
|
||||
{
|
||||
if(len)
|
||||
*len = -1;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(*ptr < 251)
|
||||
{
|
||||
size = *ptr;
|
||||
size = (uintptr_t)*ptr;
|
||||
offset = 1;
|
||||
}
|
||||
else
|
||||
@ -288,7 +286,6 @@ char* get_lenenc_str(void* data, int* len)
|
||||
switch(*(ptr))
|
||||
{
|
||||
case 0xfb:
|
||||
*len = 1;
|
||||
return NULL;
|
||||
case 0xfc:
|
||||
size = *(ptr + 1) + (*(ptr + 2) << 8);
|
||||
@ -300,8 +297,8 @@ char* get_lenenc_str(void* data, int* len)
|
||||
break;
|
||||
case 0xfe:
|
||||
size = *ptr + ((*(ptr + 2) << 8)) + (*(ptr + 3) << 16) +
|
||||
(*(ptr + 4) << 24) + ((long)*(ptr + 5) << 32) + ((long)*(ptr + 6) << 40) +
|
||||
((long)*(ptr + 7) << 48) + ((long)*(ptr + 8) << 56);
|
||||
(*(ptr + 4) << 24) + ((uintptr_t)*(ptr + 5) << 32) + ((uintptr_t)*(ptr + 6) << 40) +
|
||||
((uintptr_t)*(ptr + 7) << 48) + ((uintptr_t)*(ptr + 8) << 56);
|
||||
offset = 8;
|
||||
break;
|
||||
default:
|
||||
@ -317,7 +314,6 @@ char* get_lenenc_str(void* data, int* len)
|
||||
memset(rval + size,0,1);
|
||||
|
||||
}
|
||||
*len = size + offset;
|
||||
return rval;
|
||||
}
|
||||
|
||||
@ -360,8 +356,7 @@ parse_mapping_response(ROUTER_CLIENT_SES* rses, char* target, GWBUF* buf)
|
||||
{
|
||||
int payloadlen = gw_mysql_get_byte3(ptr);
|
||||
int packetlen = payloadlen + 4;
|
||||
int len = 0;
|
||||
char* data = get_lenenc_str(ptr+4,&len);
|
||||
char* data = get_lenenc_str(ptr+4);
|
||||
|
||||
if(data)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user