Re: [HACKERS] [PATCH v2] Add and report the new "session_read_only" GUC pseudo-variable.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Melanie Plageman <melanieplageman(at)gmail(dot)com>
Cc: Elvis Pranskevichus <elprans(at)gmail(dot)com>, andres(at)anarazel(dot)de, Michael Paquier <michael(dot)paquier(at)gmail(dot)com>, daniel(at)yesql(dot)se, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>, "Tsunakawa, Takayuki" <tsunakawa(dot)takay(at)jp(dot)fujitsu(dot)com>, Thomas Munro <thomas(dot)munro(at)enterprisedb(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Craig Ringer <craig(at)2ndquadrant(dot)com>, Magnus Hagander <magnus(at)hagander(dot)net>, Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>, Michael Banck <michael(dot)banck(at)credativ(dot)de>
Subject: Re: [HACKERS] [PATCH v2] Add and report the new "session_read_only" GUC pseudo-variable.
Date: 2018-11-12 18:08:37
Message-ID: 26312.1542046117@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Melanie Plageman <melanieplageman(at)gmail(dot)com> writes:
> On Mon, Sep 24, 2018 at 9:28 AM Elvis Pranskevichus <elprans(at)gmail(dot)com>
> wrote:
>> Sorry for the long silence on this. I'm attaching a rebased and
>> cleaned-up patch with the earlier review issues addressed. I've checked
>> all relevant tests and verified manually.

> After taking a look at the updated patch, it appears to address the review
> feedback which I provided. However, the patch didn't apply cleanly for me,
> so it likely needs a quick look along with a rebase.

It looks like the one apply failure is due to the patch having corrected
a comment that somebody else already corrected. So no big deal there.

Looking through the thread, it seems like there's a pretty fundamental
design issue that hasn't been resolved, namely whether and how this ought
to interact with default_transaction_read_only. The patch as it stands
seems to be trying to implement the definition that the transmittable
variable session_read_only is equal to "!(DefaultXactReadOnly ||
RecoveryInProgress())". I doubt that that's a good idea. In the first
place, it's not at all clear that such a flag is sufficient for all
use-cases. In the second, it's somewhere between difficult and impossible
to correctly implement GUCs that are interdependent in that way; the
current patch certainly fails to do so. (It will not correctly track
intra-session changes to DefaultXactReadOnly, for instance.)

I think that we'd be better off maintaining a strict separation between
"in hot standby" and default_transaction_read_only. If there are use
cases in which people would like to reject connections based on either
one being true, let's handle that by marking them both GUC_REPORT, and
having libpq check both. (So there need to be two flavors of
target-session-attrs libpq parameter, depending on whether you want
"in hot standby" or "currently read only" to be checked.)

That puts us back to having to choose an appropriate GUC name, because
"session_read_only" isn't it :-(. Don't have any better ideas about
that than what's been discussed in the thread.

I'm also not terribly happy with the patch adding a whole new
cross-backend signaling mechanism for this; surely we don't really
need that. Perhaps it'd be sufficient to transmit SIGHUP and embed
the check for "just exited hot standby" in the handling for that?

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2018-11-12 18:23:32 Re: Libpq support to connect to standby server as priority
Previous Message Tom Lane 2018-11-12 16:50:53 Re: NULL handling in exconfig deconstruction