pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Robert Haas <robertmhaas@gmail.com>
Cc: Etsuro Fujita <fujita.etsuro@lab.ntt.co.jp>
Cc: Ashutosh Bapat <ashutosh.bapat@enterprisedb.com>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Subject: Re: Oddity in handling of cached plans for FDW queries
Date: Wed, 20 Jul 2016 10:15:26 -0400
Message-ID: <27213.1469024126@sss.pgh.pa.us> (raw)
In-Reply-To: <CA+TgmoZLZYg=Ns7HYt1ZGRvX8irUNB3-J-1toAAsXmgEhWsnWg@mail.gmail.com>
References: <d49c1e5b-f059-20f4-c132-e9752ee0113e@lab.ntt.co.jp>
	<CAFjFpRf94+DJOr8pOLUQYgmmOxjonGPhrU4uvo_00BKCZ-fGug@mail.gmail.com>
	<bbd3d81d-1596-b7a6-833d-ddfc6754c82f@lab.ntt.co.jp>
	<CAFjFpRd9rx1kc-Dvm6ogeNKF8C6XxFA-QAH89T08pFHTKCOaFw@mail.gmail.com>
	<6085.1468513930@sss.pgh.pa.us>
	<10736.1468522173@sss.pgh.pa.us>
	<122d7752-7fe4-f561-4348-34b398d46ec1@lab.ntt.co.jp>
	<2270.1468550932@sss.pgh.pa.us>
	<28ab7288-84f5-aab4-3ef7-cf1ca6e9a291@lab.ntt.co.jp>
	<23274.1468589754@sss.pgh.pa.us>
	<8993.1468617909@sss.pgh.pa.us>
	<CA+TgmoZLZYg=Ns7HYt1ZGRvX8irUNB3-J-1toAAsXmgEhWsnWg@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>

Robert Haas <robertmhaas@gmail.com> writes:
> Mumble.  Why, exactly, was this a good idea?  The upside of commit
> 45639a0525a58a2700cf46d4c934d6de78349dac is only that you do fewer
> plan invalidations, but surely that's not a significant benefit for
> most people: user mappings don't change that often.  On the downside,
> there are now cases where joins would have gotten pushed down
> previously and now they won't.  In other words, you've saved some
> replanning activity at the cost of delivering worse plans.  That seems
> pretty suspect to me, although I grant that the scenarios where either
> the old or the new behavior is actually a problem are all somewhat off
> the beaten path.

I think that you are undervaluing the removal of user-mapping-based plan
invalidation.  That was never more than a kluge, and here is the reason:
we have no way to lock user mappings.  The system whereby we invalidate
plans as a consequence of table DDL changes is bulletproof, because we
(re) acquire locks on the tables used in the plan, then check for
invalidation signals, before deciding whether the plan is stale.  The
corresponding scenario where a user mapping changes between that check
and execution time is unprotected, so that we could end up using a plan
that is insecure for the mappings selected at execution.

Another way we could have removed the race condition is the suggestion
made upthread of embedding the user mapping details right into the plan
instead of looking them up afresh at execution.  But I didn't much like
that approach, per upthread discussion.

			regards, tom lane


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers



view thread (19+ messages)  latest in thread

Message-ID: <27213.1469024126@sss.pgh.pa.us>
Permalink:  ../27213.1469024126@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/27213.1469024126@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-hackers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, robertmhaas@gmail.com, fujita.etsuro@lab.ntt.co.jp, ashutosh.bapat@enterprisedb.com
  Subject: Re: Oddity in handling of cached plans for FDW queries
  In-Reply-To: <27213.1469024126@sss.pgh.pa.us>
  References: <d49c1e5b-f059-20f4-c132-e9752ee0113e@lab.ntt.co.jp> <CAFjFpRf94+DJOr8pOLUQYgmmOxjonGPhrU4uvo_00BKCZ-fGug@mail.gmail.com> <bbd3d81d-1596-b7a6-833d-ddfc6754c82f@lab.ntt.co.jp> <CAFjFpRd9rx1kc-Dvm6ogeNKF8C6XxFA-QAH89T08pFHTKCOaFw@mail.gmail.com> <6085.1468513930@sss.pgh.pa.us> <10736.1468522173@sss.pgh.pa.us> <122d7752-7fe4-f561-4348-34b398d46ec1@lab.ntt.co.jp> <2270.1468550932@sss.pgh.pa.us> <28ab7288-84f5-aab4-3ef7-cf1ca6e9a291@lab.ntt.co.jp> <23274.1468589754@sss.pgh.pa.us> <8993.1468617909@sss.pgh.pa.us> <CA+TgmoZLZYg=Ns7HYt1ZGRvX8irUNB3-J-1toAAsXmgEhWsnWg@mail.gmail.com> <27213.1469024126@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