Do not kill Session if a backend failed

This new algorithm makes the backend connection fails instead of killing the session
This is an improvement over issue #1085
pull/2044/head
René Cannaò 7 years ago
parent 2e20854684
commit 0c232bf04b

@ -214,6 +214,7 @@ class MySQL_Session
void MySQL_Stmt_Result_to_MySQL_wire(MYSQL_STMT *stmt, MySQL_Connection *myconn);
unsigned int NumActiveTransactions();
bool HasOfflineBackends();
bool SetEventInOfflineBackends();
int FindOneActiveTransaction();
unsigned long long IdleTime();

@ -4752,6 +4752,23 @@ bool MySQL_Session::HasOfflineBackends() {
return ret;
}
bool MySQL_Session::SetEventInOfflineBackends() {
bool ret=false;
if (mybes==0) return ret;
MySQL_Backend *_mybe;
unsigned int i;
for (i=0; i < mybes->len; i++) {
_mybe=(MySQL_Backend *)mybes->index(i);
if (_mybe->server_myds)
if (_mybe->server_myds->myconn)
if (_mybe->server_myds->myconn->IsServerOffline()) {
_mybe->server_myds->revents|=POLLIN;
ret = true;
}
}
return ret;
}
int MySQL_Session::FindOneActiveTransaction() {
int ret=-1;
if (mybes==0) return ret;

@ -3551,8 +3551,14 @@ void MySQL_Thread::process_all_sessions() {
}
if (servers_table_version_current != servers_table_version_previous) { // bug fix for #1085
// Immediatelly kill all client connections using an OFFLINE node
if (sess->HasOfflineBackends()) {
sess->killed=true;
//if (sess->HasOfflineBackends()) {
// sess->killed=true;
//}
// Search for connections that should be terminated, and simulate data in them
// the following 2 lines of code replace the previous 2 lines
// instead of killing the sessions, fails the backend connections
if (sess->SetEventInOfflineBackends()) {
sess->to_process=1;
}
}
}

Loading…
Cancel
Save