Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use connect_retries_on_failure to control the number of retries when no backend server is available #4665

Open
wants to merge 1 commit into
base: v2.7
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions lib/MySQL_Session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3260,9 +3260,26 @@ bool MySQL_Session::handler_again___status_CONNECTING_SERVER(int *_rc) {
// 'mysql_thread___connect_retries_delay'. In case of 'async_connect' failing, 'pause_until' should also
// be set to 'mysql_thread___connect_retries_delay'. Complementary NOTE below.
if (mybe->server_myds->myconn==NULL) {
pause_until=thread->curtime+mysql_thread___connect_retries_delay*1000;
*_rc=1;
return false;
if (mybe->server_myds->connect_retries_on_failure > 0 ) {
mybe->server_myds->connect_retries_on_failure--;
pause_until=thread->curtime+mysql_thread___connect_retries_delay*1000;
*_rc=1;
return false;
} else {
char buf[256];
sprintf(buf,"Max connect failure reached and no server is available in hostgroup %d", current_hostgroup);
if (thread) {
thread->status_variables.stvar[st_var_max_connect_timeout_err]++;
}
client_myds->myprot.generate_pkt_ERR(true,NULL,NULL,1,9002,(char *)"HY000",buf,true);
RequestEnd(mybe->server_myds);

while (previous_status.size()) {
previous_status.pop();
}
mybe->server_myds->max_connect_time=0;
NEXT_IMMEDIATE_NEW(WAITING_CLIENT_DATA);
}
} else {
MySQL_Data_Stream *myds=mybe->server_myds;
MySQL_Connection *myconn=myds->myconn;
Expand Down