Re: [PATCH] libpq: try all addresses for a host before moving to next on target_session_attrs mismatch

From: Jacob Champion <jacob(dot)champion(at)enterprisedb(dot)com>
To: Evgeny Kuzin <evgeny(dot)kuzin(at)outlook(dot)com>
Cc: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: [PATCH] libpq: try all addresses for a host before moving to next on target_session_attrs mismatch
Date: 2026-05-12 20:12:54
Message-ID: CAOYmi+mc482kD9bOyE9FGghj9acwo_AVQAXRV=PX0XNboqY_Eg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Mar 12, 2026 at 3:43 AM Evgeny Kuzin <evgeny(dot)kuzin(at)outlook(dot)com> wrote:
> > I'm no DNS expert, but I can't shake the feeling that you're
> > (mis)using round-robin A records to reimplement, say, SRV records
>
> Would reviving SRV support be a direction you'd consider architecturally sound?

I'm, again, no DNS expert. But I think we'd be moving in the same
direction as other cluster-aware software if we explored that
approach, which feels reasonable to me.

> Another thought - what about cluster-aware routing at the protocol level? A standby could redirect to the primary - similar to HTTP 302. The cluster knows its own topology, libpq stays fast and dumb about it. That would preserve the "connect me as fast as possible" ability you mentioned. Though that feels like a bigger architectural lift compared to SRV.

I think there might be a good argument for having both. Topologies
aren't static; ideally you want your client to navigate a failover
successfully, but you probably don't want to *optimize* for constant
failovers.

--Jacob

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Jacob Champion 2026-05-12 20:15:12 Re: [PATCH] libpq: try all addresses for a host before moving to next on target_session_attrs mismatch
Previous Message Tom Lane 2026-05-12 19:27:17 Re: Review - Patch for pg_bsd_indent: improve formatting of multiline comments