Message-ID: From: "Squiry (@Squiry)" To: "pgjdbc/pgjdbc" Date: Tue, 28 Nov 2023 16:41:40 +0000 Subject: Re: [pgjdbc/pgjdbc] PR #3012: Support multiple hosts defined with single hostname In-Reply-To: References: List-Id: X-GitHub-Author-Login: Squiry X-GitHub-Comment-Id: 1408069450 X-GitHub-Comment-Type: review_comment X-GitHub-Commit: d425ed9c11bf075106ef47a65e56761b871c1be6 X-GitHub-Issue: 3012 X-GitHub-Line: 45 X-GitHub-Path: pgjdbc/src/main/java/org/postgresql/hostchooser/HostChooserFactory.java X-GitHub-Repo: pgjdbc/pgjdbc X-GitHub-Type: review_comment X-GitHub-Url: https://github.com/pgjdbc/pgjdbc/pull/3012#discussion_r1408069450 Content-Type: text/plain; charset=utf-8 (on pgjdbc/src/main/java/org/postgresql/hostchooser/HostChooserFactory.java:45) So, [libpq](https://github.com/postgres/postgres/blob/master/src/interfaces/libpq/fe-connect.c#L3967) looks at provided hosts as a single backend per host: if it connects to any address of provided host and finds out it is not in a desired state it rejects the host and doesn't even bother try next addresses. Golangs [pgx](https://github.com/jackc/pgx/blob/master/pgconn/pgconn.go#L147) treats every address as a separate instance and tries them all, only stops on auth errors. That behavior would be more preferred for me as I have case for single hostname backed with addresses for every db instance. Error propagation becomes more interesting anyway, because connecting to something like localhost will throw some interesting exceptions like `Could not find a server with specified targetServerType: any` instead of auth errors, but it can be fixed.