Mihail Nikalayeu <mihailnikalayeu@gmail.com> wrote:
> I think I got working POC for deadlock-detector enhancements for
> REPACK (and potentially other).
That looks interesting, I'll check it.
I've also thought about the problem quite a bit this week. I tried to add a
pointer to PGPROC that, like ->waitLock, points to the lock being acquired,
but it's initialized before the actual waiting starts. I adjusted the deadlock
detector to use that pointer too, but it did not work. The problem was
probably that the lock wasn't in the queue during the check.
Finally it occurred to me that a new field can be added to the LOCK structure,
indicating that the lock is being upgraded. It enforces some extra deadlock
checks by other processes, so that the upgrading process does not have to care
about deadlock detection at all. More info in the commit message.
It should handle all the cases in your tests, however a new injection point
would be needed. (Not added yet.)
--
Antonin Houska
Web: https://www.cybertec-postgresql.com