Strange locking choices in pg_shdepend.c - Mailing list pgsql-hackers

From Tom Lane
Subject Strange locking choices in pg_shdepend.c
Date
Msg-id 20137.1200952446@sss.pgh.pa.us
Whole thread Raw
Responses Re: Strange locking choices in pg_shdepend.c  (Alvaro Herrera <alvherre@commandprompt.com>)
Re: Strange locking choices in pg_shdepend.c  (Decibel! <decibel@decibel.org>)
List pgsql-hackers
I came across some rather strange choices of lock levels in pg_shdepend.c.

Why does shdepDropOwned() take AccessExclusiveLock on pg_shdepend?
Seems like RowExclusiveLock should be sufficient.  If it isn't
sufficient, I wonder whether the other functions in here are taking
strong enough locks.

It's probably not a good idea to have shdepReassignOwned() take only
AccessShareLock on pg_shdepend.  Even though the function itself
merely reads the table, it is going to call functions that will take
RowExclusiveLock, meaning that we're setting ourselves up for potential
deadlock failures due to lock-upgrade.  It'd be safer (and faster too)
to just hold RowExclusiveLock through the whole operation.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Polyphase Merge
Next
From: Alvaro Herrera
Date:
Subject: Re: [GENERAL] setof record "out" syntax and returning records