Merge branch 'release-1.0GA' into firewall
Conflicts: log_manager/log_manager.cc
This commit is contained in:
@ -423,8 +423,8 @@ init_conn(MQ_INSTANCE *my_instance)
|
||||
*/
|
||||
char** parse_optstr(char* str, char* tok, int* szstore)
|
||||
{
|
||||
char* tk = str;
|
||||
char** arr;
|
||||
char *lasts, *tk = str;
|
||||
char **arr;
|
||||
int i = 0, size = 1;
|
||||
while((tk = strpbrk(tk + 1,tok))){
|
||||
size++;
|
||||
@ -440,10 +440,10 @@ char** parse_optstr(char* str, char* tok, int* szstore)
|
||||
}
|
||||
|
||||
*szstore = size;
|
||||
tk = strtok(str,tok);
|
||||
tk = strtok_r(str,tok, &lasts);
|
||||
while(tk && i < size){
|
||||
arr[i++] = strdup(tk);
|
||||
tk = strtok(NULL,tok);
|
||||
tk = strtok_r(NULL,tok,&lasts);
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
@ -1052,7 +1052,8 @@ routeQuery(FILTER *instance, void *session, GWBUF *queue)
|
||||
|
||||
for(z = 0;z<tbsz;z++){
|
||||
if((tmp = strchr(tblnames[z],'.')) != NULL){
|
||||
tmp = strtok(tblnames[z],".");
|
||||
char *lasts;
|
||||
tmp = strtok_r(tblnames[z],".",&lasts);
|
||||
for(i = 0; i<my_instance->shm_trg->size; i++){
|
||||
|
||||
if(strcmp(tmp,my_instance->shm_trg->objects[i]) == 0){
|
||||
@ -1103,8 +1104,9 @@ routeQuery(FILTER *instance, void *session, GWBUF *queue)
|
||||
char* tbnm = NULL;
|
||||
|
||||
if((strchr(sesstbls[j],'.')) != NULL){
|
||||
tbnm = strtok(sesstbls[j],".");
|
||||
tbnm = strtok(NULL,".");
|
||||
char *lasts;
|
||||
tbnm = strtok_r(sesstbls[j],".",&lasts);
|
||||
tbnm = strtok_r(NULL,".",&lasts);
|
||||
}else{
|
||||
tbnm = sesstbls[j];
|
||||
}
|
||||
|
||||
@ -95,6 +95,7 @@ typedef enum {
|
||||
MYSQL_AUTH_SENT,
|
||||
MYSQL_AUTH_RECV,
|
||||
MYSQL_AUTH_FAILED,
|
||||
MYSQL_HANDSHAKE_FAILED,
|
||||
MYSQL_IDLE
|
||||
} mysql_auth_state_t;
|
||||
|
||||
|
||||
@ -752,7 +752,7 @@ int log_no_master = 1;
|
||||
/* log master detection failure od first master becomes available after failure */
|
||||
if (root_master && mon_status_changed(root_master) && !(root_master->server->status & SERVER_STALE_STATUS)) {
|
||||
if (root_master->pending_status & (SERVER_MASTER)) {
|
||||
if (!(root_master->mon_prev_status & SERVER_STALE_STATUS)) {
|
||||
if (!(root_master->mon_prev_status & SERVER_STALE_STATUS) && !(root_master->server->status & SERVER_MAINT)) {
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Info: A Master Server is now available: %s:%i",
|
||||
|
||||
@ -374,8 +374,8 @@ int rc;
|
||||
rc = listen(listener->fd, SOMAXCONN);
|
||||
|
||||
if (rc == 0) {
|
||||
LOGIF(LD, (skygw_log_write(
|
||||
LOGFILE_DEBUG,
|
||||
LOGIF(LM, (skygw_log_write(
|
||||
LOGFILE_MESSAGE,
|
||||
"Listening maxscale connections at %s\n",
|
||||
config)));
|
||||
} else {
|
||||
|
||||
@ -211,12 +211,13 @@ static int gw_read_backend_event(DCB *dcb) {
|
||||
/** Read cached backend handshake */
|
||||
if (gw_read_backend_handshake(backend_protocol) != 0)
|
||||
{
|
||||
backend_protocol->protocol_auth_state = MYSQL_AUTH_FAILED;
|
||||
backend_protocol->protocol_auth_state = MYSQL_HANDSHAKE_FAILED;
|
||||
|
||||
LOGIF(LD, (skygw_log_write(
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [gw_read_backend_event] after "
|
||||
"gw_read_backend_handshake, fd %d, "
|
||||
"state = MYSQL_AUTH_FAILED.",
|
||||
"state = MYSQL_HANDSHAKE_FAILED.",
|
||||
pthread_self(),
|
||||
backend_protocol->owner_dcb->fd)));
|
||||
}
|
||||
@ -256,6 +257,7 @@ static int gw_read_backend_event(DCB *dcb) {
|
||||
* -- handle a previous handshake error
|
||||
*/
|
||||
if (backend_protocol->protocol_auth_state == MYSQL_AUTH_RECV ||
|
||||
backend_protocol->protocol_auth_state == MYSQL_HANDSHAKE_FAILED ||
|
||||
backend_protocol->protocol_auth_state == MYSQL_AUTH_FAILED)
|
||||
{
|
||||
spinlock_acquire(&dcb->authlock);
|
||||
@ -264,6 +266,7 @@ static int gw_read_backend_event(DCB *dcb) {
|
||||
CHK_PROTOCOL(backend_protocol);
|
||||
|
||||
if (backend_protocol->protocol_auth_state == MYSQL_AUTH_RECV ||
|
||||
backend_protocol->protocol_auth_state == MYSQL_HANDSHAKE_FAILED ||
|
||||
backend_protocol->protocol_auth_state == MYSQL_AUTH_FAILED)
|
||||
{
|
||||
ROUTER_OBJECT *router = NULL;
|
||||
@ -286,7 +289,7 @@ static int gw_read_backend_event(DCB *dcb) {
|
||||
if (backend_protocol->protocol_auth_state == MYSQL_AUTH_RECV)
|
||||
{
|
||||
/**
|
||||
* Read backed's reply to authentication message
|
||||
* Read backend's reply to authentication message
|
||||
*/
|
||||
receive_rc =
|
||||
gw_receive_backend_auth(backend_protocol);
|
||||
@ -340,7 +343,8 @@ static int gw_read_backend_event(DCB *dcb) {
|
||||
} /* switch */
|
||||
}
|
||||
|
||||
if (backend_protocol->protocol_auth_state == MYSQL_AUTH_FAILED)
|
||||
if (backend_protocol->protocol_auth_state == MYSQL_AUTH_FAILED ||
|
||||
backend_protocol->protocol_auth_state == MYSQL_HANDSHAKE_FAILED)
|
||||
{
|
||||
/**
|
||||
* protocol state won't change anymore,
|
||||
@ -362,7 +366,9 @@ static int gw_read_backend_event(DCB *dcb) {
|
||||
bool succp;
|
||||
|
||||
/* try reload users' table for next connection */
|
||||
service_refresh_users(dcb->session->service);
|
||||
if (backend_protocol->protocol_auth_state == MYSQL_AUTH_FAILED) {
|
||||
service_refresh_users(dcb->session->service);
|
||||
}
|
||||
#if defined(SS_DEBUG)
|
||||
LOGIF(LD, (skygw_log_write(
|
||||
LOGFILE_DEBUG,
|
||||
@ -428,7 +434,7 @@ static int gw_read_backend_event(DCB *dcb) {
|
||||
|
||||
spinlock_release(&dcb->authlock);
|
||||
|
||||
} /* MYSQL_AUTH_RECV || MYSQL_AUTH_FAILED */
|
||||
} /* MYSQL_AUTH_RECV || MYSQL_AUTH_FAILED || MYSQL_HANDSHAKE_FAILED */
|
||||
|
||||
/* reading MySQL command output from backend and writing to the client */
|
||||
{
|
||||
@ -552,7 +558,7 @@ static int gw_read_backend_event(DCB *dcb) {
|
||||
{
|
||||
client_protocol = SESSION_PROTOCOL(dcb->session,
|
||||
MySQLProtocol);
|
||||
if (client_protocol != NULL)
|
||||
if (client_protocol != NULL)
|
||||
{
|
||||
CHK_PROTOCOL(client_protocol);
|
||||
|
||||
@ -693,6 +699,7 @@ gw_MySQLWrite_backend(DCB *dcb, GWBUF *queue)
|
||||
* return 1.
|
||||
*/
|
||||
switch (backend_protocol->protocol_auth_state) {
|
||||
case MYSQL_HANDSHAKE_FAILED:
|
||||
case MYSQL_AUTH_FAILED:
|
||||
{
|
||||
size_t len;
|
||||
@ -823,18 +830,22 @@ static int gw_error_backend_event(DCB *dcb)
|
||||
*/
|
||||
if (dcb->state != DCB_STATE_POLLING)
|
||||
{
|
||||
int error, len;
|
||||
char buf[100];
|
||||
int error, len;
|
||||
char buf[100];
|
||||
|
||||
len = sizeof(error);
|
||||
|
||||
if (getsockopt(dcb->fd, SOL_SOCKET, SO_ERROR, &error, &len) == 0)
|
||||
{
|
||||
strerror_r(error, buf, 100);
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"DCB in state %s got error '%s'.",
|
||||
gw_dcb_state2string(dcb->state),
|
||||
buf)));
|
||||
if (error != 0)
|
||||
{
|
||||
strerror_r(error, buf, 100);
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"DCB in state %s got error '%s'.",
|
||||
STRDCBSTATE(dcb->state),
|
||||
buf)));
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
@ -862,18 +873,21 @@ static int gw_error_backend_event(DCB *dcb)
|
||||
|
||||
if (ses_state != SESSION_STATE_ROUTER_READY)
|
||||
{
|
||||
int error, len;
|
||||
char buf[100];
|
||||
int error, len;
|
||||
char buf[100];
|
||||
|
||||
len = sizeof(error);
|
||||
if (getsockopt(dcb->fd, SOL_SOCKET, SO_ERROR, &error, &len) == 0)
|
||||
{
|
||||
strerror_r(error, buf, 100);
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error '%s' in session that is not ready for routing.",
|
||||
buf)));
|
||||
}
|
||||
if (error != 0)
|
||||
{
|
||||
strerror_r(error, buf, 100);
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error '%s' in session that is not ready for routing.",
|
||||
buf)));
|
||||
}
|
||||
}
|
||||
gwbuf_free(errbuf);
|
||||
goto retblock;
|
||||
}
|
||||
@ -1065,18 +1079,21 @@ gw_backend_hangup(DCB *dcb)
|
||||
|
||||
if (ses_state != SESSION_STATE_ROUTER_READY)
|
||||
{
|
||||
int error, len;
|
||||
char buf[100];
|
||||
int error, len;
|
||||
char buf[100];
|
||||
|
||||
len = sizeof(error);
|
||||
if (getsockopt(dcb->fd, SOL_SOCKET, SO_ERROR, &error, &len) == 0)
|
||||
{
|
||||
strerror_r(error, buf, 100);
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Hangup in session that is not ready for routing, "
|
||||
"Error reported is '%s'.",
|
||||
buf)));
|
||||
if (error != 0)
|
||||
{
|
||||
strerror_r(error, buf, 100);
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Hangup in session that is not ready for routing, "
|
||||
"Error reported is '%s'.",
|
||||
buf)));
|
||||
}
|
||||
}
|
||||
gwbuf_free(errbuf);
|
||||
goto retblock;
|
||||
@ -1312,7 +1329,7 @@ static int gw_change_user(
|
||||
|
||||
/* now get the user, after 4 bytes header and 1 byte command */
|
||||
client_auth_packet += 5;
|
||||
strcpy(username, (char *)client_auth_packet);
|
||||
strncpy(username, (char *)client_auth_packet,MYSQL_USER_MAXLEN);
|
||||
client_auth_packet += strlen(username) + 1;
|
||||
|
||||
/* get the auth token len */
|
||||
@ -1333,7 +1350,7 @@ static int gw_change_user(
|
||||
}
|
||||
|
||||
/* get new database name */
|
||||
strcpy(database, (char *)client_auth_packet);
|
||||
strncpy(database, (char *)client_auth_packet,MYSQL_DATABASE_MAXLEN);
|
||||
|
||||
/* get character set */
|
||||
if (strlen(database)) {
|
||||
@ -1346,7 +1363,7 @@ static int gw_change_user(
|
||||
memcpy(&backend_protocol->charset, client_auth_packet, sizeof(int));
|
||||
|
||||
/* save current_database name */
|
||||
strcpy(current_database, current_session->db);
|
||||
strncpy(current_database, current_session->db,MYSQL_DATABASE_MAXLEN);
|
||||
|
||||
/*
|
||||
* Now clear database name in dcb as we don't do local authentication on db name for change user.
|
||||
|
||||
@ -214,12 +214,12 @@ int gw_read_backend_handshake(
|
||||
|
||||
if (h_len <= 4) {
|
||||
/* log error this exit point */
|
||||
conn->protocol_auth_state = MYSQL_AUTH_FAILED;
|
||||
conn->protocol_auth_state = MYSQL_HANDSHAKE_FAILED;
|
||||
LOGIF(LD, (skygw_log_write(
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [gw_read_backend_handshake] after "
|
||||
"dcb_read, fd %d, "
|
||||
"state = MYSQL_AUTH_FAILED.",
|
||||
"state = MYSQL_HANDSHAKE_FAILED.",
|
||||
dcb->fd,
|
||||
pthread_self())));
|
||||
|
||||
@ -232,6 +232,8 @@ int gw_read_backend_handshake(
|
||||
uint16_t errcode = MYSQL_GET_ERRCODE(payload);
|
||||
char* bufstr = strndup(&((char *)payload)[7], len-3);
|
||||
|
||||
conn->protocol_auth_state = MYSQL_HANDSHAKE_FAILED;
|
||||
|
||||
LOGIF(LD, (skygw_log_write(
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [gw_receive_backend_auth] Invalid "
|
||||
@ -261,12 +263,14 @@ int gw_read_backend_handshake(
|
||||
* data in buffer less than expected in the
|
||||
* packet. Log error this exit point
|
||||
*/
|
||||
conn->protocol_auth_state = MYSQL_AUTH_FAILED;
|
||||
|
||||
conn->protocol_auth_state = MYSQL_HANDSHAKE_FAILED;
|
||||
|
||||
LOGIF(LD, (skygw_log_write(
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [gw_read_backend_handshake] after "
|
||||
"gw_mysql_get_byte3, fd %d, "
|
||||
"state = MYSQL_AUTH_FAILED.",
|
||||
"state = MYSQL_HANDSHAKE_FAILED.",
|
||||
pthread_self(),
|
||||
dcb->fd,
|
||||
pthread_self())));
|
||||
@ -285,12 +289,13 @@ int gw_read_backend_handshake(
|
||||
* we cannot continue
|
||||
* log error this exit point
|
||||
*/
|
||||
conn->protocol_auth_state = MYSQL_AUTH_FAILED;
|
||||
conn->protocol_auth_state = MYSQL_HANDSHAKE_FAILED;
|
||||
|
||||
LOGIF(LD, (skygw_log_write(
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [gw_read_backend_handshake] after "
|
||||
"gw_decode_mysql_server_handshake, fd %d, "
|
||||
"state = MYSQL_AUTH_FAILED.",
|
||||
"state = MYSQL_HANDSHAKE_FAILED.",
|
||||
pthread_self(),
|
||||
conn->owner_dcb->fd,
|
||||
pthread_self())));
|
||||
@ -577,8 +582,8 @@ int gw_send_authentication_to_backend(
|
||||
dcb = conn->owner_dcb;
|
||||
final_capabilities = gw_mysql_get_byte4((uint8_t *)&server_capabilities);
|
||||
|
||||
/** Copy client's flags to backend */
|
||||
final_capabilities |= conn->client_capabilities;
|
||||
/** Copy client's flags to backend but with the known capabilities mask */
|
||||
final_capabilities |= (conn->client_capabilities & GW_MYSQL_CAPABILITIES_CLIENT);
|
||||
|
||||
/* get charset the client sent and use it for connection auth */
|
||||
charset = conn->charset;
|
||||
@ -964,7 +969,7 @@ GWBUF* mysql_create_custom_error(
|
||||
const char* msg)
|
||||
{
|
||||
uint8_t* outbuf = NULL;
|
||||
uint8_t mysql_payload_size = 0;
|
||||
uint32_t mysql_payload_size = 0;
|
||||
uint8_t mysql_packet_header[4];
|
||||
uint8_t* mysql_payload = NULL;
|
||||
uint8_t field_count = 0;
|
||||
@ -1574,7 +1579,7 @@ mysql_send_auth_error (
|
||||
const char *mysql_message)
|
||||
{
|
||||
uint8_t *outbuf = NULL;
|
||||
uint8_t mysql_payload_size = 0;
|
||||
uint32_t mysql_payload_size = 0;
|
||||
uint8_t mysql_packet_header[4];
|
||||
uint8_t *mysql_payload = NULL;
|
||||
uint8_t field_count = 0;
|
||||
|
||||
@ -1212,24 +1212,27 @@ static bool get_dcb(
|
||||
* backend and update assign it to new candidate if
|
||||
* necessary.
|
||||
*/
|
||||
else if (max_rlag == MAX_RLAG_UNDEFINED ||
|
||||
else if (SERVER_IS_SLAVE(b->backend_server))
|
||||
{
|
||||
if (max_rlag == MAX_RLAG_UNDEFINED ||
|
||||
(b->backend_server->rlag != MAX_RLAG_NOT_AVAILABLE &&
|
||||
b->backend_server->rlag <= max_rlag))
|
||||
{
|
||||
candidate_bref = check_candidate_bref(
|
||||
candidate_bref,
|
||||
&backend_ref[i],
|
||||
rses->rses_config.rw_slave_select_criteria);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGIF(LT, (skygw_log_write(
|
||||
LOGFILE_TRACE,
|
||||
"Server %s:%d is too much behind the "
|
||||
"master, %d s. and can't be chosen.",
|
||||
b->backend_server->name,
|
||||
b->backend_server->port,
|
||||
b->backend_server->rlag)));
|
||||
{
|
||||
candidate_bref = check_candidate_bref(
|
||||
candidate_bref,
|
||||
&backend_ref[i],
|
||||
rses->rses_config.rw_slave_select_criteria);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGIF(LT, (skygw_log_write(
|
||||
LOGFILE_TRACE,
|
||||
"Server %s:%d is too much behind the "
|
||||
"master, %d s. and can't be chosen.",
|
||||
b->backend_server->name,
|
||||
b->backend_server->port,
|
||||
b->backend_server->rlag)));
|
||||
}
|
||||
}
|
||||
} /*< for */
|
||||
/** Assign selected DCB's pointer value */
|
||||
@ -1473,6 +1476,12 @@ static route_target_t get_route_target (
|
||||
QUERY_IS_TYPE(qtype, QUERY_TYPE_UNKNOWN)));
|
||||
target = TARGET_MASTER;
|
||||
}
|
||||
#if defined(SS_EXTRA_DEBUG)
|
||||
LOGIF(LT, (skygw_log_write(
|
||||
LOGFILE_TRACE,
|
||||
"Selected target \"%s\"",
|
||||
STRTARGET(target))));
|
||||
#endif
|
||||
return target;
|
||||
}
|
||||
|
||||
@ -2106,7 +2115,7 @@ static int routeQuery(
|
||||
rlag_max)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (TARGET_IS_SLAVE(route_target))
|
||||
{
|
||||
btype = BE_SLAVE;
|
||||
@ -2125,6 +2134,14 @@ static int routeQuery(
|
||||
rlag_max);
|
||||
if (succp)
|
||||
{
|
||||
#if defined(SS_EXTRA_DEBUG)
|
||||
LOGIF(LT, (skygw_log_write(LOGFILE_TRACE,
|
||||
"Found DCB for slave.")));
|
||||
#endif
|
||||
ss_dassert(get_bref_from_dcb(router_cli_ses, target_dcb) !=
|
||||
router_cli_ses->rses_master_ref);
|
||||
ss_dassert(get_root_master_bref(router_cli_ses) ==
|
||||
router_cli_ses->rses_master_ref);
|
||||
atomic_add(&inst->stats.n_slave, 1);
|
||||
}
|
||||
else
|
||||
@ -2189,7 +2206,7 @@ static int routeQuery(
|
||||
|
||||
LOGIF(LT, (skygw_log_write(
|
||||
LOGFILE_TRACE,
|
||||
"Route query to %s\t%s:%d <",
|
||||
"Route query to %s \t%s:%d <",
|
||||
(SERVER_IS_MASTER(bref->bref_backend->backend_server) ?
|
||||
"master" : "slave"),
|
||||
bref->bref_backend->backend_server->name,
|
||||
@ -3933,12 +3950,12 @@ static bool route_session_write(
|
||||
{
|
||||
LOGIF(LT, (skygw_log_write(
|
||||
LOGFILE_TRACE,
|
||||
"Route query to %s\t%s:%d%s",
|
||||
"Route query to %s \t%s:%d%s",
|
||||
(SERVER_IS_MASTER(backend_ref[i].bref_backend->backend_server) ?
|
||||
"master" : "slave"),
|
||||
backend_ref[i].bref_backend->backend_server->name,
|
||||
backend_ref[i].bref_backend->backend_server->port,
|
||||
(i+1==router_cli_ses->rses_nbackends ? " <" : ""))));
|
||||
(i+1==router_cli_ses->rses_nbackends ? " <" : " "))));
|
||||
}
|
||||
|
||||
if (BREF_IS_IN_USE((&backend_ref[i])))
|
||||
@ -3988,12 +4005,12 @@ static bool route_session_write(
|
||||
{
|
||||
LOGIF(LT, (skygw_log_write(
|
||||
LOGFILE_TRACE,
|
||||
"Route query to %s\t%s:%d%s",
|
||||
"Route query to %s \t%s:%d%s",
|
||||
(SERVER_IS_MASTER(backend_ref[i].bref_backend->backend_server) ?
|
||||
"master" : "slave"),
|
||||
backend_ref[i].bref_backend->backend_server->name,
|
||||
backend_ref[i].bref_backend->backend_server->port,
|
||||
(i+1==router_cli_ses->rses_nbackends ? " <" : ""))));
|
||||
(i+1==router_cli_ses->rses_nbackends ? " <" : " "))));
|
||||
}
|
||||
|
||||
scur = backend_ref_get_sescmd_cursor(&backend_ref[i]);
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
#!/bin/sh
|
||||
#!/bin/bash
|
||||
NARGS=7
|
||||
TLOG=$1
|
||||
THOST=$2
|
||||
|
||||
Reference in New Issue
Block a user