Add support for Galera xtrabackup donor availability
This commit is contained in:
parent
bf83ce9db3
commit
060ebc3880
@ -435,6 +435,7 @@ backend_write_timeout=2
|
||||
|
||||
# galeramon specific options
|
||||
disable_master_failback=0
|
||||
available_when_donor=0
|
||||
```
|
||||
|
||||
#### `module`
|
||||
@ -499,6 +500,12 @@ The server status field may have the `SERVER_MASTER_STICKINESS` bit, meaning the
|
||||
|
||||
Anyway, a new master will be selected in case of current master failure, regardless the option value.
|
||||
|
||||
#### `available_when_donor`
|
||||
|
||||
This option if set to 1 will allow Galera monitor to keep a node in `Donor` status in the server pool if it is using any xtrabackup method for SST, e.g. `wsrep_sst_method` equal to `xtrabackup` or `xtrabackup-v2`.
|
||||
|
||||
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.
|
||||
|
||||
#### `backend_connect_timeout`
|
||||
|
||||
This option, with default value of `3` sets the monitor connect timeout to backends.
|
||||
|
@ -42,6 +42,7 @@
|
||||
* 07/11/14 Massimiliano Pinto Addition of monitor timeouts for connect/read/write
|
||||
* 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
|
||||
*
|
||||
* @endverbatim
|
||||
*/
|
||||
@ -1893,6 +1894,7 @@ static char *monitor_params[] =
|
||||
"backend_connect_timeout",
|
||||
"backend_read_timeout",
|
||||
"backend_write_timeout",
|
||||
"available_when_donor",
|
||||
NULL
|
||||
};
|
||||
/**
|
||||
@ -2278,4 +2280,4 @@ void config_add_param(CONFIG_CONTEXT* obj, char* key,char* value)
|
||||
nptr->value = strdup(value);
|
||||
nptr->next = obj->parameters;
|
||||
obj->parameters = nptr;
|
||||
}
|
||||
}
|
||||
|
@ -32,6 +32,7 @@
|
||||
* 24/06/14 Massimiliano Pinto Added depth level 0 for each node
|
||||
* 30/10/14 Massimiliano Pinto Added disableMasterFailback feature
|
||||
* 10/11/14 Massimiliano Pinto Added setNetworkTimeout for connect,read,write
|
||||
* 20/05/15 Guillaume Lefranc Added availableWhenDonor feature
|
||||
*
|
||||
* @endverbatim
|
||||
*/
|
||||
@ -158,6 +159,7 @@ CONFIG_PARAMETER* params = (CONFIG_PARAMETER*)opt;
|
||||
handle->id = MONITOR_DEFAULT_ID;
|
||||
handle->interval = MONITOR_INTERVAL;
|
||||
handle->disableMasterFailback = 0;
|
||||
handle->availableWhenDonor = 0;
|
||||
handle->master = NULL;
|
||||
handle->connect_timeout=DEFAULT_CONNECT_TIMEOUT;
|
||||
handle->read_timeout=DEFAULT_READ_TIMEOUT;
|
||||
@ -170,6 +172,8 @@ 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"))
|
||||
handle->availableWhenDonor = config_truth_value(params->value);
|
||||
params = params->next;
|
||||
}
|
||||
|
||||
@ -289,6 +293,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,"\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);
|
||||
@ -428,14 +433,28 @@ char *server_string;
|
||||
}
|
||||
|
||||
/* Check if the the Galera FSM shows this node is joined to the cluster */
|
||||
if (mysql_query(database->con, "SHOW STATUS LIKE 'wsrep_local_state_comment'") == 0
|
||||
if (mysql_query(database->con, "SHOW STATUS LIKE 'wsrep_local_state'") == 0
|
||||
&& (result = mysql_store_result(database->con)) != NULL)
|
||||
{
|
||||
num_fields = mysql_num_fields(result);
|
||||
while ((row = mysql_fetch_row(result)))
|
||||
{
|
||||
if (strncasecmp(row[1], "SYNCED", 3) == 0)
|
||||
if (strcmp(row[1], "4") == 0)
|
||||
isjoined = 1;
|
||||
|
||||
/* Check if the node is a donor and is using xtrabackup, in this case it can stay alive */
|
||||
else if (strcmp(row[1], "2") == 0 && handle->availableWhenDonor == 1) {
|
||||
if (mysql_query(database->con, "SHOW VARIABLES LIKE 'wsrep_sst_method'") == 0
|
||||
&& (result = mysql_store_result(database->con)) != NULL)
|
||||
{
|
||||
num_fields = mysql_num_fields(result);
|
||||
while ((row = mysql_fetch_row(result)))
|
||||
{
|
||||
if (strncmp(row[1], "xtrabackup", 10) == 0)
|
||||
isjoined = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
mysql_free_result(result);
|
||||
}
|
||||
@ -732,6 +751,22 @@ MYSQL_MONITOR *handle = (MYSQL_MONITOR *)arg;
|
||||
memcpy(&handle->disableMasterFailback, &disable, sizeof(int));
|
||||
}
|
||||
|
||||
/**
|
||||
* Allow a Galera node to be in sync when Donor.
|
||||
*
|
||||
* When enabled, the monitor will check if the node is using xtrabackup or xtrabackup-v2
|
||||
* as SST method. In that case, node will stay as synced.
|
||||
*
|
||||
* @param arg The handle allocated by startMonitor
|
||||
* @param disable To allow sync status use 1, 0 for traditional behavior
|
||||
*/
|
||||
static void
|
||||
availableWhenDonor(void *arg, int disable)
|
||||
{
|
||||
MYSQL_MONITOR *handle = (MYSQL_MONITOR *)arg;
|
||||
memcpy(&handle->availableWhenDonor, &disable, sizeof(int));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the timeouts to use in the monitor.
|
||||
*
|
||||
|
@ -35,6 +35,7 @@
|
||||
* 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
|
||||
*
|
||||
* @endverbatim
|
||||
*/
|
||||
@ -68,6 +69,7 @@ typedef struct {
|
||||
int replicationHeartbeat; /**< Monitor flag for MySQL replication heartbeat */
|
||||
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 */
|
||||
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 */
|
||||
|
Loading…
x
Reference in New Issue
Block a user