Develop merge
Develop merge
This commit is contained in:
@ -176,9 +176,8 @@ blr_slave_request(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave, GWBUF *queue)
|
||||
{
|
||||
if (slave->state < 0 || slave->state > BLRS_MAXSTATE)
|
||||
{
|
||||
LOGIF(LE, (skygw_log_write(
|
||||
LOGFILE_ERROR, "Invalid slave state machine state (%d) for binlog router.",
|
||||
slave->state)));
|
||||
MXS_ERROR("Invalid slave state machine state (%d) for binlog router.",
|
||||
slave->state);
|
||||
gwbuf_consume(queue, gwbuf_length(queue));
|
||||
return 0;
|
||||
}
|
||||
@ -196,11 +195,9 @@ blr_slave_request(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave, GWBUF *queue)
|
||||
blr_slave_send_error_packet(slave,
|
||||
"Binlog router is not yet configured for replication", (unsigned int) 1597, NULL);
|
||||
|
||||
LOGIF(LE, (skygw_log_write(
|
||||
LOGFILE_ERROR,
|
||||
"%s: Slave %s: Binlog router is not yet configured for replication",
|
||||
router->service->name,
|
||||
slave->dcb->remote)));
|
||||
MXS_ERROR("%s: Slave %s: Binlog router is not yet configured for replication",
|
||||
router->service->name,
|
||||
slave->dcb->remote);
|
||||
dcb_close(slave->dcb);
|
||||
return 1;
|
||||
}
|
||||
@ -215,11 +212,9 @@ blr_slave_request(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave, GWBUF *queue)
|
||||
blr_send_custom_error(slave->dcb, 1, 0,
|
||||
"MariaDB 10 Slave is required for Slave registration", "42000", 1064);
|
||||
|
||||
LOGIF(LE, (skygw_log_write(
|
||||
LOGFILE_ERROR,
|
||||
"%s: Slave %s: a MariaDB 10 Slave is required for Slave registration",
|
||||
router->service->name,
|
||||
slave->dcb->remote)));
|
||||
MXS_ERROR("%s: Slave %s: a MariaDB 10 Slave is required for Slave registration",
|
||||
router->service->name,
|
||||
slave->dcb->remote);
|
||||
|
||||
dcb_close(slave->dcb);
|
||||
return 1;
|
||||
@ -252,18 +247,15 @@ blr_slave_request(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave, GWBUF *queue)
|
||||
return blr_ping(router, slave, queue);
|
||||
break;
|
||||
case COM_QUIT:
|
||||
LOGIF(LD, (skygw_log_write(LOGFILE_DEBUG,
|
||||
"COM_QUIT received from slave with server_id %d",
|
||||
slave->serverid)));
|
||||
MXS_DEBUG("COM_QUIT received from slave with server_id %d",
|
||||
slave->serverid);
|
||||
break;
|
||||
default:
|
||||
blr_send_custom_error(slave->dcb, 1, 0,
|
||||
"You have an error in your SQL syntax; Check the syntax the MaxScale binlog router accepts.",
|
||||
"42000", 1064);
|
||||
LOGIF(LE, (skygw_log_write(
|
||||
LOGFILE_ERROR,
|
||||
"Unexpected MySQL Command (%d) received from slave",
|
||||
MYSQL_COMMAND(queue))));
|
||||
MXS_ERROR("Unexpected MySQL Command (%d) received from slave",
|
||||
MYSQL_COMMAND(queue));
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
@ -355,13 +347,11 @@ extern char *strcasestr();
|
||||
}
|
||||
}
|
||||
|
||||
LOGIF(LT, (skygw_log_write(
|
||||
LOGFILE_TRACE, "Execute statement (truncated, it contains password)"
|
||||
" from the slave '%s'", new_text)));
|
||||
MXS_INFO("Execute statement (truncated, it contains password)"
|
||||
" from the slave '%s'", new_text);
|
||||
free(new_text);
|
||||
} else {
|
||||
LOGIF(LT, (skygw_log_write(
|
||||
LOGFILE_TRACE, "Execute statement from the slave '%s'", query_text)));
|
||||
MXS_INFO("Execute statement from the slave '%s'", query_text);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -375,15 +365,14 @@ extern char *strcasestr();
|
||||
if ((word = strtok_r(query_text, sep, &brkb)) == NULL)
|
||||
{
|
||||
|
||||
LOGIF(LE, (skygw_log_write(LOGFILE_ERROR, "%s: Incomplete query.",
|
||||
router->service->name)));
|
||||
MXS_ERROR("%s: Incomplete query.", router->service->name);
|
||||
}
|
||||
else if (strcasecmp(word, "SELECT") == 0)
|
||||
{
|
||||
if ((word = strtok_r(NULL, sep, &brkb)) == NULL)
|
||||
{
|
||||
LOGIF(LE, (skygw_log_write(LOGFILE_ERROR, "%s: Incomplete select query.",
|
||||
router->service->name)));
|
||||
MXS_ERROR("%s: Incomplete select query.",
|
||||
router->service->name);
|
||||
}
|
||||
else if (strcasecmp(word, "UNIX_TIMESTAMP()") == 0)
|
||||
{
|
||||
@ -485,8 +474,8 @@ extern char *strcasestr();
|
||||
{
|
||||
if ((word = strtok_r(NULL, sep, &brkb)) == NULL)
|
||||
{
|
||||
LOGIF(LE, (skygw_log_write(LOGFILE_ERROR, "%s: Incomplete show query.",
|
||||
router->service->name)));
|
||||
MXS_ERROR("%s: Incomplete show query.",
|
||||
router->service->name);
|
||||
}
|
||||
else if (strcasecmp(word, "WARNINGS") == 0)
|
||||
{
|
||||
@ -502,9 +491,8 @@ extern char *strcasestr();
|
||||
|
||||
if ((word = strtok_r(NULL, sep, &brkb)) == NULL)
|
||||
{
|
||||
LOGIF(LE, (skygw_log_write(LOGFILE_ERROR,
|
||||
"%s: Expected VARIABLES in SHOW GLOBAL",
|
||||
router->service->name)));
|
||||
MXS_ERROR("%s: Expected VARIABLES in SHOW GLOBAL",
|
||||
router->service->name);
|
||||
}
|
||||
else if (strcasecmp(word, "VARIABLES") == 0)
|
||||
{
|
||||
@ -519,9 +507,8 @@ extern char *strcasestr();
|
||||
|
||||
return 1;
|
||||
} else
|
||||
LOGIF(LE, (skygw_log_write(LOGFILE_ERROR,
|
||||
"%s: Expected LIKE clause in SHOW GLOBAL VARIABLES.",
|
||||
router->service->name)));
|
||||
MXS_ERROR("%s: Expected LIKE clause in SHOW GLOBAL VARIABLES.",
|
||||
router->service->name);
|
||||
}
|
||||
else if (strcasecmp(word, "STATUS") == 0)
|
||||
{
|
||||
@ -536,9 +523,8 @@ extern char *strcasestr();
|
||||
|
||||
return 1;
|
||||
} else
|
||||
LOGIF(LE, (skygw_log_write(LOGFILE_ERROR,
|
||||
"%s: Expected LIKE clause in SHOW GLOBAL STATUS.",
|
||||
router->service->name)));
|
||||
MXS_ERROR("%s: Expected LIKE clause in SHOW GLOBAL STATUS.",
|
||||
router->service->name);
|
||||
}
|
||||
}
|
||||
else if (strcasecmp(word, "VARIABLES") == 0)
|
||||
@ -560,17 +546,15 @@ extern char *strcasestr();
|
||||
|
||||
return 1;
|
||||
} else
|
||||
LOGIF(LE, (skygw_log_write(LOGFILE_ERROR,
|
||||
"%s: Expected LIKE clause in SHOW VARIABLES.",
|
||||
router->service->name)));
|
||||
MXS_ERROR("%s: Expected LIKE clause in SHOW VARIABLES.",
|
||||
router->service->name);
|
||||
}
|
||||
else if (strcasecmp(word, "MASTER") == 0)
|
||||
{
|
||||
if ((word = strtok_r(NULL, sep, &brkb)) == NULL)
|
||||
{
|
||||
LOGIF(LE, (skygw_log_write(LOGFILE_ERROR,
|
||||
"%s: Expected SHOW MASTER STATUS command",
|
||||
router->service->name)));
|
||||
MXS_ERROR("%s: Expected SHOW MASTER STATUS command",
|
||||
router->service->name);
|
||||
}
|
||||
else if (strcasecmp(word, "STATUS") == 0)
|
||||
{
|
||||
@ -588,9 +572,8 @@ extern char *strcasestr();
|
||||
{
|
||||
if ((word = strtok_r(NULL, sep, &brkb)) == NULL)
|
||||
{
|
||||
LOGIF(LE, (skygw_log_write(LOGFILE_ERROR,
|
||||
"%s: Expected SHOW SLAVE STATUS command",
|
||||
router->service->name)));
|
||||
MXS_ERROR("%s: Expected SHOW SLAVE STATUS command",
|
||||
router->service->name);
|
||||
}
|
||||
else if (strcasecmp(word, "STATUS") == 0)
|
||||
{
|
||||
@ -624,17 +607,16 @@ extern char *strcasestr();
|
||||
|
||||
return 1;
|
||||
} else
|
||||
LOGIF(LE, (skygw_log_write(LOGFILE_ERROR,
|
||||
"%s: Expected LIKE clause in SHOW STATUS.",
|
||||
router->service->name)));
|
||||
MXS_ERROR("%s: Expected LIKE clause in SHOW STATUS.",
|
||||
router->service->name);
|
||||
}
|
||||
}
|
||||
else if (strcasecmp(query_text, "SET") == 0)
|
||||
{
|
||||
if ((word = strtok_r(NULL, sep, &brkb)) == NULL)
|
||||
{
|
||||
LOGIF(LE, (skygw_log_write(LOGFILE_ERROR, "%s: Incomplete set command.",
|
||||
router->service->name)));
|
||||
MXS_ERROR("%s: Incomplete set command.",
|
||||
router->service->name);
|
||||
}
|
||||
else if (strcasecmp(word, "@master_heartbeat_period") == 0)
|
||||
{
|
||||
@ -705,8 +687,8 @@ extern char *strcasestr();
|
||||
{
|
||||
if ((word = strtok_r(NULL, sep, &brkb)) == NULL)
|
||||
{
|
||||
LOGIF(LE, (skygw_log_write(LOGFILE_ERROR, "%s: Truncated SET NAMES command.",
|
||||
router->service->name)));
|
||||
MXS_ERROR("%s: Truncated SET NAMES command.",
|
||||
router->service->name);
|
||||
}
|
||||
else if (strcasecmp(word, "latin1") == 0)
|
||||
{
|
||||
@ -724,8 +706,8 @@ extern char *strcasestr();
|
||||
{
|
||||
if ((word = strtok_r(NULL, sep, &brkb)) == NULL)
|
||||
{
|
||||
LOGIF(LE, (skygw_log_write(LOGFILE_ERROR, "%s: Incomplete RESET command.",
|
||||
router->service->name)));
|
||||
MXS_ERROR("%s: Incomplete RESET command.",
|
||||
router->service->name);
|
||||
}
|
||||
else if (strcasecmp(word, "SLAVE") == 0)
|
||||
{
|
||||
@ -742,7 +724,7 @@ extern char *strcasestr();
|
||||
|
||||
if (!current_master) {
|
||||
snprintf(error_string, BINLOG_ERROR_MSG_LEN, "error allocating memory for blr_master_get_config");
|
||||
LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR, "%s: %s", router->service->name, error_string)));
|
||||
MXS_ERROR("%s: %s", router->service->name, error_string);
|
||||
blr_slave_send_error_packet(slave, error_string, (unsigned int)1201, NULL);
|
||||
|
||||
return 1;
|
||||
@ -751,13 +733,15 @@ extern char *strcasestr();
|
||||
/* get current data */
|
||||
blr_master_get_config(router, current_master);
|
||||
|
||||
LOGIF(LM, (skygw_log_write(LOGFILE_MESSAGE, "%s: 'RESET SLAVE executed'. Previous state MASTER_HOST='%s', MASTER_PORT=%i, MASTER_LOG_FILE='%s', MASTER_LOG_POS=%lu, MASTER_USER='%s'",
|
||||
router->service->name,
|
||||
current_master->host,
|
||||
current_master->port,
|
||||
current_master->logfile,
|
||||
current_master->pos,
|
||||
current_master->user)));
|
||||
MXS_NOTICE("%s: 'RESET SLAVE executed'. Previous state MASTER_HOST='%s', "
|
||||
"MASTER_PORT=%i, MASTER_LOG_FILE='%s', MASTER_LOG_POS=%lu, "
|
||||
"MASTER_USER='%s'",
|
||||
router->service->name,
|
||||
current_master->host,
|
||||
current_master->port,
|
||||
current_master->logfile,
|
||||
current_master->pos,
|
||||
current_master->user);
|
||||
|
||||
/* remove master.ini */
|
||||
strncpy(path, router->binlogdir, PATH_MAX);
|
||||
@ -770,7 +754,7 @@ extern char *strcasestr();
|
||||
if (removed_cfg == -1) {
|
||||
char err_msg[STRERROR_BUFLEN];
|
||||
snprintf(error_string, BINLOG_ERROR_MSG_LEN, "Error removing %s, %s, errno %u", path, strerror_r(errno, err_msg, sizeof(err_msg)), errno);
|
||||
LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR, "%s: %s", router->service->name, error_string)));
|
||||
MXS_ERROR("%s: %s", router->service->name, error_string);
|
||||
}
|
||||
|
||||
spinlock_acquire(&router->lock);
|
||||
@ -801,8 +785,8 @@ extern char *strcasestr();
|
||||
{
|
||||
if ((word = strtok_r(NULL, sep, &brkb)) == NULL)
|
||||
{
|
||||
LOGIF(LE, (skygw_log_write(LOGFILE_ERROR, "%s: Incomplete START command.",
|
||||
router->service->name)));
|
||||
MXS_ERROR("%s: Incomplete START command.",
|
||||
router->service->name);
|
||||
}
|
||||
else if (strcasecmp(word, "SLAVE") == 0)
|
||||
{
|
||||
@ -815,8 +799,7 @@ extern char *strcasestr();
|
||||
{
|
||||
if ((word = strtok_r(NULL, sep, &brkb)) == NULL)
|
||||
{
|
||||
LOGIF(LE, (skygw_log_write(LOGFILE_ERROR, "%s: Incomplete STOP command.",
|
||||
router->service->name)));
|
||||
MXS_ERROR("%s: Incomplete STOP command.", router->service->name);
|
||||
}
|
||||
else if (strcasecmp(word, "SLAVE") == 0)
|
||||
{
|
||||
@ -829,8 +812,7 @@ extern char *strcasestr();
|
||||
{
|
||||
if ((word = strtok_r(NULL, sep, &brkb)) == NULL)
|
||||
{
|
||||
LOGIF(LE, (skygw_log_write(LOGFILE_ERROR, "%s: Incomplete CHANGE command.",
|
||||
router->service->name)));
|
||||
MXS_ERROR("%s: Incomplete CHANGE command.", router->service->name);
|
||||
}
|
||||
else if (strcasecmp(word, "MASTER") == 0)
|
||||
{
|
||||
@ -851,7 +833,7 @@ extern char *strcasestr();
|
||||
if (!current_master) {
|
||||
free(query_text);
|
||||
strcpy(error_string, "Error allocating memory for blr_master_get_config");
|
||||
LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR, "%s: %s", router->service->name, error_string)));
|
||||
MXS_ERROR("%s: %s", router->service->name, error_string);
|
||||
|
||||
blr_slave_send_error_packet(slave, error_string, (unsigned int)1201, NULL);
|
||||
|
||||
@ -887,8 +869,8 @@ extern char *strcasestr();
|
||||
spinlock_release(&router->lock);
|
||||
|
||||
snprintf(error_string, BINLOG_ERROR_MSG_LEN, "Error writing into %s/master.ini: %s", router->binlogdir, error);
|
||||
LOGIF(LE, (skygw_log_write(LOGFILE_ERROR, "%s: %s",
|
||||
router->service->name, error_string)));
|
||||
MXS_ERROR("%s: %s",
|
||||
router->service->name, error_string);
|
||||
|
||||
blr_slave_send_error_packet(slave, error_string, (unsigned int)1201, NULL);
|
||||
|
||||
@ -934,8 +916,8 @@ extern char *strcasestr();
|
||||
{
|
||||
if ((word = strtok_r(NULL, sep, &brkb)) == NULL)
|
||||
{
|
||||
LOGIF(LE, (skygw_log_write(LOGFILE_ERROR, "%s: Incomplete DISCONNECT command.",
|
||||
router->service->name)));
|
||||
MXS_ERROR("%s: Incomplete DISCONNECT command.",
|
||||
router->service->name);
|
||||
}
|
||||
else if (strcasecmp(word, "ALL") == 0)
|
||||
{
|
||||
@ -946,9 +928,8 @@ extern char *strcasestr();
|
||||
{
|
||||
if ((word = strtok_r(NULL, sep, &brkb)) == NULL)
|
||||
{
|
||||
LOGIF(LE, (skygw_log_write(LOGFILE_ERROR,
|
||||
"%s: Expected DISCONNECT SERVER $server_id",
|
||||
router->service->name)));
|
||||
MXS_ERROR("%s: Expected DISCONNECT SERVER $server_id",
|
||||
router->service->name);
|
||||
} else {
|
||||
int serverid = atoi(word);
|
||||
free(query_text);
|
||||
@ -960,8 +941,7 @@ extern char *strcasestr();
|
||||
free(query_text);
|
||||
|
||||
query_text = strndup(qtext, query_len);
|
||||
LOGIF(LE, (skygw_log_write(
|
||||
LOGFILE_ERROR, "Unexpected query from '%s'@'%s': %s", slave->dcb->user, slave->dcb->remote, query_text)));
|
||||
MXS_ERROR("Unexpected query from '%s'@'%s': %s", slave->dcb->user, slave->dcb->remote, query_text);
|
||||
free(query_text);
|
||||
blr_slave_send_error(router, slave, "You have an error in your SQL syntax; Check the syntax the MaxScale binlog router accepts.");
|
||||
return 1;
|
||||
@ -995,8 +975,7 @@ GWBUF *clone;
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGIF(LE, (skygw_log_write(LOGFILE_ERROR,
|
||||
"Failed to clone server response to send to slave.")));
|
||||
MXS_ERROR("Failed to clone server response to send to slave.");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -1724,20 +1703,16 @@ uint32_t chksum;
|
||||
binlognamelen = len - 11;
|
||||
if (binlognamelen > BINLOG_FNAMELEN)
|
||||
{
|
||||
LOGIF(LE, (skygw_log_write(
|
||||
LOGFILE_ERROR,
|
||||
"blr_slave_binlog_dump truncating binlog filename "
|
||||
"from %d to %d",
|
||||
binlognamelen, BINLOG_FNAMELEN)));
|
||||
MXS_ERROR("blr_slave_binlog_dump truncating binlog filename "
|
||||
"from %d to %d",
|
||||
binlognamelen, BINLOG_FNAMELEN);
|
||||
binlognamelen = BINLOG_FNAMELEN;
|
||||
}
|
||||
ptr += 4; // Skip length and sequence number
|
||||
if (*ptr++ != COM_BINLOG_DUMP)
|
||||
{
|
||||
LOGIF(LE, (skygw_log_write(
|
||||
LOGFILE_ERROR,
|
||||
"blr_slave_binlog_dump expected a COM_BINLOG_DUMP but received %d",
|
||||
*(ptr-1))));
|
||||
MXS_ERROR("blr_slave_binlog_dump expected a COM_BINLOG_DUMP but received %d",
|
||||
*(ptr-1));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1748,12 +1723,10 @@ uint32_t chksum;
|
||||
strncpy(slave->binlogfile, (char *)ptr, binlognamelen);
|
||||
slave->binlogfile[binlognamelen] = 0;
|
||||
|
||||
LOGIF(LD, (skygw_log_write(
|
||||
LOGFILE_DEBUG,
|
||||
"%s: COM_BINLOG_DUMP: binlog name '%s', length %d, "
|
||||
"from position %lu.", router->service->name,
|
||||
slave->binlogfile, binlognamelen,
|
||||
(unsigned long)slave->binlog_pos)));
|
||||
MXS_DEBUG("%s: COM_BINLOG_DUMP: binlog name '%s', length %d, "
|
||||
"from position %lu.", router->service->name,
|
||||
slave->binlogfile, binlognamelen,
|
||||
(unsigned long)slave->binlog_pos);
|
||||
|
||||
slave->seqno = 1;
|
||||
|
||||
@ -1999,9 +1972,8 @@ char read_errmsg[BINLOG_ERROR_MSG_LEN+1];
|
||||
unsigned long beat1 = hkheartbeat;
|
||||
blr_close_binlog(router, slave->file);
|
||||
if (hkheartbeat - beat1 > 1)
|
||||
LOGIF(LE, (skygw_log_write(
|
||||
LOGFILE_ERROR, "blr_close_binlog took %lu maxscale beats",
|
||||
hkheartbeat - beat1)));
|
||||
MXS_ERROR("blr_close_binlog took %lu maxscale beats",
|
||||
hkheartbeat - beat1);
|
||||
blr_slave_rotate(router, slave, GWBUF_DATA(record));
|
||||
beat1 = hkheartbeat;
|
||||
if ((slave->file = blr_open_binlog(router, slave->binlogfile)) == NULL)
|
||||
@ -2036,9 +2008,8 @@ char read_errmsg[BINLOG_ERROR_MSG_LEN+1];
|
||||
break;
|
||||
}
|
||||
if (hkheartbeat - beat1 > 1)
|
||||
LOGIF(LE, (skygw_log_write(
|
||||
LOGFILE_ERROR, "blr_open_binlog took %lu beats",
|
||||
hkheartbeat - beat1)));
|
||||
MXS_ERROR("blr_open_binlog took %lu beats",
|
||||
hkheartbeat - beat1);
|
||||
}
|
||||
slave->stats.n_bytes += gwbuf_length(head);
|
||||
written = slave->dcb->func.write(slave->dcb, head);
|
||||
@ -2151,6 +2122,9 @@ char read_errmsg[BINLOG_ERROR_MSG_LEN+1];
|
||||
spinlock_release(&slave->catch_lock);
|
||||
spinlock_release(&router->binlog_lock);
|
||||
state_change = 1;
|
||||
} else {
|
||||
spinlock_release(&slave->catch_lock);
|
||||
spinlock_release(&router->binlog_lock);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2195,13 +2169,12 @@ char read_errmsg[BINLOG_ERROR_MSG_LEN+1];
|
||||
* but the new binlog file has not yet been created. Therefore
|
||||
* we ignore these issues during the rotate processing.
|
||||
*/
|
||||
LOGIF(LE, (skygw_log_write(LOGFILE_ERROR,
|
||||
"Slave reached end of file for binlog file %s at %lu "
|
||||
"which is not the file currently being downloaded. "
|
||||
"Master binlog is %s, %lu. This may be caused by a "
|
||||
"previous failure of the master.",
|
||||
slave->binlogfile, (unsigned long)slave->binlog_pos,
|
||||
router->binlog_name, router->binlog_position)));
|
||||
MXS_ERROR("Slave reached end of file for binlog file %s at %lu "
|
||||
"which is not the file currently being downloaded. "
|
||||
"Master binlog is %s, %lu. This may be caused by a "
|
||||
"previous failure of the master.",
|
||||
slave->binlogfile, (unsigned long)slave->binlog_pos,
|
||||
router->binlog_name, router->binlog_position);
|
||||
if (blr_slave_fake_rotate(router, slave))
|
||||
{
|
||||
spinlock_acquire(&slave->catch_lock);
|
||||
@ -2286,9 +2259,8 @@ ROUTER_INSTANCE *router = slave->router;
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGIF(LD, (skygw_log_write(
|
||||
LOGFILE_DEBUG, "Ignored callback due to slave state %s",
|
||||
blrs_states[slave->state])));
|
||||
MXS_DEBUG("Ignored callback due to slave state %s",
|
||||
blrs_states[slave->state]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2650,12 +2622,12 @@ blr_slave_disconnect_server(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave, int se
|
||||
{
|
||||
/* server_id found */
|
||||
server_found = 1;
|
||||
LOGIF(LM, (skygw_log_write(LOGFILE_MESSAGE, "%s: Slave %s, server id %d, disconnected by %s@%s",
|
||||
router->service->name,
|
||||
sptr->dcb->remote,
|
||||
server_id,
|
||||
slave->dcb->user,
|
||||
slave->dcb->remote)));
|
||||
MXS_NOTICE("%s: Slave %s, server id %d, disconnected by %s@%s",
|
||||
router->service->name,
|
||||
sptr->dcb->remote,
|
||||
server_id,
|
||||
slave->dcb->user,
|
||||
slave->dcb->remote);
|
||||
|
||||
/* send server_id with disconnect state to client */
|
||||
n = blr_slave_send_disconnected_server(router, slave, server_id, 1);
|
||||
@ -2680,9 +2652,9 @@ blr_slave_disconnect_server(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave, int se
|
||||
}
|
||||
|
||||
if (n == 0) {
|
||||
LOGIF(LE, (skygw_log_write(LOGFILE_ERROR, "Error: gwbuf memory allocation in "
|
||||
"DISCONNECT SERVER server_id [%d]",
|
||||
sptr->serverid)));
|
||||
MXS_ERROR("gwbuf memory allocation in "
|
||||
"DISCONNECT SERVER server_id [%d]",
|
||||
sptr->serverid);
|
||||
|
||||
blr_slave_send_error(router, slave, "Memory allocation error for DISCONNECT SERVER");
|
||||
}
|
||||
@ -2730,9 +2702,9 @@ blr_slave_disconnect_all(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave)
|
||||
len = 5 + strlen(server_id) + strlen(state) + 1;
|
||||
|
||||
if ((pkt = gwbuf_alloc(len)) == NULL) {
|
||||
LOGIF(LE, (skygw_log_write(LOGFILE_ERROR, "Error: gwbuf memory allocation in "
|
||||
"DISCONNECT ALL for [%s], server_id [%d]",
|
||||
sptr->dcb->remote, sptr->serverid)));
|
||||
MXS_ERROR("gwbuf memory allocation in "
|
||||
"DISCONNECT ALL for [%s], server_id [%d]",
|
||||
sptr->dcb->remote, sptr->serverid);
|
||||
|
||||
spinlock_release(&router->lock);
|
||||
|
||||
@ -2741,9 +2713,9 @@ blr_slave_disconnect_all(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave)
|
||||
return 1;
|
||||
}
|
||||
|
||||
LOGIF(LM, (skygw_log_write(LOGFILE_MESSAGE, "%s: Slave %s, server id %d, disconnected by %s@%s",
|
||||
router->service->name,
|
||||
sptr->dcb->remote, sptr->serverid, slave->dcb->user, slave->dcb->remote)));
|
||||
MXS_NOTICE("%s: Slave %s, server id %d, disconnected by %s@%s",
|
||||
router->service->name,
|
||||
sptr->dcb->remote, sptr->serverid, slave->dcb->user, slave->dcb->remote);
|
||||
|
||||
ptr = GWBUF_DATA(pkt);
|
||||
encode_value(ptr, len - 4, 24); // Add length of data packet
|
||||
@ -2910,15 +2882,14 @@ blr_stop_slave(ROUTER_INSTANCE* router, ROUTER_SLAVE* slave)
|
||||
|
||||
spinlock_release(&router->lock);
|
||||
|
||||
LOGIF(LM, (skygw_log_write(
|
||||
LOGFILE_MESSAGE,
|
||||
"%s: STOP SLAVE executed by %s@%s. Disconnecting from master %s:%d, read up to log %s, pos %lu, transaction safe pos %lu",
|
||||
router->service->name,
|
||||
slave->dcb->user,
|
||||
slave->dcb->remote,
|
||||
router->service->dbref->server->name,
|
||||
router->service->dbref->server->port,
|
||||
router->binlog_name, router->current_pos, router->binlog_position)));
|
||||
MXS_NOTICE("%s: STOP SLAVE executed by %s@%s. Disconnecting from master %s:%d, "
|
||||
"read up to log %s, pos %lu, transaction safe pos %lu",
|
||||
router->service->name,
|
||||
slave->dcb->user,
|
||||
slave->dcb->remote,
|
||||
router->service->dbref->server->name,
|
||||
router->service->dbref->server->port,
|
||||
router->binlog_name, router->current_pos, router->binlog_position);
|
||||
|
||||
if (router->trx_safe && router->pending_transaction) {
|
||||
char message[BINLOG_ERROR_MSG_LEN+1] = "";
|
||||
@ -2983,16 +2954,14 @@ blr_start_slave(ROUTER_INSTANCE* router, ROUTER_SLAVE* slave)
|
||||
truncate(file, router->last_safe_pos);
|
||||
|
||||
/* Log it */
|
||||
LOGIF(LE, (skygw_log_write(
|
||||
LOGFILE_ERROR,
|
||||
"Warning: a transaction is still opened at pos %lu"
|
||||
" File %s will be truncated. "
|
||||
"Next binlog file is %s at pos %d, "
|
||||
"START SLAVE is required again.",
|
||||
router->last_safe_pos,
|
||||
router->prevbinlog,
|
||||
router->binlog_name,
|
||||
4)));
|
||||
MXS_WARNING("A transaction is still opened at pos %lu"
|
||||
" File %s will be truncated. "
|
||||
"Next binlog file is %s at pos %d, "
|
||||
"START SLAVE is required again.",
|
||||
router->last_safe_pos,
|
||||
router->prevbinlog,
|
||||
router->binlog_name,
|
||||
4);
|
||||
|
||||
spinlock_acquire(&router->lock);
|
||||
|
||||
@ -3023,16 +2992,15 @@ blr_start_slave(ROUTER_INSTANCE* router, ROUTER_SLAVE* slave)
|
||||
|
||||
blr_start_master(router);
|
||||
|
||||
LOGIF(LM, (skygw_log_write(
|
||||
LOGFILE_MESSAGE,
|
||||
"%s: START SLAVE executed by %s@%s. Trying connection to master %s:%d, binlog %s, pos %lu, transaction safe pos %lu",
|
||||
router->service->name,
|
||||
slave->dcb->user,
|
||||
slave->dcb->remote,
|
||||
router->service->dbref->server->name,
|
||||
router->service->dbref->server->port,
|
||||
router->binlog_name,
|
||||
router->current_pos, router->binlog_position)));
|
||||
MXS_NOTICE("%s: START SLAVE executed by %s@%s. Trying connection to master %s:%d, "
|
||||
"binlog %s, pos %lu, transaction safe pos %lu",
|
||||
router->service->name,
|
||||
slave->dcb->user,
|
||||
slave->dcb->remote,
|
||||
router->service->dbref->server->name,
|
||||
router->service->dbref->server->port,
|
||||
router->binlog_name,
|
||||
router->current_pos, router->binlog_position);
|
||||
|
||||
/* File path for router cached authentication data */
|
||||
strcpy(path, router->binlogdir);
|
||||
@ -3045,10 +3013,8 @@ blr_start_slave(ROUTER_INSTANCE* router, ROUTER_SLAVE* slave)
|
||||
|
||||
if (loaded < 0)
|
||||
{
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Unable to load users for service %s",
|
||||
router->service->name)));
|
||||
MXS_ERROR("Unable to load users for service %s",
|
||||
router->service->name);
|
||||
} else {
|
||||
/* update cached data */
|
||||
if (loaded > 0)
|
||||
@ -3136,7 +3102,7 @@ int blr_handle_change_master(ROUTER_INSTANCE* router, char *command, char *error
|
||||
|
||||
if ((cmd_string = strdup(cmd_ptr + 2)) == NULL) {
|
||||
strncpy(error, "error allocating memory for statement parsing", BINLOG_ERROR_MSG_LEN);
|
||||
LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR, "%s: %s", router->service->name, error)));
|
||||
MXS_ERROR("%s: %s", router->service->name, error);
|
||||
|
||||
return -1;
|
||||
}
|
||||
@ -3149,7 +3115,7 @@ int blr_handle_change_master(ROUTER_INSTANCE* router, char *command, char *error
|
||||
free(cmd_string);
|
||||
|
||||
if (parse_ret) {
|
||||
LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR, "%s CHANGE MASTER TO parse error: %s", router->service->name, error)));
|
||||
MXS_ERROR("%s CHANGE MASTER TO parse error: %s", router->service->name, error);
|
||||
|
||||
blr_master_free_parsed_options(&change_master);
|
||||
|
||||
@ -3161,7 +3127,7 @@ int blr_handle_change_master(ROUTER_INSTANCE* router, char *command, char *error
|
||||
|
||||
if (!current_master) {
|
||||
strncpy(error, "error allocating memory for blr_master_get_config", BINLOG_ERROR_MSG_LEN);
|
||||
LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR, "%s: %s", router->service->name, error)));
|
||||
MXS_ERROR("%s: %s", router->service->name, error);
|
||||
|
||||
blr_master_free_parsed_options(&change_master);
|
||||
|
||||
@ -3210,7 +3176,7 @@ int blr_handle_change_master(ROUTER_INSTANCE* router, char *command, char *error
|
||||
strcpy(error, "Router is not configured for master connection, MASTER_LOG_FILE is required");
|
||||
}
|
||||
|
||||
LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR, "%s: %s", router->service->name, error)));
|
||||
MXS_ERROR("%s: %s", router->service->name, error);
|
||||
|
||||
/* restore previous master_host and master_port */
|
||||
blr_master_restore_config(router, current_master);
|
||||
@ -3231,7 +3197,7 @@ int blr_handle_change_master(ROUTER_INSTANCE* router, char *command, char *error
|
||||
/* if errors returned */
|
||||
if (strlen(error)) {
|
||||
|
||||
LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR, "%s: %s", router->service->name, error)));
|
||||
MXS_ERROR("%s: %s", router->service->name, error);
|
||||
|
||||
/* restore previous master_host and master_port */
|
||||
blr_master_restore_config(router, current_master);
|
||||
@ -3282,7 +3248,7 @@ int blr_handle_change_master(ROUTER_INSTANCE* router, char *command, char *error
|
||||
/* return an error or set new binlog name at pos 4 */
|
||||
if (return_error) {
|
||||
|
||||
LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR, "%s: %s", router->service->name, error)));
|
||||
MXS_ERROR("%s: %s", router->service->name, error);
|
||||
|
||||
/* restore previous master_host and master_port */
|
||||
blr_master_restore_config(router, current_master);
|
||||
@ -3309,9 +3275,9 @@ int blr_handle_change_master(ROUTER_INSTANCE* router, char *command, char *error
|
||||
close(router->binlog_fd);
|
||||
router->binlog_fd = -1;
|
||||
|
||||
LOGIF(LT, (skygw_log_write(LOGFILE_TRACE, "%s: New MASTER_LOG_FILE is [%s]",
|
||||
router->service->name,
|
||||
router->binlog_name)));
|
||||
MXS_INFO("%s: New MASTER_LOG_FILE is [%s]",
|
||||
router->service->name,
|
||||
router->binlog_name);
|
||||
}
|
||||
} else {
|
||||
/**
|
||||
@ -3345,7 +3311,7 @@ int blr_handle_change_master(ROUTER_INSTANCE* router, char *command, char *error
|
||||
|
||||
/* log error and return */
|
||||
if (return_error) {
|
||||
LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR, "%s: %s", router->service->name, error)));
|
||||
MXS_ERROR("%s: %s", router->service->name, error);
|
||||
|
||||
/* restore previous master_host and master_port */
|
||||
blr_master_restore_config(router, current_master);
|
||||
@ -3369,27 +3335,31 @@ int blr_handle_change_master(ROUTER_INSTANCE* router, char *command, char *error
|
||||
memset(router->binlog_name, '\0', sizeof(router->binlog_name));
|
||||
strncpy(router->binlog_name, master_logfile, BINLOG_FNAMELEN);
|
||||
|
||||
LOGIF(LT, (skygw_log_write(LOGFILE_TRACE, "%s: New MASTER_LOG_FILE is [%s]",
|
||||
router->service->name,
|
||||
router->binlog_name)));
|
||||
MXS_INFO("%s: New MASTER_LOG_FILE is [%s]",
|
||||
router->service->name,
|
||||
router->binlog_name);
|
||||
}
|
||||
|
||||
LOGIF(LT, (skygw_log_write(LOGFILE_TRACE, "%s: New MASTER_LOG_POS is [%lu]",
|
||||
router->service->name,
|
||||
router->current_pos)));
|
||||
MXS_INFO("%s: New MASTER_LOG_POS is [%lu]",
|
||||
router->service->name,
|
||||
router->current_pos);
|
||||
}
|
||||
}
|
||||
|
||||
/* Log config changes (without passwords) */
|
||||
|
||||
LOGIF(LM, (skygw_log_write(LOGFILE_MESSAGE, "%s: 'CHANGE MASTER TO executed'. Previous state MASTER_HOST='%s', MASTER_PORT=%i, MASTER_LOG_FILE='%s', MASTER_LOG_POS=%lu, MASTER_USER='%s'. New state is MASTER_HOST='%s', MASTER_PORT=%i, MASTER_LOG_FILE='%s', MASTER_LOG_POS=%lu, MASTER_USER='%s'",
|
||||
router->service->name,
|
||||
current_master->host,current_master->port, current_master->logfile, current_master->pos, current_master->user,
|
||||
router->service->dbref->server->name,
|
||||
router->service->dbref->server->port,
|
||||
router->binlog_name,
|
||||
router->current_pos,
|
||||
router->user)));
|
||||
MXS_NOTICE("%s: 'CHANGE MASTER TO executed'. Previous state "
|
||||
"MASTER_HOST='%s', MASTER_PORT=%i, MASTER_LOG_FILE='%s', "
|
||||
"MASTER_LOG_POS=%lu, MASTER_USER='%s'. New state is MASTER_HOST='%s', "
|
||||
"MASTER_PORT=%i, MASTER_LOG_FILE='%s', MASTER_LOG_POS=%lu, MASTER_USER='%s'",
|
||||
router->service->name,
|
||||
current_master->host, current_master->port, current_master->logfile,
|
||||
current_master->pos, current_master->user,
|
||||
router->service->dbref->server->name,
|
||||
router->service->dbref->server->port,
|
||||
router->binlog_name,
|
||||
router->current_pos,
|
||||
router->user);
|
||||
|
||||
blr_master_free_config(current_master);
|
||||
|
||||
@ -3429,9 +3399,9 @@ blr_set_master_hostname(ROUTER_INSTANCE *router, char *hostname) {
|
||||
|
||||
server_update_address(router->service->dbref->server, ptr);
|
||||
|
||||
LOGIF(LT, (skygw_log_write(LOGFILE_TRACE, "%s: New MASTER_HOST is [%s]",
|
||||
router->service->name,
|
||||
router->service->dbref->server->name)));
|
||||
MXS_INFO("%s: New MASTER_HOST is [%s]",
|
||||
router->service->name,
|
||||
router->service->dbref->server->name);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -3458,9 +3428,9 @@ blr_set_master_port(ROUTER_INSTANCE *router, char *port) {
|
||||
if (new_port) {
|
||||
server_update_port(router->service->dbref->server, new_port);
|
||||
|
||||
LOGIF(LT, (skygw_log_write(LOGFILE_TRACE, "%s: New MASTER_PORT is [%i]",
|
||||
router->service->name,
|
||||
router->service->dbref->server->port)));
|
||||
MXS_INFO("%s: New MASTER_PORT is [%i]",
|
||||
router->service->name,
|
||||
router->service->dbref->server->port);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -3694,9 +3664,9 @@ blr_set_master_user(ROUTER_INSTANCE *router, char *user) {
|
||||
}
|
||||
router->user = strdup(ptr);
|
||||
|
||||
LOGIF(LT, (skygw_log_write(LOGFILE_TRACE, "%s: New MASTER_USER is [%s]",
|
||||
router->service->name,
|
||||
router->user)));
|
||||
MXS_INFO("%s: New MASTER_USER is [%s]",
|
||||
router->service->name,
|
||||
router->user);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -4128,9 +4098,8 @@ char *sep = " ,=";
|
||||
return -1;
|
||||
} else if (strcasecmp(word, "LIKE") == 0) {
|
||||
if ((word = strtok_r(NULL, sep, &brkb)) == NULL) {
|
||||
LOGIF(LE, (skygw_log_write(LOGFILE_ERROR,
|
||||
"%s: Missing LIKE clause in SHOW [GLOBAL] VARIABLES.",
|
||||
router->service->name)));
|
||||
MXS_ERROR("%s: Missing LIKE clause in SHOW [GLOBAL] VARIABLES.",
|
||||
router->service->name);
|
||||
return -1;
|
||||
} else if (strcasecmp(word, "'SERVER_ID'") == 0) {
|
||||
if (router->set_master_server_id) {
|
||||
@ -4305,9 +4274,8 @@ char *sep = " ,=";
|
||||
return -1;
|
||||
} else if (strcasecmp(word, "LIKE") == 0) {
|
||||
if ((word = strtok_r(NULL, sep, &brkb)) == NULL) {
|
||||
LOGIF(LE, (skygw_log_write(LOGFILE_ERROR,
|
||||
"%s: Missing LIKE clause in SHOW [GLOBAL] STATUS.",
|
||||
router->service->name)));
|
||||
MXS_ERROR("%s: Missing LIKE clause in SHOW [GLOBAL] STATUS.",
|
||||
router->service->name);
|
||||
return -1;
|
||||
} else if (strcasecmp(word, "'Uptime'") == 0) {
|
||||
char uptime[41]="";
|
||||
@ -4484,11 +4452,10 @@ time_t t_now = time(0);
|
||||
/* skip servers with state = 0 */
|
||||
if ( (sptr->state == BLRS_DUMPING) && (sptr->heartbeat > 0) && ((t_now + 1 - sptr->lastReply) >= sptr->heartbeat) )
|
||||
{
|
||||
LOGIF(LM, (skygw_log_write(
|
||||
LOGFILE_MESSAGE, "Sending Heartbeat to slave server-id %d in State %d, cstate %d. "
|
||||
"Heartbeat interval is %d, last event time is %lu",
|
||||
sptr->serverid, sptr->state, sptr->cstate, sptr->heartbeat,
|
||||
(unsigned long)sptr->lastReply)));
|
||||
MXS_NOTICE("Sending Heartbeat to slave server-id %d. "
|
||||
"Heartbeat interval is %d, last event time is %lu",
|
||||
sptr->serverid, sptr->heartbeat,
|
||||
(unsigned long)sptr->lastReply);
|
||||
|
||||
blr_slave_send_heartbeat(router, sptr);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user