Merge branch '2.1' into 2.2

This commit is contained in:
Markus Mäkelä
2017-10-03 14:30:06 +03:00
39 changed files with 685 additions and 417 deletions

View File

@ -868,9 +868,12 @@ createInstance(SERVICE *service, char **options)
/** Set SSL pointer in in server struct */
server->server_ssl = ssl_cfg;
/* Set server unique name */
/* Add server to service backend list */
serviceAddBackend(inst->service, server);
/* Hide backend server struct */
service->dbref->server->is_active = false;
service->dbref->active = false;
}
/*
@ -919,6 +922,9 @@ createInstance(SERVICE *service, char **options)
else
{
inst->master_state = BLRM_UNCONNECTED;
/* Set backend server as active */
service->dbref->server->is_active = true;
service->dbref->active = true;
}
/**
@ -979,6 +985,18 @@ createInstance(SERVICE *service, char **options)
blr_cache_read_master_data(inst);
/**
* The value of master checksum is known only at registration time, so
* as soon as replication succeds the value is updated.
* Set now the binlog checksum from the saved value.
* This is very useful in case of possible failure in the
* registration phase for any reason: master is down, wrong password etc.
* In this case a connecting slave will get the checksum value
* from previous registration instead of default one (CRC32)
* which can be wrong if slave has binlog_checksum = NONE.
*/
blr_set_checksum(inst, inst->saved_master.chksum2);
/*
* Find latest binlog file in binlogdir or GTID maps repo
*/
if (blr_file_init(inst) == 0)

View File

@ -1009,6 +1009,7 @@ extern const char *blr_get_encryption_algorithm(int);
extern int blr_check_encryption_algorithm(char *);
extern const char *blr_encryption_algorithm_list(void);
extern bool blr_get_encryption_key(ROUTER_INSTANCE *);
extern void blr_set_checksum(ROUTER_INSTANCE *instance, GWBUF *buf);
extern const char *blr_skip_leading_sql_comments(const char *);
extern bool blr_fetch_mariadb_gtid(ROUTER_SLAVE *,
const char *,

View File

@ -2523,16 +2523,8 @@ static void blr_register_getchecksum(ROUTER_INSTANCE *router, GWBUF *buf)
*/
static void blr_register_handle_checksum(ROUTER_INSTANCE *router, GWBUF *buf)
{
char *val = blr_extract_column(buf, 1);
if (val && strncasecmp(val, "NONE", 4) == 0)
{
router->master_chksum = false;
}
if (val)
{
MXS_FREE(val);
}
// Set checksum from master reply
blr_set_checksum(router, buf);
// Response from master should be stored
blr_register_cache_response(router,
@ -3569,3 +3561,25 @@ static int blr_check_connect_retry(ROUTER_INSTANCE *router)
return BLR_MASTER_BACKOFF_TIME * (1 + router->retry_count);
}
}
/**
* Set checksum value in router instance
*
* @param inst The router instance
* @param buf The buffer with checksum value
*/
void blr_set_checksum(ROUTER_INSTANCE *inst, GWBUF *buf)
{
if (buf)
{
char *val = blr_extract_column(buf, 1);
if (val && strncasecmp(val, "NONE", 4) == 0)
{
inst->master_chksum = false;
}
if (val)
{
MXS_FREE(val);
}
}
}

View File

@ -7837,6 +7837,15 @@ static bool blr_handle_admin_stmt(ROUTER_INSTANCE *router,
return true;
}
/* Mark as active the master server struct */
spinlock_acquire(&router->lock);
if (!router->service->dbref->server->is_active)
{
router->service->dbref->server->is_active = true;
router->service->dbref->active = true;
}
spinlock_release(&router->lock);
/**
* check if router is BLRM_UNCONFIGURED
* and change state to BLRM_SLAVE_STOPPED