Re: hostorder and failover_timeout for libpq - Mailing list pgsql-hackers

From Michael Paquier
Subject Re: hostorder and failover_timeout for libpq
Date
Msg-id 20181001071020.GI11712@paquier.xyz
Whole thread Raw
In response to Re: hostorder and failover_timeout for libpq  (Ildar Musin <ildar@adeven.com>)
Responses Re: hostorder and failover_timeout for libpq  (Dmitry Dolgov <9erthalion6@gmail.com>)
Re: hostorder and failover_timeout for libpq  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On Wed, Sep 19, 2018 at 02:26:53PM +0200, Ildar Musin wrote:
> Another approach would be to leave `pg_conn->connhost` as it is now (i.e.
> not to create global addresses array) and just apply random permutations to
> it if `hostorder=random` is specified. And probably apply permutations to
> addresses list within each individual host.
>
> At this point I'd like to ask community what in your opinion would be the
> best course of action and whether this feature should be implemented within
> libpq at all? Because from my POV there are factors that really depend on
> network architecture and there is probably no single right solution.

As things stand now, when multiple hosts are defined in a connection
string the order specified in the string is used until a successful
connection is done.  When working on Postgres-XC, we have implemented
similar capability at application-level.  However, now that libpq also
supports multi-host capabilities, I could see a point in having
something within libpq.  What could we get though except a random mode
for read-only or read-write load balancing?  This only use case looks a
bit limited to me to rework again the code paths discarding the
connection failures for that though, as there is as well the argument to
tell the application to generate its own connection string based on
libpq properties.  So my take would be to just do that at
application-level and not bother.

By the way, I can see that the latest patch available does not apply at
tries to juggle with multiple concepts.  I can see at least two of them:
failover_timeout and hostorder.  You should split things.  I have moved
the patch to next CF, waiting on author.
--
Michael

Attachment

pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: [HACKERS] Moving relation extension locks out of heavyweightlock manager
Next
From: Michael Paquier
Date:
Subject: Re: Hash Joins vs. Bloom Filters / take 2