Re: [PATCH] libpq: Allow specifying multiple host names to try to connect to - Mailing list pgsql-hackers
From | Bruce Momjian |
---|---|
Subject | Re: [PATCH] libpq: Allow specifying multiple host names to try to connect to |
Date | |
Msg-id | 20150805145310.GB13687@momjian.us Whole thread Raw |
In response to | Re: [PATCH] libpq: Allow specifying multiple host names to try to connect to (Robbie Harwood <rharwood@redhat.com>) |
Responses |
Re: [PATCH] libpq: Allow specifying multiple host names to
try to connect to
|
List | pgsql-hackers |
On Wed, Jul 8, 2015 at 12:24:37PM -0400, Robbie Harwood wrote: > > You update the documentation just for psql but your change effects any > > libpq application if we go forward with this patch we should update the > > documentation for libpq as well. > > > > This approach seems to work with the url style of conninfo > > > > For example > > postgres://some-down-host.info,some-other-host.org:5435/test1 > > > > seems to work as expected but I don't like that syntax I would rather see > > postgres://some-down-host.info:5435/test1,postgres://some-other-host.org:5435/test1 > > > > This would be a more invasive change but I think the syntax is more usable. > > I agree with this; it seems to me that it's more powerful to be able to > specify complete urls for when they may differ. > > For the non-url case though, I don't see a clean way of doing this. We > could always, e.g., locally bind port specification to the closest host > specification, but that seems nasty, and is still less powerful than > passing urls (or we could just do the same for all parameters, but > that's just a mess). > > Might it be reasonable to only allow the multi-host syntax in the > url-style and not otherwise? First, I agree this is a very useful feature that we want. Many NoSQL databases are promoting multi-host client libraries as HA, which is kind of humorous, and also makes sense because many NoSQL solution are multi-host. I can see this feature benefitting us for clients to auto-failover without requiring a pooler or virtual IP reassignment, and also useful for read-only connections that want to connect to a read-only slave, but don't care which one. The idea of randomly selecting a host from the list might be a future feature. I agree we should allow the specification of multiple hosts, e.g. -h "host1,host2", but anything more complex should require the URL syntax, and require full URLs separated by commas, not commas inside a single URL to specify multiple host names, as shown above. If repeating information inside each URL is a problem, the user can still use connections-specific options to controls things, e.g. by using -p 5433, it is not necessary to specify the port number in the URLs: $ psql -p 5433 postgres://localhost/test,postgres://localhost/test2 I realize this is libpq-feature-creep, but considering the complexities of a pooler and virtual IP address reassignment, I think adding this makes sense. The fact that other DBs are doing it, including I think VMWare's libpq, supports the idea of adding this simple specification. Can someone work on a patch to implement this? -- Bruce Momjian <bruce@momjian.us> http://momjian.us EnterpriseDB http://enterprisedb.com + Everyone has their own god. +
pgsql-hackers by date: