Merge branch '2.1' into develop

This commit is contained in:
Johan Wikman
2017-02-14 17:54:27 +02:00
46 changed files with 321 additions and 210 deletions

View File

@ -106,7 +106,7 @@ static void errorReply(MXS_ROUTER *instance,
mxs_error_action_t action,
bool *succp);
static uint64_t getCapabilities(void);
static uint64_t getCapabilities(MXS_ROUTER* instance);
static int blr_handler_config(void *userdata, const char *section, const char *name, const char *value);
static int blr_handle_config_item(const char *name, const char *value, ROUTER_INSTANCE *inst);
static int blr_load_dbusers(const ROUTER_INSTANCE *router);
@ -1906,7 +1906,7 @@ static void rses_end_locked_router_action(ROUTER_SLAVE *rses)
}
static uint64_t getCapabilities(void)
static uint64_t getCapabilities(MXS_ROUTER* instance)
{
return RCAP_TYPE_NO_RSESSION | RCAP_TYPE_CONTIGUOUS_OUTPUT | RCAP_TYPE_RESULTSET_OUTPUT;
}

View File

@ -1197,8 +1197,12 @@ blr_cache_response(ROUTER_INSTANCE *router, char *response, GWBUF *buf)
{
return;
}
write(fd, GWBUF_DATA(buf), GWBUF_LENGTH(buf));
// TODO: Check result.
if (write(fd, GWBUF_DATA(buf), GWBUF_LENGTH(buf)) == -1)
{
char err[MXS_STRERROR_BUFLEN];
MXS_ERROR("Failed to write cached response: %d, %s",
errno, strerror_r(errno, err, sizeof(err)));
}
close(fd);
}
@ -1251,7 +1255,12 @@ blr_cache_read_response(ROUTER_INSTANCE *router, char *response)
close(fd);
return NULL;
}
read(fd, GWBUF_DATA(buf), statb.st_size);
if (read(fd, GWBUF_DATA(buf), statb.st_size) == -1)
{
char err[MXS_STRERROR_BUFLEN];
MXS_ERROR("Failed to read cached response: %d, %s",
errno, strerror_r(errno, err, sizeof(err)));
}
close(fd);
return buf;
}
@ -1421,11 +1430,10 @@ blr_read_events_all_events(ROUTER_INSTANCE *router, int fix, int debug)
break;
case -1:
{
char err_msg[BLRM_STRERROR_R_MSG_SIZE + 1] = "";
strerror_r(errno, err_msg, BLRM_STRERROR_R_MSG_SIZE);
char err[MXS_STRERROR_BUFLEN];
MXS_ERROR("Failed to read binlog file %s at position %llu"
" (%s).", router->binlog_name,
pos, err_msg);
" (%s).", router->binlog_name, pos,
strerror_r(errno, err, sizeof(err)));
if (errno == EBADF)
{
@ -1533,7 +1541,7 @@ blr_read_events_all_events(ROUTER_INSTANCE *router, int fix, int debug)
}
else
{
char errmsg[BLRM_STRERROR_R_MSG_SIZE + 1] = "";
char errmsg[BINLOG_ERROR_MSG_LEN + 1] = "";
/* fill replication header struct */
hdr.timestamp = EXTRACT32(hdbuf);
hdr.event_type = hdbuf[4];
@ -1641,12 +1649,12 @@ blr_read_events_all_events(ROUTER_INSTANCE *router, int fix, int debug)
{
if (n == -1)
{
char err_msg[BLRM_STRERROR_R_MSG_SIZE + 1] = "";
strerror_r(errno, err_msg, BLRM_STRERROR_R_MSG_SIZE);
char err[MXS_STRERROR_BUFLEN];
MXS_ERROR("Error reading the event at %llu in %s. "
"%s, expected %d bytes.",
pos, router->binlog_name,
err_msg, hdr.event_size - BINLOG_EVENT_HDR_LEN);
strerror_r(errno, err, sizeof(err)),
hdr.event_size - BINLOG_EVENT_HDR_LEN);
}
else
{
@ -1709,7 +1717,7 @@ blr_read_events_all_events(ROUTER_INSTANCE *router, int fix, int debug)
uint32_t event_size = EXTRACT32(hdbuf + BINLOG_EVENT_LEN_OFFSET);
uint8_t *decrypt_ptr;
unsigned long next_pos;
char errmsg[BLRM_STRERROR_R_MSG_SIZE + 1] = "";
char errmsg[BINLOG_ERROR_MSG_LEN + 1] = "";
/**
* Events are encrypted.

View File

@ -3664,7 +3664,12 @@ blr_start_slave(ROUTER_INSTANCE* router, ROUTER_SLAVE* slave)
router->prevbinlog,
router->last_safe_pos);
/* Truncate previous binlog file to last_safe pos */
truncate(file, router->last_safe_pos);
if (truncate(file, router->last_safe_pos) == -1)
{
char err[MXS_STRERROR_BUFLEN];
MXS_ERROR("Failed to truncate file: %d, %s",
errno, strerror_r(errno, err, sizeof(err)));
}
/* Log it */
MXS_WARNING("A transaction is still opened at pos %lu"