@ -96,11 +96,12 @@ bool Session_Regex::match(char *m) {
}
KillArgs : : KillArgs ( char * u , char * p , char * h , unsigned int P , unsigned long i , int kt , MySQL_Thread * _mt ) {
KillArgs : : KillArgs ( char * u , char * p , char * h , unsigned int P , unsigned int _hid , unsigned long i , int kt , MySQL_Thread * _mt ) {
username = strdup ( u ) ;
password = strdup ( p ) ;
hostname = strdup ( h ) ;
port = P ;
hid = _hid ;
id = i ;
kill_type = kt ;
mt = _mt ;
@ -158,6 +159,8 @@ void * kill_query_thread(void *arg) {
}
if ( ! ret ) {
proxy_error ( " Failed to connect to server %s:%d to run KILL %s %llu: Error: %s \n " , ka - > hostname , ka - > port , ( ka - > kill_type = = KILL_QUERY ? " QUERY " : " CONNECTION " ) , ka - > id , mysql_error ( mysql ) ) ;
// TODO: Ask for this specific case: 'modify killargs to include hostgroup info
MyHGM - > p_update_mysql_error_counter ( p_mysql_error_type : : mysql , ka - > hid , ka - > hostname , ka - > port , mysql_errno ( mysql ) ) ;
goto __exit_kill_query_thread ;
}
char buf [ 100 ] ;
@ -1448,6 +1451,7 @@ int MySQL_Session::handler_again___status_PINGING_SERVER() {
set_status ( NONE ) ;
return - 1 ;
} else {
MyHGM - > p_update_mysql_error_counter ( p_mysql_error_type : : mysql , myconn - > parent - > myhgc - > hid , myconn - > parent - > address , myconn - > parent - > port , mysql_errno ( myconn - > mysql ) ) ;
if ( rc = = - 1 | | rc = = - 2 ) {
if ( rc = = - 2 ) {
unsigned long long us = mysql_thread___ping_timeout_server * 1000 ;
@ -1502,6 +1506,7 @@ int MySQL_Session::handler_again___status_RESETTING_CONNECTION() {
set_status ( NONE ) ;
return - 1 ;
} else {
MyHGM - > p_update_mysql_error_counter ( p_mysql_error_type : : mysql , myconn - > parent - > myhgc - > hid , myconn - > parent - > address , myconn - > parent - > port , mysql_errno ( myconn - > mysql ) ) ;
if ( rc = = - 1 | | rc = = - 2 ) {
if ( rc = = - 2 ) {
proxy_error ( " Change user timeout during COM_CHANGE_USER on %s , %d \n " , myconn - > parent - > address , myconn - > parent - > port ) ;
@ -1542,7 +1547,7 @@ void MySQL_Session::handler_again___new_thread_to_kill_connection() {
auth_password = ui - > password ;
}
}
KillArgs * ka = new KillArgs ( ui - > username , auth_password , myds - > myconn - > parent - > address , myds - > myconn - > parent - > port , myds - > myconn - > mysql- > thread_id , KILL_QUERY , thread ) ;
KillArgs * ka = new KillArgs ( ui - > username , auth_password , myds - > myconn - > parent - > address , myds - > myconn - > parent - > port , myds - > myconn - > parent- > myhgc - > hid , myds - > myconn - > mysql- > thread_id , KILL_QUERY , thread ) ;
pthread_attr_t attr ;
pthread_attr_init ( & attr ) ;
pthread_attr_setdetachstate ( & attr , PTHREAD_CREATE_DETACHED ) ;
@ -1879,6 +1884,7 @@ bool MySQL_Session::handler_again___status_SETTING_INIT_CONNECT(int *_rc) {
if ( rc = = - 1 ) {
// the command failed
int myerr = mysql_errno ( myconn - > mysql ) ;
MyHGM - > p_update_mysql_error_counter ( p_mysql_error_type : : mysql , myconn - > parent - > myhgc - > hid , myconn - > parent - > address , myconn - > parent - > port , mysql_errno ( myconn - > mysql ) ) ;
if ( myerr > = 2000 ) {
bool retry_conn = false ;
// client error, serious
@ -1969,6 +1975,7 @@ bool MySQL_Session::handler_again___status_SETTING_LDAP_USER_VARIABLE(int *_rc)
if ( rc = = - 1 ) {
// the command failed
int myerr = mysql_errno ( myconn - > mysql ) ;
MyHGM - > p_update_mysql_error_counter ( p_mysql_error_type : : mysql , myconn - > parent - > myhgc - > hid , myconn - > parent - > address , myconn - > parent - > port , myerr ) ;
if ( myerr > = 2000 ) {
bool retry_conn = false ;
// client error, serious
@ -2045,6 +2052,7 @@ bool MySQL_Session::handler_again___status_SETTING_SQL_LOG_BIN(int *_rc) {
if ( rc = = - 1 ) {
// the command failed
int myerr = mysql_errno ( myconn - > mysql ) ;
MyHGM - > p_update_mysql_error_counter ( p_mysql_error_type : : mysql , myconn - > parent - > myhgc - > hid , myconn - > parent - > address , myconn - > parent - > port , myerr ) ;
if ( myerr > = 2000 ) {
bool retry_conn = false ;
// client error, serious
@ -2109,6 +2117,7 @@ bool MySQL_Session::handler_again___status_CHANGING_CHARSET(int *_rc) {
if ( rc = = - 1 ) {
// the command failed
int myerr = mysql_errno ( myconn - > mysql ) ;
MyHGM - > p_update_mysql_error_counter ( p_mysql_error_type : : mysql , myconn - > parent - > myhgc - > hid , myconn - > parent - > address , myconn - > parent - > port , myerr ) ;
if ( myerr > = 2000 ) {
if ( myerr = = 2019 ) {
proxy_error ( " Client trying to set a charset/collation (%u) not supported by backend (%s:%d). Changing it to %u \n " , charset , myconn - > parent - > address , myconn - > parent - > port , mysql_tracked_variables [ SQL_CHARACTER_SET ] . default_value ) ;
@ -2212,6 +2221,7 @@ bool MySQL_Session::handler_again___status_SETTING_GENERIC_VARIABLE(int *_rc, co
if ( rc = = - 1 ) {
// the command failed
int myerr = mysql_errno ( myconn - > mysql ) ;
MyHGM - > p_update_mysql_error_counter ( p_mysql_error_type : : mysql , myconn - > parent - > myhgc - > hid , myconn - > parent - > address , myconn - > parent - > port , myerr ) ;
if ( myerr > = 2000 ) {
bool retry_conn = false ;
// client error, serious
@ -2314,6 +2324,7 @@ bool MySQL_Session::handler_again___status_SETTING_MULTI_STMT(int *_rc) {
} else {
if ( rc = = - 1 ) {
proxy_error ( " Error setting multistatement on server %s , %d : %d, %s \n " , myconn - > parent - > address , myconn - > parent - > port , mysql_errno ( myconn - > mysql ) , mysql_error ( myconn - > mysql ) ) ;
MyHGM - > p_update_mysql_error_counter ( p_mysql_error_type : : mysql , myconn - > parent - > myhgc - > hid , myconn - > parent - > address , myconn - > parent - > port , mysql_errno ( myconn - > mysql ) ) ;
} else {
// rc==1 , nothing to do for now
}
@ -2351,6 +2362,7 @@ bool MySQL_Session::handler_again___status_CHANGING_SCHEMA(int *_rc) {
if ( rc = = - 1 ) {
// the command failed
int myerr = mysql_errno ( myconn - > mysql ) ;
MyHGM - > p_update_mysql_error_counter ( p_mysql_error_type : : mysql , myconn - > parent - > myhgc - > hid , myconn - > parent - > address , myconn - > parent - > port , myerr ) ;
if ( myerr > = 2000 ) {
bool retry_conn = false ;
// client error, serious
@ -2490,6 +2502,7 @@ bool MySQL_Session::handler_again___status_CONNECTING_SERVER(int *_rc) {
break ;
case - 1 :
case - 2 :
MyHGM - > p_update_mysql_error_counter ( p_mysql_error_type : : mysql , myconn - > parent - > myhgc - > hid , myconn - > parent - > address , myconn - > parent - > port , mysql_errno ( myconn - > mysql ) ) ;
if ( myds - > connect_retries_on_failure > 0 ) {
myds - > connect_retries_on_failure - - ;
int myerr = mysql_errno ( myconn - > mysql ) ;
@ -2569,6 +2582,7 @@ bool MySQL_Session::handler_again___status_CHANGING_USER_SERVER(int *_rc) {
previous_status . pop ( ) ;
NEXT_IMMEDIATE_NEW ( st ) ;
} else {
MyHGM - > p_update_mysql_error_counter ( p_mysql_error_type : : mysql , myconn - > parent - > myhgc - > hid , myconn - > parent - > address , myconn - > parent - > port , mysql_errno ( myconn - > mysql ) ) ;
if ( rc = = - 1 ) {
// the command failed
int myerr = mysql_errno ( myconn - > mysql ) ;
@ -2661,6 +2675,7 @@ bool MySQL_Session::handler_again___status_CHANGING_AUTOCOMMIT(int *_rc) {
myds - > DSS = STATE_MARIADB_GENERIC ;
NEXT_IMMEDIATE_NEW ( st ) ;
} else {
MyHGM - > p_update_mysql_error_counter ( p_mysql_error_type : : mysql , myconn - > parent - > myhgc - > hid , myconn - > parent - > address , myconn - > parent - > port , mysql_errno ( myconn - > mysql ) ) ;
if ( rc = = - 1 ) {
// the command failed
int myerr = mysql_errno ( myconn - > mysql ) ;
@ -3727,6 +3742,7 @@ handler_again:
RequestEnd ( myds ) ;
finishQuery ( myds , myconn , prepared_stmt_with_no_params ) ;
} else {
MyHGM - > p_update_mysql_error_counter ( p_mysql_error_type : : mysql , myconn - > parent - > myhgc - > hid , myconn - > parent - > address , myconn - > parent - > port , mysql_errno ( myconn - > mysql ) ) ;
if ( rc = = - 1 ) {
int myerr = mysql_errno ( myconn - > mysql ) ;
char * errmsg = NULL ;
@ -5858,6 +5874,7 @@ void MySQL_Session::MySQL_Stmt_Result_to_MySQL_wire(MYSQL_STMT *stmt, MySQL_Conn
MYSQL * mysql = stmt - > mysql ;
// no result set
int myerrno = mysql_stmt_errno ( stmt ) ;
MyHGM - > p_update_mysql_error_counter ( p_mysql_error_type : : mysql , myconn - > parent - > myhgc - > hid , myconn - > parent - > address , myconn - > parent - > port , myerrno ) ;
if ( myerrno = = 0 ) {
unsigned int num_rows = mysql_affected_rows ( stmt - > mysql ) ;
unsigned int nTrx = NumActiveTransactions ( ) ;
@ -5938,6 +5955,7 @@ void MySQL_Session::MySQL_Result_to_MySQL_wire(MYSQL *mysql, MySQL_ResultSet *My
//client_myds->pkt_sid++;
} else {
// error
MyHGM - > p_update_mysql_error_counter ( p_mysql_error_type : : mysql , _myds - > myconn - > parent - > myhgc - > hid , _myds - > myconn - > parent - > address , _myds - > myconn - > parent - > port , myerrno ) ;
char sqlstate [ 10 ] ;
sprintf ( sqlstate , " %s " , mysql_sqlstate ( mysql ) ) ;
if ( _myds & & _myds - > killed_at ) { // see case #750