Re: ATTACH/DETACH PARTITION CONCURRENTLY

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: David Rowley <david(dot)rowley(at)2ndquadrant(dot)com>
Cc: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Michael Paquier <michael(at)paquier(dot)xyz>, Sergei Kornilov <sk(at)zsrv(dot)org>, Amit Langote <langote_amit_f8(at)lab(dot)ntt(dot)co(dot)jp>, Andres Freund <andres(at)anarazel(dot)de>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Simon Riggs <simon(at)2ndquadrant(dot)com>
Subject: Re: ATTACH/DETACH PARTITION CONCURRENTLY
Date: 2018-12-24 19:19:24
Message-ID: CA+TgmoZtwSA1SnjYE+S1G3VvU4gbhDnyxdryei_AaNNMoPbgsQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Dec 21, 2018 at 6:06 PM David Rowley
<david(dot)rowley(at)2ndquadrant(dot)com> wrote:
> > I didn't handle that. If partition pruning relies on nothing changing
> > between planning and execution, isn't that broken regardless of any of
> > this? It's true that with the simple query protocol we'll hold locks
> > continuously from planning into execution, and therefore with the
> > current locking regime we couldn't really have a problem. But unless
> > I'm confused, with the extended query protocol it's quite possible to
> > generate a plan, release locks, and then reacquire locks at execution
> > time. Unless we have some guarantee that a new plan will always be
> > generated if any DDL has happened in the middle, I think we've got
> > trouble, and I don't think that is guaranteed in all cases.
>
> Today the plan would be invalidated if a partition was ATTACHED or
> DETACHED. The newly built plan would get the updated list of
> partitions.

I think you're right, and that won't be true any more once we lower
the lock level, so it has to be handled somehow. The entire plan
invalidation mechanism seems to depend fundamentally on
AccessExclusiveLock being used everywhere, so this is likely to be an
ongoing issue every time we want to reduce a lock level anywhere. I
wonder if there is any kind of systematic fix or if we are just going
to have to keep inventing ad-hoc solutions.

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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2018-12-24 19:46:48 Re: pg_dumpall --exclude-database option
Previous Message Robert Haas 2018-12-24 19:15:42 Re: ATTACH/DETACH PARTITION CONCURRENTLY