Limit the amount of data received by a backend

Issue #527
Limit the amount of data received by a backend during a single poll() iteration.
Right now the default is mysql_thread___threshold_resultset_size*2, and it is arbitary.

Unrelated to #527, MySQL_Connection::async_ping() was modified to return a different value in case of timeout
v1.2.0
René Cannaò 10 years ago
parent 17b7e1f609
commit f4c7df34cf

@ -944,8 +944,13 @@ handler_again:
set_status(NONE);
return -1;
} else {
if (rc==-1) {
proxy_error("Detected a broken connection during ping on %s , %d\n", myconn->parent->address, myconn->parent->port);
if (rc==-1 || rc==-2) {
if (rc==-2) {
proxy_error("Ping timeout during ping on %s , %d\n", myconn->parent->address, myconn->parent->port);
} else { // rc==-1
int myerr=mysql_errno(myconn->mysql);
proxy_error("Detected a broken connection during ping on (%d,%s,%d) , FD (Conn:%d , MyDS:%d) : %d, %s\n", myconn->parent->myhgc->hid, myconn->parent->address, myconn->parent->port, myds->fd, myds->myconn->fd, myerr, mysql_error(myconn->mysql));
}
myds->destroy_MySQL_Connection_From_Pool(false);
myds->fd=0;
delete mybe->server_myds;

@ -453,6 +453,7 @@ void MySQL_Connection::store_result_cont(short event) {
#define NEXT_IMMEDIATE(new_st) do { async_state_machine = new_st; goto handler_again; } while (0)
MDB_ASYNC_ST MySQL_Connection::handler(short event) {
unsigned int processed_bytes=0; // issue #527 : this variable will store the amount of bytes processed during this event
if (mysql==NULL) {
// it is the first time handler() is being called
async_state_machine=ASYNC_CONNECT_START;
@ -697,7 +698,12 @@ handler_again:
unsigned int br=MyRS->add_row(mysql_row);
__sync_fetch_and_add(&parent->bytes_recv,br);
myds->sess->thread->status_variables.queries_backends_bytes_recv+=br;
NEXT_IMMEDIATE(ASYNC_USE_RESULT_CONT);
processed_bytes+=br; // issue #527 : this variable will store the amount of bytes processed during this event
if (processed_bytes > (unsigned int)mysql_thread___threshold_resultset_size*2) {
next_event(ASYNC_USE_RESULT_CONT); // we temporarily pause
} else {
NEXT_IMMEDIATE(ASYNC_USE_RESULT_CONT); // we continue looping
}
} else {
MyRS->add_eof();
NEXT_IMMEDIATE(ASYNC_QUERY_END);
@ -947,9 +953,11 @@ int MySQL_Connection::async_ping(short event) {
return 0;
break;
case ASYNC_PING_FAILED:
case ASYNC_PING_TIMEOUT:
return -1;
break;
case ASYNC_PING_TIMEOUT:
return -2;
break;
case ASYNC_IDLE:
async_state_machine=ASYNC_PING_START;
default:
@ -964,9 +972,11 @@ int MySQL_Connection::async_ping(short event) {
return 0;
break;
case ASYNC_PING_FAILED:
case ASYNC_PING_TIMEOUT:
return -1;
break;
case ASYNC_PING_TIMEOUT:
return -2;
break;
default:
return 1;
break;

Loading…
Cancel
Save