|From:||Robert Haas <robertmhaas(at)gmail(dot)com>|
|To:||Peter van Hardenberg <pvh(at)pvh(dot)ca>|
|Cc:||Peter Eisentraut <peter_e(at)gmx(dot)net>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>|
|Subject:||Re: Patch: Implement failover on libpq connect level.|
|Views:||Raw Message | Whole Thread | Download mbox|
On Mon, Oct 24, 2016 at 11:57 AM, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
> So now I think that to make this work correctly, we're going to need
> to change both the URL parser and also add parsing for the host and
> port. Let's say the user says this:
> What I think we need to do is translate that into this:
> host=1::2,4::5,6::7 port=3,,8
So here's a patch implementing that. This seems to work, but I
haven't tested it in incredible detail at this point, so testing from
others would be greatly appreciated (the handling of .pgpass files, in
particular, I have not tested). This is loosely inspired by Victor's
patch but rewritten from scratch to fix the various design issues
which I've commented on in previous emails on this thread.
Some notes on decisions that I made while implementing this:
- Only the host= and port= parameter support multiple, comma-separated
values. In particular, you can only specify a single password.
However, you can still end up with different passwords for connections
to different servers if the passwords are read from .pgpass.
- The PQhost(), PQport(), and PQpass() now functions return the
information for the host to which we actually connected or to the
first one in the list if we haven't tried to connect yet. Looking
through where these functions are actually used in our source code,
this behavior seems more useful than any other I could imagine. On
the other hand, PQreset() will retry the connection starting with the
first host in the original list.
- The hostorder, target_server_type, and failover_timeout parameters
from Victor's patch are not present in this version. I think we can
add those things in future patches once the basic functionality is
committed. Or maybe we'll decide that we don't want those things or
that we want something different instead, which is fine, too. The
point is, they don't need to be there in the first patch.
- As requested, it's an error if you specify N hosts and K port
numbers where N != K. However, K = 1 is always allowed; that is, if
only a single port number is specified, it applies to all hosts.
- I have made an attempt to update the documentation appropriately but
there might be other sections which also need to be adjusted.
Let me know your thoughts.
The Enterprise PostgreSQL Company
|Next Message||Serge Rielau||2016-10-26 15:43:17||Re: Fast Default WIP patch for discussion|
|Previous Message||Tom Lane||2016-10-26 14:20:28||Re: Unused variable in postgres_fdw/deparse.c|
|Next Message||Mithun Cy||2016-10-27 13:46:05||Re: Patch: Implement failover on libpq connect level.|
|Previous Message||Brad DeJong||2016-10-26 12:17:11||Re: setCharacterStream(int, Reader)|