pgjdbc/pgjdbc GitHub issues and pull requests (mirror)
help / color / mirror / Atom feed[pgjdbc/pgjdbc] PR #3012: Support multiple hosts defined with single hostname
15+ messages / 4 participants
[nested] [flat]
* [pgjdbc/pgjdbc] PR #3012: Support multiple hosts defined with single hostname
@ 2023-11-24 13:30 "Squiry (@Squiry)" <[email protected]>
0 siblings, 0 replies; 15+ messages in thread
From: Squiry (@Squiry) @ 2023-11-24 13:30 UTC (permalink / raw)
To: pgjdbc/pgjdbc <[email protected]>
The implementation is pretty simple but the test is... well, ugly, but I have no idea how to make it any better.
Resolves #3011
^ permalink raw reply [nested|flat] 15+ messages in thread
* Re: [pgjdbc/pgjdbc] PR #3012: Support multiple hosts defined with single hostname
@ 2023-11-25 11:40 ` "davecramer (@davecramer)" <[email protected]>
13 siblings, 0 replies; 15+ messages in thread
From: davecramer (@davecramer) @ 2023-11-25 11:40 UTC (permalink / raw)
To: pgjdbc/pgjdbc <[email protected]>
(on build-logic/jvm/src/main/kotlin/build-logic.test-base.gradle.kts)
tests run on java 8 so this won't work
^ permalink raw reply [nested|flat] 15+ messages in thread
* Re: [pgjdbc/pgjdbc] PR #3012: Support multiple hosts defined with single hostname
@ 2023-11-25 15:36 ` "Squiry (@Squiry)" <[email protected]>
13 siblings, 0 replies; 15+ messages in thread
From: Squiry (@Squiry) @ 2023-11-25 15:36 UTC (permalink / raw)
To: pgjdbc/pgjdbc <[email protected]>
(on build-logic/jvm/src/main/kotlin/build-logic.test-base.gradle.kts)
Ok, on java8 test should work even without that flag. I will fix it later today.
^ permalink raw reply [nested|flat] 15+ messages in thread
* Re: [pgjdbc/pgjdbc] PR #3012: Support multiple hosts defined with single hostname
@ 2023-11-27 09:37 ` "vlsi (@vlsi)" <[email protected]>
13 siblings, 0 replies; 15+ messages in thread
From: vlsi (@vlsi) @ 2023-11-27 09:37 UTC (permalink / raw)
To: pgjdbc/pgjdbc <[email protected]>
(on pgjdbc/src/main/java/org/postgresql/hostchooser/HostChooserFactory.java:45)
I am afraid it would break TLS hostname verification.
We already support multi-host. What we miss is IP-based balancing.
^ permalink raw reply [nested|flat] 15+ messages in thread
* Re: [pgjdbc/pgjdbc] PR #3012: Support multiple hosts defined with single hostname
@ 2023-11-27 12:47 ` "davecramer (@davecramer)" <[email protected]>
13 siblings, 0 replies; 15+ messages in thread
From: davecramer (@davecramer) @ 2023-11-27 12:47 UTC (permalink / raw)
To: pgjdbc/pgjdbc <[email protected]>
(on pgjdbc/src/main/java/org/postgresql/hostchooser/HostChooserFactory.java:45)
How does it work for libpq then ?
^ permalink raw reply [nested|flat] 15+ messages in thread
* Re: [pgjdbc/pgjdbc] PR #3012: Support multiple hosts defined with single hostname
@ 2023-11-27 12:47 ` "Squiry (@Squiry)" <[email protected]>
13 siblings, 0 replies; 15+ messages in thread
From: Squiry (@Squiry) @ 2023-11-27 12:47 UTC (permalink / raw)
To: pgjdbc/pgjdbc <[email protected]>
(on pgjdbc/src/main/java/org/postgresql/hostchooser/HostChooserFactory.java:45)
I can put `InetAddress` in `HostSpec` and use it in `PGStream` (I believe this is the only place where actual connection is created), will it be ok?
^ permalink raw reply [nested|flat] 15+ messages in thread
* Re: [pgjdbc/pgjdbc] PR #3012: Support multiple hosts defined with single hostname
@ 2023-11-27 13:01 ` "vlsi (@vlsi)" <[email protected]>
13 siblings, 0 replies; 15+ messages in thread
From: vlsi (@vlsi) @ 2023-11-27 13:01 UTC (permalink / raw)
To: pgjdbc/pgjdbc <[email protected]>
(on pgjdbc/src/main/java/org/postgresql/hostchooser/HostChooserFactory.java:45)
Sure we need to remember both "hostname" and "the resolved IP address".
Suppose there's "db1" which resolves to 3 IP addresses and "db2" which resolves to 15 IP addresses.
Does it mean we distribute the load as 3:15? Should we distribute the load as 1:1 and then make even distribution among the IPs behind each hostname?
I suggest we settle on that before adjusting the implementation.
^ permalink raw reply [nested|flat] 15+ messages in thread
* Re: [pgjdbc/pgjdbc] PR #3012: Support multiple hosts defined with single hostname
@ 2023-11-27 13:17 ` "Squiry (@Squiry)" <[email protected]>
13 siblings, 0 replies; 15+ messages in thread
From: Squiry (@Squiry) @ 2023-11-27 13:17 UTC (permalink / raw)
To: pgjdbc/pgjdbc <[email protected]>
(on pgjdbc/src/main/java/org/postgresql/hostchooser/HostChooserFactory.java:45)
Tbh I don't think that this would be the case, more like "db1" that resolves to 18 ip addresses and that's it.
Right now implementation doesn't even bother to detect ip addresses if multiple hosts was defined.
^ permalink raw reply [nested|flat] 15+ messages in thread
* Re: [pgjdbc/pgjdbc] PR #3012: Support multiple hosts defined with single hostname
@ 2023-11-27 14:02 ` "Squiry (@Squiry)" <[email protected]>
13 siblings, 0 replies; 15+ messages in thread
From: Squiry (@Squiry) @ 2023-11-27 14:02 UTC (permalink / raw)
To: pgjdbc/pgjdbc <[email protected]>
(on pgjdbc/src/main/java/org/postgresql/hostchooser/HostChooserFactory.java:45)
Libpq shuffles provided hosts [here](https://github.com/postgres/postgres/blob/master/src/interfaces/libpq/fe-connect.c#L1712) and than shuffles resolved address of each host [here](https://github.com/postgres/postgres/blob/master/src/interfaces/libpq/fe-connect.c#L2617). Looks more like a 1:1 case. This will require a little bit more changes on pgjdbc side.
^ permalink raw reply [nested|flat] 15+ messages in thread
* Re: [pgjdbc/pgjdbc] PR #3012: Support multiple hosts defined with single hostname
@ 2023-11-28 16:41 ` "Squiry (@Squiry)" <[email protected]>
13 siblings, 0 replies; 15+ messages in thread
From: Squiry (@Squiry) @ 2023-11-28 16:41 UTC (permalink / raw)
To: pgjdbc/pgjdbc <[email protected]>
(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.
^ permalink raw reply [nested|flat] 15+ messages in thread
* Re: [pgjdbc/pgjdbc] PR #3012: Support multiple hosts defined with single hostname
@ 2023-12-04 08:40 ` "Squiry (@Squiry)" <[email protected]>
13 siblings, 0 replies; 15+ messages in thread
From: Squiry (@Squiry) @ 2023-12-04 08:40 UTC (permalink / raw)
To: pgjdbc/pgjdbc <[email protected]>
(on pgjdbc/src/main/java/org/postgresql/hostchooser/HostChooserFactory.java:45)
@vlsi @davecramer so which implementation should I pick as reference.
^ permalink raw reply [nested|flat] 15+ messages in thread
* Re: [pgjdbc/pgjdbc] PR #3012: Support multiple hosts defined with single hostname
@ 2023-12-04 12:01 ` "davecramer (@davecramer)" <[email protected]>
13 siblings, 0 replies; 15+ messages in thread
From: davecramer (@davecramer) @ 2023-12-04 12:01 UTC (permalink / raw)
To: pgjdbc/pgjdbc <[email protected]>
(on pgjdbc/src/main/java/org/postgresql/hostchooser/HostChooserFactory.java:45)
actually, cloud providers do this quite a bit. Where there is 1 writer and N readers. Active-Active is gaining traction in PostgreSQL so having N writers and M readers will be coming. If I had to choose between the two implementations it would probably be libpq only because more interfaces use it.
^ permalink raw reply [nested|flat] 15+ messages in thread
* Re: [pgjdbc/pgjdbc] PR #3012: Support multiple hosts defined with single hostname
@ 2025-02-15 17:08 ` "x4m (@x4m)" <[email protected]>
13 siblings, 0 replies; 15+ messages in thread
From: x4m (@x4m) @ 2025-02-15 17:08 UTC (permalink / raw)
To: pgjdbc/pgjdbc <[email protected]>
(on pgjdbc/src/main/java/org/postgresql/hostchooser/HostChooserFactory.java:45)
So, did you choose anything? Right now I'm reviewing patch about it into libpq, and current libpq behavior looks to me like a bug :)
https://www.postgresql.org/message-id/flat/CAKK5BkESSc69sp2TiTWHvvOHCUey0rDWXSrR9pinyRqyfamUYg%40mai...
^ permalink raw reply [nested|flat] 15+ messages in thread
* Re: [pgjdbc/pgjdbc] PR #3012: Support multiple hosts defined with single hostname
@ 2025-02-16 12:36 ` "davecramer (@davecramer)" <[email protected]>
13 siblings, 0 replies; 15+ messages in thread
From: davecramer (@davecramer) @ 2025-02-16 12:36 UTC (permalink / raw)
To: pgjdbc/pgjdbc <[email protected]>
What did you consider a bug?
I read the link and couldn’t figure out the bug part
Dave Cramer
On Sat, Feb 15, 2025 at 12:08 PM Andrey Borodin ***@***.***>
wrote:
> ***@***.**** commented on this pull request.
> ------------------------------
>
> In pgjdbc/src/main/java/org/postgresql/hostchooser/HostChooserFactory.java
> <https://github.com/pgjdbc/pgjdbc/pull/3012#discussion_r1957158530;:
>
> > + resultHosts[i] = new HostSpec(inetAddress.getHostAddress(), host.getPort(),
> + host.getLocalSocketAddress());
>
> So, did you choose anything? Right now I'm reviewing patch about it into
> libpq, and current libpq behavior looks to me like a bug :)
>
> https://www.postgresql.org/message-id/flat/CAKK5BkESSc69sp2TiTWHvvOHCUey0rDWXSrR9pinyRqyfamUYg%40mai...
>
> —
> Reply to this email directly, view it on GitHub
> <https://github.com/pgjdbc/pgjdbc/pull/3012#discussion_r1957158530;, or
> unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AADDH5W66IUGTYMYRSIJXNL2P5YAXAVCNFSM6AAAAABXGUUWUO...;
> .
> You are receiving this because you were mentioned.Message ID:
> ***@***.***>
>
^ permalink raw reply [nested|flat] 15+ messages in thread
* Re: [pgjdbc/pgjdbc] PR #3012: Support multiple hosts defined with single hostname
@ 2025-02-17 08:29 ` "x4m (@x4m)" <[email protected]>
13 siblings, 0 replies; 15+ messages in thread
From: x4m (@x4m) @ 2025-02-17 08:29 UTC (permalink / raw)
To: pgjdbc/pgjdbc <[email protected]>
> What did you consider a bug? I read the link and couldn’t figure out the bug part
If I have a single DNS name that is resolved to all IPs from Highly-available cluster, libpq will probe only first one.
^ permalink raw reply [nested|flat] 15+ messages in thread
end of thread, other threads:[~2025-02-17 08:29 UTC | newest]
Thread overview: 15+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2023-11-24 13:30 [pgjdbc/pgjdbc] PR #3012: Support multiple hosts defined with single hostname "Squiry (@Squiry)" <[email protected]>
2023-11-25 11:40 ` "davecramer (@davecramer)" <[email protected]>
2023-11-25 15:36 ` "Squiry (@Squiry)" <[email protected]>
2023-11-27 09:37 ` "vlsi (@vlsi)" <[email protected]>
2023-11-27 12:47 ` "davecramer (@davecramer)" <[email protected]>
2023-11-27 12:47 ` "Squiry (@Squiry)" <[email protected]>
2023-11-27 13:01 ` "vlsi (@vlsi)" <[email protected]>
2023-11-27 13:17 ` "Squiry (@Squiry)" <[email protected]>
2023-11-27 14:02 ` "Squiry (@Squiry)" <[email protected]>
2023-11-28 16:41 ` "Squiry (@Squiry)" <[email protected]>
2023-12-04 08:40 ` "Squiry (@Squiry)" <[email protected]>
2023-12-04 12:01 ` "davecramer (@davecramer)" <[email protected]>
2025-02-15 17:08 ` "x4m (@x4m)" <[email protected]>
2025-02-16 12:36 ` "davecramer (@davecramer)" <[email protected]>
2025-02-17 08:29 ` "x4m (@x4m)" <[email protected]>
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox