Mirroring bug fixes

Handling of error_msg
Fixed crashed on SHOW PROCESSLIST
pull/525/head
René Cannaò 10 years ago
parent 4cc6b3ca82
commit 0e01e5e322

@ -73,6 +73,7 @@ class MySQL_Session
void * operator new(size_t);
void operator delete(void *);
MySQL_Thread *thread;
unsigned long long start_time;
uint32_t thread_session_id;
// enum session_states sess_states;
Query_Processor_Output *qpo;

@ -188,6 +188,7 @@ MySQL_Session::MySQL_Session() {
thread_session_id=0;
pause_until=0;
qpo=NULL;
start_time=0;
command_counters=new StatCounters(15,10,false);
healthy=1;
autocommit=true;
@ -675,7 +676,13 @@ __get_pkts_from_client:
qpo=GloQPro->process_mysql_query(this,pkt.ptr,pkt.size,&CurrentQuery);
assert(qpo); // GloQPro->process_mysql_query() should always return a qpo
rc_break=handler___status_WAITING_CLIENT_DATA___STATE_SLEEP___MYSQL_COM_QUERY_qpo(&pkt);
if (rc_break==true) { break; }
if (rc_break==true) {
if (mirror==false) {
break;
} else {
return -1;
}
}
//if (mirror==true) {
// // this is not required anymore, because now
// // GloQPro->process_mysql_query() knows if we are inside a mirror session
@ -697,7 +704,11 @@ __get_pkts_from_client:
newsess->client_myds->attach_connection(myconn);
newsess->client_myds->myprot.init(&newsess->client_myds, newsess->client_myds->myconn->userinfo, newsess);
newsess->to_process=1;
newsess->mirror_hostgroup=qpo->mirror_hostgroup; // in the new session we copy the mirror hostgroup
if (qpo->mirror_hostgroup>= 0) {
newsess->mirror_hostgroup=qpo->mirror_hostgroup; // in the new session we copy the mirror hostgroup
} else {
newsess->mirror_hostgroup=default_hostgroup; // copy the default
}
newsess->mirror_flagOUT=qpo->mirror_flagOUT; // in the new session we copy the mirror flagOUT
newsess->default_schema=strdup(default_schema);
newsess->mirror=true;

@ -1365,6 +1365,7 @@ void MySQL_Thread::register_session(MySQL_Session *_sess) {
}
mysql_sessions->add(_sess);
_sess->thread=this;
_sess->start_time=curtime;
proxy_debug(PROXY_DEBUG_NET,1,"Thread=%p, Session=%p -- Registered new session\n", _sess->thread, _sess);
}
@ -2053,7 +2054,7 @@ SQLite3_result * MySQL_Threads_Handler::SQL3_Processlist() {
pta[3]=strdup(ui->schemaname);
}
}
if (sess->client_myds->client_addr->sa_family==AF_INET) {
if (sess->mirror==false && sess->client_myds->client_addr->sa_family==AF_INET) {
struct sockaddr_in * ipv4addr=(struct sockaddr_in *)sess->client_myds->client_addr;
pta[4]=strdup(inet_ntoa(ipv4addr->sin_addr));
sprintf(buf,"%d", htons(ipv4addr->sin_port));
@ -2131,11 +2132,16 @@ SQLite3_result * MySQL_Threads_Handler::SQL3_Processlist() {
pta[11]=strdup(buf);
break;
}
int idx=sess->client_myds->poll_fds_idx;
unsigned long long last_sent=sess->thread->mypolls.last_sent[idx];
unsigned long long last_recv=sess->thread->mypolls.last_recv[idx];
unsigned long long last_time=(last_sent > last_recv ? last_sent : last_recv);
sprintf(buf,"%llu", (sess->thread->curtime - last_time)/1000 );
if (sess->mirror==false) {
int idx=sess->client_myds->poll_fds_idx;
unsigned long long last_sent=sess->thread->mypolls.last_sent[idx];
unsigned long long last_recv=sess->thread->mypolls.last_recv[idx];
unsigned long long last_time=(last_sent > last_recv ? last_sent : last_recv);
sprintf(buf,"%llu", (sess->thread->curtime - last_time)/1000 );
} else {
// for mirror session we only consider the start time
sprintf(buf,"%llu", (sess->thread->curtime - sess->start_time)/1000 );
}
pta[12]=strdup(buf);
result->add_row(pta);

Loading…
Cancel
Save