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

Add a provision in driver to try another server on login timeout #21

Merged
merged 3 commits into from
Jun 7, 2024

Conversation

kneeraj
Copy link

@kneeraj kneeraj commented Jun 5, 2024

Jira link
gh-issue

The driver is being enhanced to handle a connection timing out due to a busy server when login timeout is used by the user.
The timed out server is added to a temporary list which is ignored when the Connect Thread goes for the next attempt after timeout. This feature is enabled only when load-balance is set to true.

Testing:
Manually tested both the scenarios, i.e. directly using login timeout property in url and second by using login timeout property in url and Hikari pool combination.
[ For now I just added temporary code to sleep during connection attempt to mimic an unresponsive server. Removed the test code as it was not standard. We will add a cleaner test hook to simulate this cleanly later ]

@kneeraj kneeraj requested a review from ashetkar June 5, 2024 13:19
@@ -110,8 +110,9 @@ public synchronized String getLeastLoadedServer(List<String> failedHosts) {
int min = Integer.MAX_VALUE;
ArrayList<String> minConnectionsHostList = new ArrayList<>();
for (String h : hostToNumConnMap.keySet()) {
if (failedHosts.contains(h)) {
LOGGER.fine("Skipping failed host " + h);
boolean wasTimedOutHost = timedOutHosts != null && timedOutHosts.contains(h) ? true : false;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit

Suggested change
boolean wasTimedOutHost = timedOutHosts != null && timedOutHosts.contains(h) ? true : false;
boolean wasTimedOutHost = timedOutHosts != null && timedOutHosts.contains(h);

@kneeraj kneeraj merged commit c25ac63 into master Jun 7, 2024
2 checks passed
@ashetkar ashetkar deleted the gh-22725 branch June 7, 2024 10:00
ashetkar pushed a commit that referenced this pull request Oct 4, 2024
Adds a feature of trying another server when login timeout is specified.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants