Re: ATTACH/DETACH PARTITION CONCURRENTLY
Amit Langote <langote_amit_f8@lab.ntt.co.jp>
From: Amit Langote <Langote_Amit_f8@lab.ntt.co.jp>
To: Robert Haas <robertmhaas@gmail.com>,
David Rowley <david.rowley@2ndquadrant.com>
Cc: Alvaro Herrera <alvherre@2ndquadrant.com>,
Andres Freund <andres@anarazel.de>,
PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>,
Simon Riggs <simon@2ndquadrant.com>
Date: 2018-11-15T02:03:07Z
Lists: pgsql-hackers
Attachments
- 0001-Reduce-unnecessary-list-construction-in-RelationBuil.patch (text/plain) patch 0001
- 0002-Ensure-that-RelationBuildPartitionDesc-sees-a-consis.patch (text/plain) patch 0002
On 2018/11/15 4:27, Robert Haas wrote: > RelationBuildPartitionDesc doesn't lock the children > whose relpartbounds it is fetching (!), so unless we're guaranteed to > have already locked them children earlier for some other reason, we > could grab the partition bound at this point and then it could change > again before we get a lock on them. Hmm, I think that RelationBuildPartitionDesc doesn't need to lock a partition before fetching its relpartbound, because the latter can't change if the caller is holding a lock on the parent, which it must be if we're in RelationBuildPartitionDesc for parent at all. Am I missing something? As Michael pointed out, the first cleanup patch needs to be rebased due to a recent commit [1]. I did that to see if something we did in that commit made things worse for your patch, but seems fine. I had to go and change things outside RelationBuildPartitionDesc as I rebased, due to the aforementioned commit, but they're simple changes such as changing List * arguments of some newly added functions to PartitionBoundSpec **. Please find the rebased patches attached with this email. Thanks, Amit [1] https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=b52b7dc2
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