Skip to content

Commit dbe0269

Browse files
committed
wip: if all servers have reached max_connections but there is a server with weight=0, use it
1 parent c029e66 commit dbe0269

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

lib/PgSQL_HostGroups_Manager.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1974,6 +1974,17 @@ PgSQL_SrvC *PgSQL_HGC::get_random_MySrvC(char * gtid_uuid, uint64_t gtid_trxid,
19741974
}
19751975
}
19761976
}
1977+
if (sum==0 && num_candidates > 0) {
1978+
proxy_info("No available server in hostgroup %u with weight > 0, but %u candidates found. This is probably due to max_connections reached for all servers. Using candidates with weight 0\n", hid, num_candidates);
1979+
// Iterate on all candidates and increase their weight
1980+
for (j=0; j<num_candidates; j++) {
1981+
mysrvc = mysrvcCandidates[j];
1982+
// increase the weight of the server
1983+
mysrvc->weight++;
1984+
proxy_debug("Increasing weight of server %s:%d to %ld\n", mysrvc->address, mysrvc->port, mysrvc->weight);
1985+
sum += 1;
1986+
}
1987+
}
19771988
if (sum==0) {
19781989
// per issue #531 , we try a desperate attempt to bring back online any shunned server
19791990
// we do this lowering the maximum wait time to 10%

0 commit comments

Comments
 (0)