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

The report host status is agnostic to error codes #3218

Open
dsmolyarenko opened this issue Apr 16, 2024 · 0 comments
Open

The report host status is agnostic to error codes #3218

dsmolyarenko opened this issue Apr 16, 2024 · 0 comments

Comments

@dsmolyarenko
Copy link

Describe the issue
Currently the HostStatus.ConnectFail status is being set on following exceptions attempting to obtain connection:

  1. ConnectException
  2. IOException
  3. SQLException

See ConnectionFactoryImpl#openConnectionImpl method. Setting this status the host is excluded from the hosts list for a certain number of seconds (hostRecheckSeconds property).
The problem that some error codes doesn't mean the host needs to be marked as unavailable. The example is 53300 - that means user role connection limit is reached. This means that another role still eligible to establish a connection but the host is halted for seconds.

      } catch (SQLException se) {
        closeStream(newStream);
        GlobalHostStatusTracker.reportHostStatus(hostSpec, HostStatus.ConnectFail);
        knownStates.put(hostSpec, HostStatus.ConnectFail);
        if (hostIter.hasNext()) {
        ...

Driver Version?
42.7.3

Java Version?
17

OS Version?
rhel 9

PostgreSQL Version?
13.9

To Reproduce
Configure multihost jdbc url with two or more hosts.

Expected behaviour
Certain error codes shouldn't mark hosts as broken:

      } catch (SQLException se) {
        closeStream(newStream);
        if (isConnectFailure(se.getSQLState())) { // it needs to check a driver property with error codes list
            GlobalHostStatusTracker.reportHostStatus(hostSpec, HostStatus.ConnectFail);
        }
        knownStates.put(hostSpec, HostStatus.ConnectFail);
        if (hostIter.hasNext()) {
        ...
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

No branches or pull requests

1 participant