Re: ATTACH/DETACH PARTITION CONCURRENTLY
David Rowley <david.rowley@2ndquadrant.com>
From: David Rowley <david.rowley@2ndquadrant.com>
To: Robert Haas <robertmhaas@gmail.com>
Cc: Michael Paquier <michael@paquier.xyz>,
Alvaro Herrera <alvherre@2ndquadrant.com>, Sergei Kornilov <sk@zsrv.org>, Amit Langote <langote_amit_f8@lab.ntt.co.jp>, Andres Freund <andres@anarazel.de>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>,
Simon Riggs <simon@2ndquadrant.com>
Date: 2018-12-24T22:58:08Z
Lists: pgsql-hackers
On Tue, 25 Dec 2018 at 08:15, Robert Haas <robertmhaas@gmail.com> wrote: > > On Fri, Dec 21, 2018 at 6:04 PM David Rowley > <david.rowley@2ndquadrant.com> wrote: > > I don't think you need to qsort() the Oids before locking. What the > > qsort() does today is ensure we get a consistent locking order. Any > > other order would surely do, providing we stick to it consistently. I > > think PartitionDesc order is fine, as it's consistent. Having it > > locked in PartitionDesc order I think is what's needed for [1] anyway. > > [2] proposes to relax the locking order taken during execution. > > If queries take locks in one order and DDL takes them in some other > order, queries and DDL starting around the same time could deadlock. > Unless we convert the whole system to lock everything in PartitionDesc > order the issue doesn't go away completely. But maybe we just have to > live with that. Surely we're not going to pay the cost of locking > partitions that we don't otherwise need to avoid a deadlock-vs-DDL > risk, and once we've decided to assume that risk, I'm not sure a > qsort() here helps anything much. When I said "consistent" I meant consistent over all places where we obtain locks on all partitions. My original v1-0002 patch attempted something like this. -- David Rowley http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, 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