Re: [bug fix] PG10: libpq doesn't connect to alternative hosts when some errors occur

From: "Tsunakawa, Takayuki" <tsunakawa(dot)takay(at)jp(dot)fujitsu(dot)com>
To: 'Michael Paquier' <michael(dot)paquier(at)gmail(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Stephen Frost <sfrost(at)snowman(dot)net>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [bug fix] PG10: libpq doesn't connect to alternative hosts when some errors occur
Date: 2017-05-19 02:24:34
Message-ID: 0A3221C70F24FB45833433255569204D1F6FADD3@G01JPEXMBYT05
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

From: pgsql-hackers-owner(at)postgresql(dot)org
> [mailto:pgsql-hackers-owner(at)postgresql(dot)org] On Behalf Of Michael Paquier
> On Thu, May 18, 2017 at 11:30 PM, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
> > Because why?
>
> Because it is critical to let the user know as well *why* an error happened.
> Imagine that this feature is used with multiple nodes, all primaries. If
> a DB admin busted the credentials in one of them then all the load would
> be redirected on the other nodes, without knowing what is actually causing
> the error. Then the node where the credentials have been changed would just
> run idle, and the application would be unaware of that.

In that case, the DBA can know the authentication errors in the server log of the idle instance.

I'm sorry to repeat myself, but libpq connection failover is the feature for HA. So I believe what to prioritize is HA.

And the documentation looks somewhat misleading. I get the impression that libpq tries hosts until success regardless of failure reason: it aims for successful connection, not giving up early. Who can read this as "libpq gives up connection under some circumstances?"

https://www.postgresql.org/docs/devel/static/libpq-connect.html
--------------------------------------------------
It is possible to specify multiple host components, each with an optional port component, in a single URI. A URI of the form postgresql://host1:port1,host2:port2,host3:port3/ is equivalent to a connection string of the form host=host1,host2,host3 port=port1,port2,port3. Each host will be tried in turn until a connection is successfully established.

...
If multiple host names are specified, each will be tried in turn in the order given.
--------------------------------------------------

Regards
Takayuki Tsunakawa

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2017-05-19 02:27:51 Re: Get stuck when dropping a subscription during synchronizing table
Previous Message Masahiko Sawada 2017-05-19 02:12:23 Re: Moving relation extension locks out of heavyweight lock manager