Merge branch 'release-1.0beta' of https://github.com/skysql/MaxScale into release-1.0beta
Conflicts: server/modules/protocol/mysql_common.c
This commit is contained in:
commit
dcb2070736
@ -255,11 +255,7 @@ static int logmanager_write_log(
|
||||
static blockbuf_t* blockbuf_init(logfile_id_t id);
|
||||
static void blockbuf_node_done(void* bb_data);
|
||||
static char* blockbuf_get_writepos(
|
||||
#if 0
|
||||
int** refcount,
|
||||
#else
|
||||
blockbuf_t** p_bb,
|
||||
#endif
|
||||
logfile_id_t id,
|
||||
size_t str_len,
|
||||
bool flush);
|
||||
@ -653,7 +649,16 @@ static int logmanager_write_log(
|
||||
int safe_str_len;
|
||||
|
||||
timestamp_len = get_timestamp_len();
|
||||
safe_str_len = MIN(timestamp_len-1+str_len, lf->lf_buf_size);
|
||||
|
||||
/** Findout how much can be safely written with current block size */
|
||||
if (timestamp_len-1+str_len > lf->lf_buf_size)
|
||||
{
|
||||
safe_str_len = lf->lf_buf_size;
|
||||
}
|
||||
else
|
||||
{
|
||||
safe_str_len = timestamp_len-1+str_len;
|
||||
}
|
||||
/**
|
||||
* Seek write position and register to block buffer.
|
||||
* Then print formatted string to write position.
|
||||
@ -673,9 +678,9 @@ static int logmanager_write_log(
|
||||
* of the timestamp string.
|
||||
*/
|
||||
if (use_valist) {
|
||||
vsnprintf(wp+timestamp_len, safe_str_len, str, valist);
|
||||
vsnprintf(wp+timestamp_len, safe_str_len-timestamp_len, str, valist);
|
||||
} else {
|
||||
snprintf(wp+timestamp_len, safe_str_len, "%s", str);
|
||||
snprintf(wp+timestamp_len, safe_str_len-timestamp_len, "%s", str);
|
||||
}
|
||||
|
||||
/** write to syslog */
|
||||
@ -694,12 +699,7 @@ static int logmanager_write_log(
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/** remove double line feed */
|
||||
if (wp[timestamp_len+str_len-2] == '\n') {
|
||||
wp[timestamp_len+str_len-2]=' ';
|
||||
}
|
||||
wp[timestamp_len+str_len-1]='\n';
|
||||
wp[safe_str_len-1] = '\n';
|
||||
blockbuf_unregister(bb);
|
||||
|
||||
/**
|
||||
|
@ -814,6 +814,8 @@ int below_water;
|
||||
}
|
||||
|
||||
spinlock_acquire(&dcb->writeqlock);
|
||||
|
||||
ss_dassert(dcb->state != DCB_STATE_ZOMBIE);
|
||||
|
||||
if (dcb->writeq != NULL)
|
||||
{
|
||||
@ -978,9 +980,10 @@ int below_water;
|
||||
}
|
||||
if (dolog)
|
||||
{
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Writing to %s socket failed due %d, %s.",
|
||||
LOGIF(LD, (skygw_log_write(
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [dcb_write] Writing to %s socket failed due %d, %s.",
|
||||
pthread_self(),
|
||||
dcb_isclient(dcb) ? "client" : "backend server",
|
||||
saved_errno,
|
||||
strerror(saved_errno))));
|
||||
|
@ -145,9 +145,9 @@ typedef enum {
|
||||
DCB_STATE_POLLING, /*< Waiting in the poll loop */
|
||||
DCB_STATE_LISTENING, /*< The DCB is for a listening socket */
|
||||
DCB_STATE_DISCONNECTED, /*< The socket is now closed */
|
||||
DCB_STATE_FREED, /*< Memory freed */
|
||||
DCB_STATE_NOPOLLING, /*< Removed from poll mask */
|
||||
DCB_STATE_ZOMBIE /*< DCB is no longer active, waiting to free it */
|
||||
DCB_STATE_ZOMBIE, /*< DCB is no longer active, waiting to free it */
|
||||
DCB_STATE_FREED /*< Memory freed */
|
||||
} dcb_state_t;
|
||||
|
||||
typedef enum {
|
||||
|
@ -102,6 +102,12 @@ typedef enum {
|
||||
MYSQL_IDLE
|
||||
} mysql_auth_state_t;
|
||||
|
||||
typedef enum {
|
||||
MYSQL_PROTOCOL_ALLOC,
|
||||
MYSQL_PROTOCOL_ACTIVE,
|
||||
MYSQL_PROTOCOL_DONE
|
||||
} mysql_protocol_state_t;
|
||||
|
||||
|
||||
/*
|
||||
* MySQL session specific data
|
||||
@ -270,6 +276,7 @@ typedef struct {
|
||||
server_command_t protocol_command; /*< session command list */
|
||||
server_command_t* protocol_cmd_history; /*< session command history */
|
||||
mysql_auth_state_t protocol_auth_state; /*< Authentication status */
|
||||
mysql_protocol_state_t protocol_state; /*< Protocol struct status */
|
||||
uint8_t scramble[MYSQL_SCRAMBLE_LEN]; /*< server scramble,
|
||||
* created or received */
|
||||
uint32_t server_capabilities; /*< server capabilities,
|
||||
|
@ -762,12 +762,13 @@ return_rc:
|
||||
*/
|
||||
static int gw_error_backend_event(DCB *dcb)
|
||||
{
|
||||
SESSION* session;
|
||||
void* rsession;
|
||||
ROUTER_OBJECT* router;
|
||||
ROUTER* router_instance;
|
||||
GWBUF* errbuf;
|
||||
bool succp;
|
||||
SESSION* session;
|
||||
void* rsession;
|
||||
ROUTER_OBJECT* router;
|
||||
ROUTER* router_instance;
|
||||
GWBUF* errbuf;
|
||||
bool succp;
|
||||
session_state_t ses_state;
|
||||
|
||||
CHK_DCB(dcb);
|
||||
session = dcb->session;
|
||||
@ -776,18 +777,13 @@ static int gw_error_backend_event(DCB *dcb)
|
||||
router = session->service->router;
|
||||
router_instance = session->service->router_instance;
|
||||
|
||||
#if defined(SS_DEBUG)
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Backend error event handling.")));
|
||||
#endif
|
||||
/**
|
||||
* Avoid running redundant error handling procedure.
|
||||
* dcb_close is already called for the DCB. Thus, either connection is
|
||||
* closed by router and COM_QUIT sent or there was an error which
|
||||
* have already been handled.
|
||||
*/
|
||||
if (dcb->session != DCB_STATE_POLLING)
|
||||
if (dcb->state != DCB_STATE_POLLING)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
@ -796,6 +792,34 @@ static int gw_error_backend_event(DCB *dcb)
|
||||
0,
|
||||
"Lost connection to backend server.");
|
||||
|
||||
spinlock_acquire(&session->ses_lock);
|
||||
ses_state = session->state;
|
||||
spinlock_release(&session->ses_lock);
|
||||
|
||||
/**
|
||||
* Session might be initialized when DCB already is in the poll set.
|
||||
* Thus hangup can occur in the middle of session initialization.
|
||||
* Only complete and successfully initialized sessions allow for
|
||||
* calling error handler.
|
||||
*/
|
||||
while (ses_state == SESSION_STATE_READY)
|
||||
{
|
||||
spinlock_acquire(&session->ses_lock);
|
||||
ses_state = session->state;
|
||||
spinlock_release(&session->ses_lock);
|
||||
}
|
||||
|
||||
if (ses_state != SESSION_STATE_ROUTER_READY)
|
||||
{
|
||||
gwbuf_free(errbuf);
|
||||
goto retblock;
|
||||
}
|
||||
|
||||
#if defined(SS_DEBUG)
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Backend error event handling.")));
|
||||
#endif
|
||||
router->handleError(router_instance,
|
||||
rsession,
|
||||
errbuf,
|
||||
@ -811,6 +835,7 @@ static int gw_error_backend_event(DCB *dcb)
|
||||
}
|
||||
dcb_close(dcb);
|
||||
|
||||
retblock:
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -924,12 +949,13 @@ return_fd:
|
||||
static int
|
||||
gw_backend_hangup(DCB *dcb)
|
||||
{
|
||||
SESSION* session;
|
||||
void* rsession;
|
||||
ROUTER_OBJECT* router;
|
||||
ROUTER* router_instance;
|
||||
bool succp;
|
||||
GWBUF* errbuf;
|
||||
SESSION* session;
|
||||
void* rsession;
|
||||
ROUTER_OBJECT* router;
|
||||
ROUTER* router_instance;
|
||||
bool succp;
|
||||
GWBUF* errbuf;
|
||||
session_state_t ses_state;
|
||||
|
||||
CHK_DCB(dcb);
|
||||
session = dcb->session;
|
||||
@ -937,20 +963,41 @@ gw_backend_hangup(DCB *dcb)
|
||||
|
||||
rsession = session->router_session;
|
||||
router = session->service->router;
|
||||
router_instance = session->service->router_instance;
|
||||
|
||||
router_instance = session->service->router_instance;
|
||||
|
||||
errbuf = mysql_create_custom_error(
|
||||
1,
|
||||
0,
|
||||
"Lost connection to backend server.");
|
||||
|
||||
spinlock_acquire(&session->ses_lock);
|
||||
ses_state = session->state;
|
||||
spinlock_release(&session->ses_lock);
|
||||
|
||||
/**
|
||||
* Session might be initialized when DCB already is in the poll set.
|
||||
* Thus hangup can occur in the middle of session initialization.
|
||||
* Only complete and successfully initialized sessions allow for
|
||||
* calling error handler.
|
||||
*/
|
||||
while (ses_state == SESSION_STATE_READY)
|
||||
{
|
||||
spinlock_acquire(&session->ses_lock);
|
||||
ses_state = session->state;
|
||||
spinlock_release(&session->ses_lock);
|
||||
}
|
||||
|
||||
if (ses_state != SESSION_STATE_ROUTER_READY)
|
||||
{
|
||||
gwbuf_free(errbuf);
|
||||
goto retblock;
|
||||
}
|
||||
#if defined(SS_DEBUG)
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Backend hangup error handling.")));
|
||||
#endif
|
||||
|
||||
|
||||
errbuf = mysql_create_custom_error(
|
||||
1,
|
||||
0,
|
||||
"Lost connection to backend server.");
|
||||
|
||||
router->handleError(router_instance,
|
||||
rsession,
|
||||
errbuf,
|
||||
@ -959,7 +1006,8 @@ gw_backend_hangup(DCB *dcb)
|
||||
&succp);
|
||||
|
||||
/** There are not required backends available, close session. */
|
||||
if (!succp) {
|
||||
if (!succp)
|
||||
{
|
||||
#if defined(SS_DEBUG)
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
@ -972,7 +1020,8 @@ gw_backend_hangup(DCB *dcb)
|
||||
}
|
||||
dcb_close(dcb);
|
||||
|
||||
return 1;
|
||||
retblock:
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -65,7 +65,7 @@ static int gw_client_hangup_event(DCB *dcb);
|
||||
int mysql_send_ok(DCB *dcb, int packet_number, int in_affected_rows, const char* mysql_message);
|
||||
int MySQLSendHandshake(DCB* dcb);
|
||||
static int gw_mysql_do_authentication(DCB *dcb, GWBUF *queue);
|
||||
static int route_by_statement(SESSION *, GWBUF *);
|
||||
static int route_by_statement(SESSION *, GWBUF **);
|
||||
|
||||
/*
|
||||
* The "module object" for the mysqld client protocol module.
|
||||
@ -534,7 +534,7 @@ int gw_read_client_event(
|
||||
if (nbytes_read == 0)
|
||||
{
|
||||
goto return_rc;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* if read queue existed appent read to it.
|
||||
* if length of read buffer is less than 3 or less than mysql packet
|
||||
@ -783,7 +783,7 @@ int gw_read_client_event(
|
||||
* Feed each statement completely and separately
|
||||
* to router.
|
||||
*/
|
||||
rc = route_by_statement(session, read_buffer);
|
||||
rc = route_by_statement(session, &read_buffer);
|
||||
|
||||
if (read_buffer != NULL)
|
||||
{
|
||||
@ -1300,12 +1300,19 @@ static int gw_error_client_event(
|
||||
STRDCBSTATE(dcb->state),
|
||||
(session != NULL ? session : NULL))));
|
||||
|
||||
if (session != NULL && session->state == SESSION_STATE_STOPPING)
|
||||
{
|
||||
goto retblock;
|
||||
}
|
||||
|
||||
#if defined(SS_DEBUG)
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Client error event handling.")));
|
||||
#endif
|
||||
dcb_close(dcb);
|
||||
|
||||
retblock:
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -1380,12 +1387,19 @@ gw_client_hangup_event(DCB *dcb)
|
||||
{
|
||||
CHK_SESSION(session);
|
||||
}
|
||||
|
||||
if (session != NULL && session->state == SESSION_STATE_STOPPING)
|
||||
{
|
||||
goto retblock;
|
||||
}
|
||||
#if defined(SS_DEBUG)
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Client hangup error handling.")));
|
||||
"Client hangup error handling.")));
|
||||
#endif
|
||||
dcb_close(dcb);
|
||||
|
||||
retblock:
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -1399,7 +1413,9 @@ gw_client_hangup_event(DCB *dcb)
|
||||
* Return 1 in success. If the last packet is incomplete return success but
|
||||
* leave incomplete packet to readbuf.
|
||||
*/
|
||||
static int route_by_statement(SESSION *session, GWBUF *readbuf)
|
||||
static int route_by_statement(
|
||||
SESSION* session,
|
||||
GWBUF** p_readbuf)
|
||||
{
|
||||
int rc = -1;
|
||||
GWBUF* packetbuf;
|
||||
@ -1407,7 +1423,7 @@ static int route_by_statement(SESSION *session, GWBUF *readbuf)
|
||||
gwbuf_type_t prevtype;
|
||||
GWBUF* tmpbuf;
|
||||
|
||||
tmpbuf = readbuf;
|
||||
tmpbuf = *p_readbuf;
|
||||
while (tmpbuf != NULL)
|
||||
{
|
||||
ss_dassert(GWBUF_IS_TYPE_MYSQL(tmpbuf));
|
||||
@ -1416,15 +1432,14 @@ static int route_by_statement(SESSION *session, GWBUF *readbuf)
|
||||
#endif
|
||||
do
|
||||
{
|
||||
ss_dassert(GWBUF_IS_TYPE_MYSQL(readbuf));
|
||||
ss_dassert(GWBUF_IS_TYPE_MYSQL((*p_readbuf)));
|
||||
|
||||
packetbuf = gw_MySQL_get_next_packet(&readbuf);
|
||||
|
||||
ss_dassert(GWBUF_IS_TYPE_MYSQL(packetbuf));
|
||||
packetbuf = gw_MySQL_get_next_packet(p_readbuf);
|
||||
|
||||
if (packetbuf != NULL)
|
||||
{
|
||||
CHK_GWBUF(packetbuf);
|
||||
ss_dassert(GWBUF_IS_TYPE_MYSQL(packetbuf));
|
||||
/**
|
||||
* This means that buffer includes exactly one MySQL
|
||||
* statement.
|
||||
@ -1447,7 +1462,7 @@ static int route_by_statement(SESSION *session, GWBUF *readbuf)
|
||||
goto return_rc;
|
||||
}
|
||||
}
|
||||
while (readbuf != NULL);
|
||||
while (*p_readbuf != NULL);
|
||||
|
||||
return_rc:
|
||||
return rc;
|
||||
|
@ -79,6 +79,7 @@ MySQLProtocol* mysql_protocol_init(
|
||||
strerror(eno))));
|
||||
goto return_p;
|
||||
}
|
||||
p->protocol_state = MYSQL_PROTOCOL_ALLOC;
|
||||
p->protocol_auth_state = MYSQL_ALLOC;
|
||||
p->protocol_command.scom_cmd = MYSQL_COM_UNDEFINED;
|
||||
p->protocol_command.scom_nresponse_packets = 0;
|
||||
@ -90,6 +91,7 @@ MySQLProtocol* mysql_protocol_init(
|
||||
/*< Assign fd with protocol */
|
||||
p->fd = fd;
|
||||
p->owner_dcb = dcb;
|
||||
p->protocol_state = MYSQL_PROTOCOL_ACTIVE;
|
||||
CHK_PROTOCOL(p);
|
||||
return_p:
|
||||
return p;
|
||||
@ -107,15 +109,30 @@ return_p:
|
||||
void mysql_protocol_done (
|
||||
DCB* dcb)
|
||||
{
|
||||
server_command_t* scmd = ((MySQLProtocol *)dcb->protocol)->protocol_cmd_history;
|
||||
MySQLProtocol* p;
|
||||
server_command_t* scmd;
|
||||
server_command_t* scmd2;
|
||||
|
||||
p = (MySQLProtocol *)dcb->protocol;
|
||||
|
||||
spinlock_acquire(&p->protocol_lock);
|
||||
|
||||
if (p->protocol_state != MYSQL_PROTOCOL_ACTIVE)
|
||||
{
|
||||
goto retblock;
|
||||
}
|
||||
scmd = p->protocol_cmd_history;
|
||||
|
||||
while (scmd != NULL)
|
||||
{
|
||||
scmd2 = scmd->scom_next;
|
||||
free(scmd);
|
||||
scmd = scmd2;
|
||||
}
|
||||
p->protocol_state = MYSQL_PROTOCOL_DONE;
|
||||
|
||||
retblock:
|
||||
spinlock_release(&p->protocol_lock);
|
||||
}
|
||||
|
||||
|
||||
@ -886,7 +903,7 @@ int mysql_send_com_quit(
|
||||
if (buf == NULL)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
nbytes = dcb->func.write(dcb, buf);
|
||||
|
||||
return nbytes;
|
||||
@ -1497,6 +1514,9 @@ GWBUF* gw_MySQL_get_next_packet(
|
||||
size_t packetlen;
|
||||
size_t totalbuflen;
|
||||
uint8_t* data;
|
||||
size_t nbytes_copied = 0;
|
||||
uint8_t* target;
|
||||
|
||||
readbuf = *p_readbuf;
|
||||
|
||||
if (readbuf == NULL)
|
||||
@ -1523,42 +1543,27 @@ GWBUF* gw_MySQL_get_next_packet(
|
||||
packetbuf = NULL;
|
||||
goto return_packetbuf;
|
||||
}
|
||||
/** there is one complete packet in the buffer */
|
||||
if (packetlen == buflen)
|
||||
{
|
||||
packetbuf = gwbuf_clone_portion(readbuf, 0, packetlen);
|
||||
*p_readbuf = gwbuf_consume(readbuf, packetlen);
|
||||
goto return_packetbuf;
|
||||
}
|
||||
|
||||
packetbuf = gwbuf_alloc(packetlen);
|
||||
target = GWBUF_DATA(packetbuf);
|
||||
packetbuf->gwbuf_type = readbuf->gwbuf_type; /*< Copy the type too */
|
||||
/**
|
||||
* Packet spans multiple buffers.
|
||||
* Allocate buffer for complete packet
|
||||
* copy packet parts into it and consume copied bytes
|
||||
*/
|
||||
else if (packetlen > buflen)
|
||||
* Copy first MySQL packet to packetbuf and leave posible other
|
||||
* packets to read buffer.
|
||||
*/
|
||||
while (nbytes_copied < packetlen && totalbuflen > 0)
|
||||
{
|
||||
size_t nbytes_copied = 0;
|
||||
uint8_t* target;
|
||||
uint8_t* src = GWBUF_DATA((*p_readbuf));
|
||||
size_t bytestocopy;
|
||||
|
||||
packetbuf = gwbuf_alloc(packetlen);
|
||||
target = GWBUF_DATA(packetbuf);
|
||||
|
||||
while (nbytes_copied < packetlen)
|
||||
{
|
||||
uint8_t* src = GWBUF_DATA(readbuf);
|
||||
size_t buflen = GWBUF_LENGTH(readbuf);
|
||||
|
||||
memcpy(target+nbytes_copied, src, buflen);
|
||||
*p_readbuf = gwbuf_consume(readbuf, buflen);
|
||||
nbytes_copied += buflen;
|
||||
}
|
||||
ss_dassert(nbytes_copied == packetlen);
|
||||
}
|
||||
else
|
||||
{
|
||||
packetbuf = gwbuf_clone_portion(readbuf, 0, packetlen);
|
||||
*p_readbuf = gwbuf_consume(readbuf, packetlen);
|
||||
bytestocopy = MIN(buflen,packetlen-nbytes_copied);
|
||||
|
||||
memcpy(target+nbytes_copied, src, bytestocopy);
|
||||
*p_readbuf = gwbuf_consume((*p_readbuf), bytestocopy);
|
||||
totalbuflen = gwbuf_length((*p_readbuf));
|
||||
nbytes_copied += bytestocopy;
|
||||
}
|
||||
ss_dassert(buflen == 0 || nbytes_copied == packetlen);
|
||||
|
||||
return_packetbuf:
|
||||
return packetbuf;
|
||||
@ -1625,11 +1630,16 @@ void protocol_archive_srv_command(
|
||||
MySQLProtocol* p)
|
||||
{
|
||||
server_command_t* s1;
|
||||
server_command_t** s2;
|
||||
server_command_t* h1;
|
||||
int len = 0;
|
||||
|
||||
spinlock_acquire(&p->protocol_lock);
|
||||
|
||||
if (p->protocol_state != MYSQL_PROTOCOL_ACTIVE)
|
||||
{
|
||||
goto retblock;
|
||||
}
|
||||
|
||||
s1 = &p->protocol_command;
|
||||
|
||||
LOGIF(LT, (skygw_log_write(
|
||||
@ -1639,18 +1649,19 @@ void protocol_archive_srv_command(
|
||||
p->owner_dcb->fd)));
|
||||
|
||||
/** Copy to history list */
|
||||
s2 = &p->protocol_cmd_history;
|
||||
|
||||
if (*s2 != NULL)
|
||||
{
|
||||
while ((*s2)->scom_next != NULL)
|
||||
{
|
||||
*s2 = (*s2)->scom_next;
|
||||
len += 1;
|
||||
}
|
||||
if ((h1 = p->protocol_cmd_history) == NULL)
|
||||
{
|
||||
p->protocol_cmd_history = server_command_copy(s1);
|
||||
}
|
||||
*s2 = server_command_copy(s1);
|
||||
|
||||
else
|
||||
{
|
||||
while (h1->scom_next != NULL)
|
||||
{
|
||||
h1 = h1->scom_next;
|
||||
}
|
||||
h1->scom_next = server_command_copy(s1);
|
||||
}
|
||||
|
||||
/** Keep history limits, remove oldest */
|
||||
if (len > MAX_CMD_HISTORY)
|
||||
{
|
||||
@ -1669,6 +1680,8 @@ void protocol_archive_srv_command(
|
||||
p->protocol_command = *(s1->scom_next);
|
||||
free(s1->scom_next);
|
||||
}
|
||||
|
||||
retblock:
|
||||
spinlock_release(&p->protocol_lock);
|
||||
}
|
||||
|
||||
@ -1685,6 +1698,10 @@ void protocol_add_srv_command(
|
||||
|
||||
spinlock_acquire(&p->protocol_lock);
|
||||
|
||||
if (p->protocol_state != MYSQL_PROTOCOL_ACTIVE)
|
||||
{
|
||||
goto retblock;
|
||||
}
|
||||
/** this is the only server command in protocol */
|
||||
if (p->protocol_command.scom_cmd == MYSQL_COM_UNDEFINED)
|
||||
{
|
||||
@ -1717,6 +1734,7 @@ void protocol_add_srv_command(
|
||||
c = c->scom_next;
|
||||
}
|
||||
#endif
|
||||
retblock:
|
||||
spinlock_release(&p->protocol_lock);
|
||||
}
|
||||
|
||||
|
@ -1548,8 +1548,10 @@ static void clientReply (
|
||||
(uint8_t *)GWBUF_DATA((scur->scmd_cur_cmd->my_sescmd_buf));
|
||||
size_t len = MYSQL_GET_PACKET_LEN(buf);
|
||||
char* cmdstr = (char *)malloc(len+1);
|
||||
/** data+termination character == len */
|
||||
snprintf(cmdstr, len, "%s", &buf[5]);
|
||||
|
||||
snprintf(cmdstr, len+1, "%s", &buf[5]);
|
||||
ss_dassert(len+4 == GWBUF_LENGTH(scur->scmd_cur_cmd->my_sescmd_buf));
|
||||
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
|
@ -230,3 +230,47 @@ if [ "$a" != "$TRETVAL" ]; then
|
||||
else
|
||||
echo "$TINPUT PASSED">>$TLOG ;
|
||||
fi
|
||||
echo "-----------------------------------" >> $TLOG
|
||||
echo "Session variables: Stress Test 1" >> $TLOG
|
||||
echo "-----------------------------------" >> $TLOG
|
||||
|
||||
RUNCMD=mysql\ --host=$THOST\ -P$TPORT\ -u$TUSER\ -p$TPWD\ --unbuffered=true\ --disable-reconnect\ -q\ -r
|
||||
TINPUT=test_sescmd2.sql
|
||||
for ((i = 0;i<1000;i++))
|
||||
do
|
||||
a=`$RUNCMD < $TINPUT 2>&1`
|
||||
if [[ "`echo "$a"|grep -i 'error'`" != "" ]]
|
||||
then
|
||||
err=`echo "$a" | grep -i error`
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [[ "$err" == "" ]]
|
||||
then
|
||||
echo "TEST PASSED" >> $TLOG
|
||||
else
|
||||
echo "$err" >> $TLOG
|
||||
echo "Test FAILED at iteration $((i+1))" >> $TLOG
|
||||
fi
|
||||
echo "-----------------------------------" >> $TLOG
|
||||
echo "Session variables: Stress Test 2" >> $TLOG
|
||||
echo "-----------------------------------" >> $TLOG
|
||||
|
||||
err=""
|
||||
TINPUT=test_sescmd3.sql
|
||||
for ((j = 0;j<1000;j++))
|
||||
do
|
||||
b=`$RUNCMD < $TINPUT 2>&1`
|
||||
if [[ "`echo "$b"|grep -i 'null'`" != "" ]]
|
||||
then
|
||||
err=`echo "$b" | grep -i null`
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [[ "$err" == "" ]]
|
||||
then
|
||||
echo "TEST PASSED" >> $TLOG
|
||||
else
|
||||
echo "Test FAILED at iteration $((j+1))" >> $TLOG
|
||||
fi
|
||||
echo "" >> $TLOG
|
||||
|
20
server/modules/routing/readwritesplit/test/test_sescmd2.sql
Normal file
20
server/modules/routing/readwritesplit/test/test_sescmd2.sql
Normal file
@ -0,0 +1,20 @@
|
||||
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
|
||||
/*!40101 SET NAMES utf8 */;
|
||||
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
|
||||
/*!40103 SET TIME_ZONE='+00:00' */;
|
||||
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
|
||||
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
|
||||
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
|
||||
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
|
||||
|
||||
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
|
||||
|
||||
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
|
||||
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
|
||||
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
|
||||
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
||||
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
|
16
server/modules/routing/readwritesplit/test/test_sescmd3.sql
Normal file
16
server/modules/routing/readwritesplit/test/test_sescmd3.sql
Normal file
@ -0,0 +1,16 @@
|
||||
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
|
||||
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
|
||||
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
|
||||
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
|
||||
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
|
||||
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
|
||||
select @OLD_SQL_NOTES;
|
||||
select @OLD_CHARACTER_SET_CLIENT;
|
||||
select @OLD_CHARACTER_SET_RESULTS;
|
||||
select @OLD_COLLATION_CONNECTION;
|
||||
select @OLD_TIME_ZONE;
|
||||
select @OLD_UNIQUE_CHECKS;
|
||||
select @OLD_FOREIGN_KEY_CHECKS;
|
||||
select @OLD_SQL_MODE;
|
Loading…
x
Reference in New Issue
Block a user