Robert Haas <robertmh...@gmail.com> writes: > On Wed, Feb 20, 2019 at 11:03 AM Tom Lane <t...@sss.pgh.pa.us> wrote: >> What I was wondering about was the possibility of the set of >> tables-that-need-to-be-locked-at-all changing. Maybe that won't >> create an issue either, but I'm not quite sure.
> That's pretty much what I was thinking, too. I think it might be fair > to say, however, that if it does give rise to deadlock situations, > they will be corner cases. For instance, suppose you lock are busy > locking top-down and, meanwhile, somebody detaches a partition you > haven't gotten around to locking yet and tries to attach it someplace > higher up in the partition hierarchy. I think that there's a > more-or-less unavoidable deadlock there. And there may be other cases > where it is practically avoidable but we will fail to avoid it. But I > don't think it's such a common scenario that we have two concurrent > DDL commands on the same partitioning hierarchy that we should stress > about it too much. If the common cases work OK, a theoretical > deadlock risk in some more obscure case seems acceptable to me, if it > means we get a significant performance boost. I agree that any deadlock would have to involve somebody doing something quite odd --- not just one partition-oriented operation, but something taking multiple strong locks without regard to the partition structure. So I don't see a problem with taking that risk; people doing that sort of thing are probably at risk of deadlocks no matter what we do here. Looking at the patch itself, I agree that a bit more attention to comments is needed, and I wonder whether David has found all the places where it's now necessary to s/NoLock/RowExclusiveLock/. I don't have any other objections. regards, tom lane