Re: Patch: Implement failover on libpq connect level.

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Mithun Cy <mithun(dot)cy(at)enterprisedb(dot)com>
Cc: Catalin Iacob <iacobcatalin(at)gmail(dot)com>, "Tsunakawa, Takayuki" <tsunakawa(dot)takay(at)jp(dot)fujitsu(dot)com>, Craig Ringer <craig(at)2ndquadrant(dot)com>, Peter van Hardenberg <pvh(at)pvh(dot)ca>, 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.
Date: 2016-11-29 17:37:06
Message-ID: CA+Tgmoa4TjO_mSzXHXObRqU9QSqnhR0cf27E-zOYnomw7ugXDQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-jdbc

On Thu, Nov 24, 2016 at 7:16 AM, Mithun Cy <mithun(dot)cy(at)enterprisedb(dot)com> wrote:
> On Wed, Nov 23, 2016 at 10:19 PM, Catalin Iacob <iacobcatalin(at)gmail(dot)com>
> wrote:
> On Tue, Nov 22, 2016 at 8:38 AM, Tsunakawa, Takayuki
> <tsunakawa(dot)takay(at)jp(dot)fujitsu(dot)com> wrote:
> >> If you want to connect to a server where the transaction is read-only,
> then shouldn't the connection parameter be something like
>>>"target_session_attrs=readonly"? That represents exactly what the code
> does.
>
> >FWIW I find this to be a reasonable compromise. To keep the analogy
> >with the current patch it would be more something like
> "target_session_attrs=read_write|any".
>
> I have taken this suggestion now renamed target_server_type to
> target_session_attrs with possible 2 values "read-write", "any".

I didn't hear any objections to this approach and, after some thought,
I think it's good. So I've committed this after rewriting the
documentation, some cosmetic cleanup, and changing the logic so that
if one IP for a host turns out to be read-only, we skip all remaining
IPs for that host, not just the one that we tested already. This
seems likely to be what users will want.

I recognize that this isn't going to be please everybody 100%, but
there's still room for followup patches to improve things further.
One thing I really like about the target_session_attrs renaming is
that it seems to leave the door open to a variety of things we might
want to do later. The "read-write" value we now support is closely
related to the query we use for testing ("show
transaction_read_only"). If we later want to filter based on some
other server property, we can add additional values with associated
SQL commands for each. Of course that could get a little crazy if
overdone, but hopefully we won't overdo it.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2016-11-29 17:50:31 Re: Proposal: scan key push down to heap [WIP]
Previous Message Peter Eisentraut 2016-11-29 17:16:37 Re: move collation import to backend

Browse pgsql-jdbc by date

  From Date Subject
Next Message Kuntal Ghosh 2016-11-29 19:19:13 Re: Patch: Implement failover on libpq connect level.
Previous Message Jorge Solórzano 2016-11-29 16:57:54 Re: Versioning policy PgJDBC - discussion