Robert Haas <robertmh...@gmail.com> writes: > What sort of random things would someone do with pageinspect functions > that would hold buffer pins on one buffer while locking another one? > The functions in hashfuncs.c don't even seem like they would access > multiple buffers in total, let alone at overlapping times. And I don't > think that a query pageinspect could realistically be suspended while > holding a buffer pin either. If you wrapped it in a cursor it'd be > suspended before or after accessing any given buffer, not right in the > middle of that operation.
pin != access. Unless things have changed really drastically since I last looked, a seqscan will sit on a buffer pin throughout the series of fetches from a single page. Admittedly, that's about *heap* page pins while indexscans have different rules. But I recall that btrees at least use persistent pins as well. It may be that there is indeed no way to make this happen with available SQL tools. But I wouldn't put a lot of money on that, and even less that it'll stay true in the future. Having said that, you're right that this is qualitatively different from the other bug, in that this is a deadlock not apparent data corruption. However, IIUC it's an LWLock deadlock, which we don't handle all that nicely. regards, tom lane