Re: ATTACH/DETACH PARTITION CONCURRENTLY
Simon Riggs <simon@2ndquadrant.com>
From: Simon Riggs <simon@2ndquadrant.com>
To: Andres Freund <andres@anarazel.de>
Cc: David Rowley <david.rowley@2ndquadrant.com>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2018-08-07T13:00:10Z
Lists: pgsql-hackers
On 7 August 2018 at 13:47, Andres Freund <andres@anarazel.de> wrote: > Hi, > > On 2018-08-08 00:40:12 +1200, David Rowley wrote: >> 1. Obtain a ShareUpdateExclusiveLock on the partitioned table rather >> than an AccessExclusiveLock. >> 2. Do all the normal partition attach partition validation. >> 3. Insert pg_partition record with partvalid = true. >> 4. Invalidate relcache entry for the partitioned table >> 5. Any loops over a partitioned table's PartitionDesc must check >> PartitionIsValid(). This will return true if the current snapshot >> should see the partition or not. The partition is valid if partisvalid >> = true and the xmin precedes or is equal to the current snapshot. > > How does this protect against other sessions actively using the relcache > entry? Currently it is *NOT* safe to receive invalidations for > e.g. partitioning contents afaics. I think you may be right in the general case, but ISTM possible to invalidate/refresh just the list of partitions. If so, that idea would seem to require some new, as-yet not invented mechanism. -- Simon Riggs http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
Commits
-
Allow ATTACH PARTITION with only ShareUpdateExclusiveLock.
- 898e5e3290a7 12.0 landed
-
Change lock acquisition order in expand_inherited_rtentry.
- f4b6341d5fcb 12.0 landed
-
Move code for managing PartitionDescs into a new file, partdesc.c
- 1bb5e7821810 12.0 landed
-
Remove more redundant relation locking during executor startup.
- f2343653f5b2 12.0 cited
-
Add assertions that we hold some relevant lock during relation open.
- b04aeb0a053e 12.0 cited
-
Try to acquire relation locks in RangeVarGetRelid.
- 4240e429d0c2 9.2.0 cited