Merge branch 'v2.0-lab' into v2.0-lab

pull/1464/head
Nick Vyzas 8 years ago committed by GitHub
commit b35665a727
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

1
.gitignore vendored

@ -45,6 +45,7 @@ oldcode/tests/connect_speed
#binary
src/proxysql
src/*pem
binaries/*deb
binaries/*rpm
tools/eventslog_reader_sample

@ -498,7 +498,7 @@ class MySQL_HostGroups_Manager {
SQLite3_result * SQL3_Connection_Pool(bool _reset);
void push_MyConn_to_pool(MySQL_Connection *, bool _lock=true);
void push_MyConn_to_pool_array(MySQL_Connection **);
void push_MyConn_to_pool_array(MySQL_Connection **, unsigned int);
void destroy_MyConn_from_pool(MySQL_Connection *, bool _lock=true);
void replication_lag_action(int, char*, unsigned int, int);

@ -21,7 +21,8 @@ class MySQL_ResultSet {
unsigned long long resultset_size;
PtrSizeArray PSarrayOUT;
//PtrSizeArray *PSarrayOUT;
MySQL_ResultSet(MySQL_Protocol *_myprot, MYSQL_RES *_res, MYSQL *_my, MYSQL_STMT *_stmt=NULL);
MySQL_ResultSet();
void init(MySQL_Protocol *_myprot, MYSQL_RES *_res, MYSQL *_my, MYSQL_STMT *_stmt=NULL);
~MySQL_ResultSet();
unsigned int add_row(MYSQL_ROW row);
unsigned int add_row2(MYSQL_ROWS *row, unsigned char *offset);

@ -72,6 +72,7 @@ class MySQL_Connection {
MYSQL_RES *mysql_result;
MYSQL_ROW mysql_row;
MySQL_ResultSet *MyRS;
MySQL_ResultSet *MyRS_reuse;
MySrvC *parent;
MySQL_Connection_userinfo *userinfo;
MySQL_Data_Stream *myds;

@ -178,6 +178,7 @@ struct ev_io * new_connector(char *address, uint16_t gtid_port, uint16_t mysql_p
close(s);
return NULL;
}
/*
memset(&a, 0, sizeof(a));
a.sin_port = htons(gtid_port);
a.sin_family = AF_INET;
@ -186,9 +187,27 @@ struct ev_io * new_connector(char *address, uint16_t gtid_port, uint16_t mysql_p
close(s);
return NULL;
}
*/
ioctl_FIONBIO(s,1);
int status = connect(s, (struct sockaddr *) &a, sizeof(a));
struct addrinfo hints;
struct addrinfo *res = NULL;
memset(&hints, 0, sizeof(hints));
hints.ai_protocol= IPPROTO_TCP;
hints.ai_family= AF_UNSPEC;
hints.ai_socktype= SOCK_STREAM;
char str_port[NI_MAXSERV+1];
sprintf(str_port,"%d", gtid_port);
int gai_rc = getaddrinfo(address, str_port, &hints, &res);
if (gai_rc) {
freeaddrinfo(res);
//exit here
return NULL;
}
//int status = connect(s, (struct sockaddr *) &a, sizeof(a));
int status = connect(s, res->ai_addr, res->ai_addrlen);
if ((status == 0) || ((status == -1) && (errno == EINPROGRESS))) {
struct ev_io *c = (struct ev_io *)malloc(sizeof(struct ev_io));
if (c) {
@ -1121,7 +1140,7 @@ bool MySQL_HostGroups_Manager::commit() {
//fprintf(stderr,"%lld\n", ptr);
if (ptr==0) {
if (GloMTH->variables.hostgroup_manager_verbose) {
proxy_info("Creating new server in HG %d : %s:%d , gtid_port=%d, weight=%d, status=%s\n", atoi(r->fields[0]), r->fields[1], atoi(r->fields[2]), atoi(r->fields[3]), atoi(r->fields[4]), (MySerStatus) atoi(r->fields[5]));
proxy_info("Creating new server in HG %d : %s:%d , gtid_port=%d, weight=%d, status=%d\n", atoi(r->fields[0]), r->fields[1], atoi(r->fields[2]), atoi(r->fields[3]), atoi(r->fields[4]), (MySerStatus) atoi(r->fields[5]));
}
MySrvC *mysrvc=new MySrvC(r->fields[1], atoi(r->fields[2]), atoi(r->fields[3]), atoi(r->fields[4]), (MySerStatus) atoi(r->fields[5]), atoi(r->fields[6]), atoi(r->fields[7]), atoi(r->fields[8]), atoi(r->fields[9]), atoi(r->fields[10]), r->fields[11]); // add new fields here if adding more columns in mysql_servers
proxy_debug(PROXY_DEBUG_MYSQL_CONNPOOL, 5, "Adding new server %s:%d , weight=%d, status=%d, mem_ptr=%p into hostgroup=%d\n", r->fields[1], atoi(r->fields[2]), atoi(r->fields[3]), (MySerStatus) atoi(r->fields[4]), mysrvc, atoi(r->fields[0]));
@ -1851,12 +1870,12 @@ __exit_push_MyConn_to_pool:
wrunlock();
}
void MySQL_HostGroups_Manager::push_MyConn_to_pool_array(MySQL_Connection **ca) {
void MySQL_HostGroups_Manager::push_MyConn_to_pool_array(MySQL_Connection **ca, unsigned int cnt) {
unsigned int i=0;
MySQL_Connection *c=NULL;
c=ca[i];
wrlock();
while (c) {
while (i<cnt) {
push_MyConn_to_pool(c,false);
i++;
c=ca[i];

@ -1757,16 +1757,20 @@ stmt_execute_metadata_t * MySQL_Protocol::get_binds_from_pkt(void *ptr, unsigned
return ret;
}
MySQL_ResultSet::MySQL_ResultSet(MySQL_Protocol *_myprot, MYSQL_RES *_res, MYSQL *_my, MYSQL_STMT *_stmt) {
MySQL_ResultSet::MySQL_ResultSet() {
buffer = NULL;
}
void MySQL_ResultSet::init(MySQL_Protocol *_myprot, MYSQL_RES *_res, MYSQL *_my, MYSQL_STMT *_stmt) {
transfer_started=false;
resultset_completed=false;
myprot=_myprot;
mysql=_my;
buffer=NULL;
if (buffer==NULL) {
//if (_stmt==NULL) { // we allocate this buffer only for not prepared statements
// removing the previous assumption. We allocate this buffer also for prepared statements
buffer=(unsigned char *)malloc(RESULTSET_BUFLEN);
//}
}
buffer_used=0;
myds=NULL;
sid=0;

@ -3044,7 +3044,10 @@ handler_again:
case 2:
MySQL_Result_to_MySQL_wire(myconn->mysql, myconn->MyRS);
if (myconn->MyRS) { // we also need to clear MyRS, so that the next staement will recreate it if needed
delete myconn->MyRS;
if (myconn->MyRS_reuse) {
delete myconn->MyRS_reuse;
}
myconn->MyRS_reuse = myconn->MyRS;
myconn->MyRS=NULL;
}
NEXT_IMMEDIATE(PROCESSING_QUERY);
@ -4187,7 +4190,8 @@ void MySQL_Session::handler___client_DSS_QUERY_SENT___server_DSS_NOT_INITIALIZED
void MySQL_Session::MySQL_Stmt_Result_to_MySQL_wire(MYSQL_STMT *stmt, MySQL_Connection *myconn) {
MYSQL_RES *stmt_result=myconn->query.stmt_result;
if (stmt_result) {
MySQL_ResultSet *MyRS=new MySQL_ResultSet(&client_myds->myprot, stmt_result, stmt->mysql, stmt);
MySQL_ResultSet *MyRS=new MySQL_ResultSet();
MyRS->init(&client_myds->myprot, stmt_result, stmt->mysql, stmt);
MyRS->get_resultset(client_myds->PSarrayOUT);
//removed bool resultset_completed=MyRS->get_resultset(client_myds->PSarrayOUT);
delete MyRS;

@ -2846,6 +2846,7 @@ __run_skip_1a:
}
GloQPro->update_query_processor_stats();
}
if (rc == -1 && errno == EINTR)
// poll() timeout, try again
continue;
@ -4770,15 +4771,16 @@ void MySQL_Thread::return_local_connections() {
if (cached_connections->len==0) {
return;
}
/*
MySQL_Connection **ca=(MySQL_Connection **)malloc(sizeof(MySQL_Connection *)*(cached_connections->len+1));
unsigned int i=0;
*/
// ca[i]=NULL;
MyHGM->push_MyConn_to_pool_array((MySQL_Connection **)cached_connections->pdata, cached_connections->len);
// free(ca);
while (cached_connections->len) {
ca[i]=(MySQL_Connection *)cached_connections->remove_index_fast(0);
i++;
cached_connections->remove_index_fast(0);
}
ca[i]=NULL;
MyHGM->push_MyConn_to_pool_array(ca);
free(ca);
}
unsigned long long MySQL_Threads_Handler::get_ConnPool_get_conn_immediate() {

@ -212,6 +212,7 @@ MySQL_Connection::MySQL_Connection() {
largest_query_length=0;
multiplex_delayed=false;
MyRS=NULL;
MyRS_reuse=NULL;
unknown_transaction_status = false;
creation_time=0;
processing_multi_statement=false;
@ -240,6 +241,11 @@ MySQL_Connection::~MySQL_Connection() {
}
if (MyRS) {
delete MyRS;
MyRS = NULL;
}
if (MyRS_reuse) {
delete MyRS_reuse;
MyRS_reuse = NULL;
}
if (query.stmt) {
query.stmt=NULL;
@ -533,6 +539,7 @@ void MySQL_Connection::real_query_start() {
}
void MySQL_Connection::real_query_cont(short event) {
if (event == 0) return;
proxy_debug(PROXY_DEBUG_MYSQL_PROTOCOL, 6,"event=%d\n", event);
async_exit_status = mysql_real_query_cont(&interr ,mysql , mysql_status(event, true));
}
@ -901,7 +908,9 @@ handler_again:
break;
case ASYNC_NEXT_RESULT_CONT:
async_exit_status = mysql_next_result_cont(&interr, mysql, mysql_status(event, true));
if (event) {
async_exit_status = mysql_next_result_cont(&interr, mysql, mysql_status(event, true));
}
if (async_exit_status) {
next_event(ASYNC_NEXT_RESULT_CONT);
} else {
@ -944,9 +953,23 @@ handler_again:
NEXT_IMMEDIATE(ASYNC_QUERY_END);
} else {
if (myds->sess->mirror==false) {
MyRS=new MySQL_ResultSet(&myds->sess->client_myds->myprot, mysql_result, mysql);
if (MyRS_reuse == NULL) {
MyRS = new MySQL_ResultSet();
MyRS->init(&myds->sess->client_myds->myprot, mysql_result, mysql);
} else {
MyRS = MyRS_reuse;
MyRS_reuse = NULL;
MyRS->init(&myds->sess->client_myds->myprot, mysql_result, mysql);
}
} else {
MyRS=new MySQL_ResultSet(NULL, mysql_result, mysql);
if (MyRS_reuse == NULL) {
MyRS = new MySQL_ResultSet();
MyRS->init(NULL, mysql_result, mysql);
} else {
MyRS = MyRS_reuse;
MyRS_reuse = NULL;
MyRS->init(NULL, mysql_result, mysql);
}
}
async_fetch_row_start=false;
NEXT_IMMEDIATE(ASYNC_USE_RESULT_CONT);
@ -1537,7 +1560,10 @@ void MySQL_Connection::async_free_result() {
compute_unknown_transaction_status();
async_state_machine=ASYNC_IDLE;
if (MyRS) {
delete MyRS;
if (MyRS_reuse) {
delete (MyRS_reuse);
}
MyRS_reuse = MyRS;
MyRS=NULL;
}
}

Loading…
Cancel
Save