Re: Libpq support to connect to standby server as priority

From: vignesh C <vignesh21(at)gmail(dot)com>
To: Greg Nancarrow <gregn4422(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, Anastasia Lubennikova <a(dot)lubennikova(at)postgrespro(dot)ru>, Peter Smith <smithpb2250(at)gmail(dot)com>, "Smith, Peter" <peters(at)fast(dot)au(dot)fujitsu(dot)com>, David Steele <david(at)pgmasters(dot)net>, "Tsunakawa, Takayuki" <tsunakawa(dot)takay(at)fujitsu(dot)com>, Haribabu Kommi <kommi(dot)haribabu(at)gmail(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>, Dave Cramer <pg(at)fastcrypt(dot)com>, Jing Wang <jingwangian(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, Elvis Pranskevichus <elprans(at)gmail(dot)com>
Subject: Re: Libpq support to connect to standby server as priority
Date: 2021-02-10 06:07:26
Message-ID: CALDaNm2JeSU4eA1b3-zSikcaOYEOFM5QYniQ3=ycuH9oP_=PVg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Feb 9, 2021 at 5:47 AM Greg Nancarrow <gregn4422(at)gmail(dot)com> wrote:
>
> On Mon, Feb 8, 2021 at 8:17 PM vignesh C <vignesh21(at)gmail(dot)com> wrote:
> >
> > >
> > > I think what we want to do is mark default_transaction_read_only as
> > > GUC_REPORT, instead. That will give a reliable report of what the
> > > state of its GUC is, and you can combine it with is_hot_standby
> > > to decide whether the session should be considered read-only.
> > > If you don't get those two GUC values during connection, then you
> > > can fall back on "SHOW transaction_read_only".
> > >
> >
> > I have made a patch for the above with the changes suggested and
> > rebased it with the head code.
> > Attached v21 patch which has the changes for the same.
> > Thoughts?
> >
>
> I'm still looking at the patch code, but I noticed that the
> documentation update describing how support of read-write transactions
> is determined isn't quite right and it isn't clear how the parameters
> work.
> I'd suggest something like the following (you'd need to fix the line
> lengths and line-wrapping appropriately) - please check it for
> correctness:
>
> <para>
> The support of read-write transactions is determined by the value of the
> <varname>default_transaction_read_only</varname> and
> <varname>in_hot_standby</varname> configuration parameters,
> that, if supported,
> are reported by the server upon successful connection. If the
> value of either
> of these parameters is <literal>on</literal>, it means the
> server doesn't support
> read-write transactions. If either/both of these parameters
> are not reported,
> then the support of read-write transactions is determined by
> an explicit query,
> by sending <literal>SHOW transaction_read_only</literal> after
> successful
> connection; if it returns <literal>on</literal>, it means the
> server doesn't
> support read-write transactions. The standby mode state is
> determined by either
> the value of the <varname>in_hot_standby</varname> configuration
> parameter, that is reported by the server (if supported) upon
> successful connection, or is otherwise explicitly queried by sending
> <literal>SELECT pg_is_in_recovery()</literal> after successful
> connection; if it returns <literal>t</literal>, it means the server is
> in hot standby mode.
> </para>

Thanks Greg for the comments, Please find the attached v22 patch
having the fix for the same.
Thoughts?

Regards,
Vignesh

Attachment Content-Type Size
v22-0001-Enhance-the-libpq-target_session_attrs-connectio.patch text/x-patch 37.9 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message vignesh C 2021-02-10 06:09:48 Re: Libpq support to connect to standby server as priority
Previous Message Michael Paquier 2021-02-10 06:06:45 Re: Online checksums patch - once again