From: Victor Wagner <vitus@wagner.pp.ru>
To: pgsql-hackers@postgresql.org
Subject: Re: Patch: Implement failover on libpq connect level.
Date: Thu, 5 Nov 2015 18:12:35 +0300
Message-ID: <20151105151235.GA21434@wagner.pp.ru> (raw)
In-Reply-To: <56379A44.9080609@gmx.net>
References: <20150818041850.GA5092@wagner.pp.ru>
<20151014104151.GA6744@wagner.pp.ru>
<562E8C55.9030409@gmx.net>
<20151028111839.6e73c68a@fafnir>
<56327381.5040108@gmx.net>
<CA+TgmoY8J2Jp1fM4EmtU6=3hHLpHc9+qyOJW3OgCNRN6QTgyDg@mail.gmail.com>
<56379A44.9080609@gmx.net>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>
On 2015.11.02 at 12:15:48 -0500, Peter Eisentraut wrote:
>> That's true, but doesn't allowing every parameter to be multiply
>> specified greatly increase the implementation complexity for a pretty
>> marginal benefit?
>Well, the way I would have approached is that after all the parsing you
>end up with a list of PQconninfoOption arrays and you you loop over that
>list and call connectDBStart() until you have a connection that
>satisfies you.
>I see that the patch doesn't do that and it looks quite messy as a
>result.
There are some drawbacks with this approach
1. You are suggesting usage of two nested loops, instead of one straight
loop - outer loop over the URLs in the connect string, inner loop over
the IP addresses each URL resolves into. (This inner loop already
presents there for several versions of the postgres).
2. You are suggesting that it should be possible to specify all options
separately for each of the fallback hosts.
But some options control how
next host should be choosen (i.e. use random order for load-balancing
or sequential order for high availability), so they should be specified
only once per connect string.
Some other options are
connection level rather then node-level (i.e. if you are using
replication mode of the connection, there is no sense to specify it for
one host and not specify for other). These options should be better
specified such way, that it would be not possible to use conflicting
values.
Third category of options are specified per-cluster much more often
than per node. But are quite often changed from compiled in default.
Typically there are authentication credentials (even you use
trigger-based replication, user information would probably be
replicated), database name (if you use WAL-level replication), client
encoding (which depends on more on the client than on server), etc.
It would be pain if we would need specify them for each host separately.
Syntax, implemented in the my patch allows even to specify
nonstandard-port once for all hosts (using port= parameter in the query
string) and override it for particular host in the list using colon
syntax.
3. Last, but not least. There is more than one postgresql client
implementation. Apart of libpq we have jdbc, native GO language client
etc. And I think that maintaining compatibility of the connect string
between them is good thing. So, I've modelled syntax of multihost
feature in the libpq URL-style syntax after jdbc syntax.
--
Victor Wagner <vitus@wagner.pp.ru>
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: vitus@wagner.pp.ru, pgsql-hackers@postgresql.org
Subject: Re: Patch: Implement failover on libpq connect level.
In-Reply-To: <20151105151235.GA21434@wagner.pp.ru>
References: <20150818041850.GA5092@wagner.pp.ru> <20151014104151.GA6744@wagner.pp.ru> <562E8C55.9030409@gmx.net> <20151028111839.6e73c68a@fafnir> <56327381.5040108@gmx.net> <CA+TgmoY8J2Jp1fM4EmtU6=3hHLpHc9+qyOJW3OgCNRN6QTgyDg@mail.gmail.com> <56379A44.9080609@gmx.net> <20151105151235.GA21434@wagner.pp.ru>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox