pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Andrew Gierth <andrew@tao11.riddles.org.uk>
Cc: Marko Tiikkaja <marko@joh.to>
Cc: pgsql-bugs@lists.postgresql.org, dejan.petrovic@islonline.com, Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
Subject: Re: BUG #15060: Row in table not found when using pg function in an expression
Date: Tue, 13 Feb 2018 09:53:59 -0500
Message-ID: <29608.1518533639@sss.pgh.pa.us> (raw)
In-Reply-To: <87vaf1qfps.fsf@news-spur.riddles.org.uk>
References: <151844034484.1446.1721073839109092583@wrigleys.postgresql.org>
	<876072rphi.fsf@news-spur.riddles.org.uk>
	<12102.1518466287@sss.pgh.pa.us>
	<CAL9smLDF9pZ89LWFgO4BcnMZf15EFiaxAhcnjuamS=HOKb+=NQ@mail.gmail.com>
	<87vaf1qfps.fsf@news-spur.riddles.org.uk>

Andrew Gierth <andrew@tao11.riddles.org.uk> writes:
> "Marko" == Marko Tiikkaja <marko@joh.to> writes:
>  Marko> I'm not sure I understand. When's the snapshot used for planning
>  Marko> actually taken here?

> GetCachedPlan will use either whatever snapshot is already set, if there
> is one, or it will set one of its own (actually at least two: separate
> snapshots for revalidate + parse analysis and for planning).

Hm.  So we could improve on the fix I proposed earlier if there were a
way to tell GetCachedPlan "take a new snapshot even though there is an
active snapshot".  It's still expensive, but at least the code path where
we use an existing generic plan doesn't get any added cost.

CC'ing Peter because of this part:

> The recent introduction of procedures exposes this interesting little
> variation in behavior (pg11 only):
> ...
> I assume that what's going on here is that the commit, which ends the
> transaction in which the DO was invoked and begins a new one, doesn't
> set a new active snapshot in the new transaction, and so planning of the
> perform in the second case is taking new snapshots inside GetCachedPlan.

I find this concerning.  No part of plpgsql, or any other PL, has ever
before executed without the constant presence of an ActiveSnapshot.
It seems likely to me that this will expose, if not outright bugs,
at least strange differences in behavior between "procedure" code and
"function" code.  Perhaps the commit-and-restart-transaction code ought
to include pushing a new ActiveSnapshot.

			regards, tom lane




view thread (11+ messages)  latest in thread

Message-ID: <29608.1518533639@sss.pgh.pa.us>
Permalink:  ../29608.1518533639@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/29608.1518533639@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, andrew@tao11.riddles.org.uk, marko@joh.to, peter.eisentraut@2ndquadrant.com
  Subject: Re: BUG #15060: Row in table not found when using pg function in an expression
  In-Reply-To: <29608.1518533639@sss.pgh.pa.us>
  References: <151844034484.1446.1721073839109092583@wrigleys.postgresql.org> <876072rphi.fsf@news-spur.riddles.org.uk> <12102.1518466287@sss.pgh.pa.us> <CAL9smLDF9pZ89LWFgO4BcnMZf15EFiaxAhcnjuamS=HOKb+=NQ@mail.gmail.com> <87vaf1qfps.fsf@news-spur.riddles.org.uk> <29608.1518533639@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox