mirror of
https://gitee.com/wangbin579/cetus.git
synced 2024-11-30 02:47:35 +08:00
Don't send large contents to client in one time
This commit is contained in:
commit
a3d249c6a2
@ -278,6 +278,12 @@ proxy_c_read_query_result(network_mysqld_con *con)
|
||||
break;
|
||||
}
|
||||
|
||||
if (inj->id > INJ_ID_COM_STMT_PREPARE && inj->id < INJ_ID_RESET_CONNECTION) {
|
||||
if (res->qstat.query_status == MYSQLD_PACKET_ERR) {
|
||||
con->resp_err_met = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (is_continue) {
|
||||
if (res->qstat.query_status) {
|
||||
if (con->is_in_transaction) {
|
||||
|
@ -135,7 +135,6 @@ chassis_event_loop(chassis_event_loop_t *loop, int *mutex)
|
||||
}
|
||||
}
|
||||
|
||||
g_debug("%s: leave chassis_event_loop", G_STRLOC);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
@ -454,6 +454,7 @@ network_mysqld_proto_get_com_init_db(network_packet *packet,
|
||||
switch (status) {
|
||||
case MYSQLD_PACKET_ERR:
|
||||
is_finished = 1;
|
||||
con->resp_err_met = 1;
|
||||
if (udata->db_name && udata->db_name->len) {
|
||||
g_message("%s: COM_INIT_DB failed, want db:%s, client default db still:%s",
|
||||
G_STRLOC, udata->db_name->str, con->client->default_db->str);
|
||||
@ -487,6 +488,7 @@ network_mysqld_proto_get_com_init_db(network_packet *packet,
|
||||
break;
|
||||
default:
|
||||
g_critical("%s: COM_INIT_DB should be (ERR|OK), got %02x", G_STRLOC, status);
|
||||
con->resp_err_met = 1;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
@ -903,6 +903,8 @@ disp_err_packet(network_mysqld_con *con, network_packet *packet)
|
||||
packet->offset = NET_HEADER_SIZE;
|
||||
err_packet = network_mysqld_err_packet_new();
|
||||
|
||||
con->resp_err_met = 1;
|
||||
|
||||
if (!network_mysqld_proto_get_err_packet(packet, err_packet)) {
|
||||
g_message("%s: dst:%s, sql:%s, errmsg:%s",
|
||||
G_STRLOC, con->server->dst->name->str, con->orig_sql->str, err_packet->errmsg->str);
|
||||
@ -2742,6 +2744,7 @@ handle_send_query_to_servers(network_mysqld_con *con, network_mysqld_con_state_t
|
||||
con->cur_resp_len = 0;
|
||||
con->eof_met_cnt = 0;
|
||||
con->partically_record_left_cnt = 0;
|
||||
con->resp_err_met = 0;
|
||||
|
||||
/*
|
||||
* send the query to the server
|
||||
@ -3296,7 +3299,18 @@ disp_attr(network_mysqld_con *con, int srv_down_count, int *disp_flag)
|
||||
|
||||
*disp_flag = DISP_CONTINUE;
|
||||
return 0;
|
||||
|
||||
} else if (con->resp_err_met) {
|
||||
con->state = ST_SEND_QUERY_RESULT;
|
||||
network_queue_clear(con->client->send_queue);
|
||||
network_mysqld_con_send_error_full(con->client, C("adjust connection attribute failed"), ER_CETUS_UNKNOWN, "HY000");
|
||||
g_warning("%s: adjust connection attribute failed for con:%p, attr state:%d, src:%s",
|
||||
G_STRLOC, con, con->attr_adj_state, con->client->src->name->str);
|
||||
remove_mul_server_recv_packets(con);
|
||||
network_queue_clear(con->client->recv_queue);
|
||||
network_mysqld_queue_reset(con->client);
|
||||
con->server_to_be_closed = 1;
|
||||
*disp_flag = DISP_CONTINUE;
|
||||
return 0;
|
||||
} else {
|
||||
if (build_attr_statements(con)) {
|
||||
g_debug("%s: continue here:%d", G_STRLOC, con->state);
|
||||
|
@ -574,6 +574,7 @@ struct network_mysqld_con {
|
||||
unsigned int is_processed_by_subordinate:1;
|
||||
unsigned int is_admin_client:1;
|
||||
unsigned int is_admin_waiting_resp:1;
|
||||
unsigned int resp_err_met:1;
|
||||
unsigned int direct_answer:1;
|
||||
unsigned int admin_read_merge:1;
|
||||
unsigned int ask_one_worker:1;
|
||||
|
@ -682,6 +682,7 @@ network_socket_write_writev(network_socket *con, int send_chunks)
|
||||
|
||||
iov = g_new0(struct iovec, chunk_count);
|
||||
|
||||
int aggr_len = 0;
|
||||
for (chunk = send_queue->chunks->head, chunk_id = 0;
|
||||
chunk && chunk_id < chunk_count; chunk_id++, chunk = chunk->next) {
|
||||
GString *s = chunk->data;
|
||||
@ -696,6 +697,12 @@ network_socket_write_writev(network_socket *con, int send_chunks)
|
||||
iov[chunk_id].iov_len = s->len;
|
||||
}
|
||||
|
||||
aggr_len += iov[chunk_id].iov_len;
|
||||
if (aggr_len >= 65536) {
|
||||
chunk_id++;
|
||||
break;
|
||||
}
|
||||
|
||||
if (s->len == 0) {
|
||||
g_warning("%s: s->len is zero", G_STRLOC);
|
||||
}
|
||||
@ -704,8 +711,8 @@ network_socket_write_writev(network_socket *con, int send_chunks)
|
||||
g_debug("%s: network socket:%p, send (src:%s, dst:%s) fd:%d",
|
||||
G_STRLOC, con, con->src->name->str, con->dst->name->str, con->fd);
|
||||
|
||||
len = writev(con->fd, iov, chunk_count);
|
||||
g_debug("%s: tcp write:%d, chunk count:%d", G_STRLOC, (int)len, (int)chunk_count);
|
||||
len = writev(con->fd, iov, chunk_id);
|
||||
g_debug("%s: tcp write:%d, chunk count:%d", G_STRLOC, (int)len, (int)chunk_id);
|
||||
os_errno = errno;
|
||||
|
||||
g_free(iov);
|
||||
|
Loading…
Reference in New Issue
Block a user