On Wed, 14 Apr 2021 at 10:41, Craig Ringer <craig.rin...@enterprisedb.com> wrote: > On Wed, 14 Apr 2021 at 02:25, Robert Haas <robertmh...@gmail.com> wrote: > > You could try to identify locks by pointer addresses, but that's got > > security hazards and the addreses aren't portable across all the > > backends involved in the parallel query because of how DSM works, so > > it's not really that helpful in terms of matching stuff up. > > What I'm doing now is identifying them by LWLock* across backends. I > keep track of DSM segment mappings in each backend inside the trace > script and I relocate LWLock* pointers known to be inside DSM segments > relative to a dummy base address so they're equal across backends.
BTW, one of the reasons I did this was to try to identify BDR and pglogical code that blocks or sleeps while holding a LWLock. I got stuck on that for other reasons, so it didn't go anywhere, but those issues are now resolved so I should probably return to it at some point. It'd be a nice thing to be able to run on postgres itself too.