Re: Strange locking choices in pg_shdepend.c

Поиск
Список
Период
Сортировка
От Alvaro Herrera
Тема Re: Strange locking choices in pg_shdepend.c
Дата
Msg-id 20080121223127.GE12482@alvh.no-ip.org
обсуждение исходный текст
Ответ на Strange locking choices in pg_shdepend.c  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: Strange locking choices in pg_shdepend.c  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: Strange locking choices in pg_shdepend.c  (Alvaro Herrera <alvherre@alvh.no-ip.org>)
Список pgsql-hackers
Tom Lane wrote:
> 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.

Hmm, I can't recall nor deduce any reason for that.  Perhaps the
intention was to protect against itself; but I think this should only
matter if we're dropping the same role concurrently (otherwise the
to-be-dropped objects would be disjoint sets, so it doesn't matter),
which should be already protected by the lock on the role itself.

Hmm, unless revoking privileges concurrently, for two different users on
the same object could cause a problem?  I don't see us grabbing a lock
on the object itself -- does this matter?


> 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.

Huh, correct.  I think this was just an oversight.

-- 
Alvaro Herrera                                http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Alvaro Herrera
Дата:
Сообщение: Re: [GENERAL] setof record "out" syntax and returning records
Следующее
От: Tom Lane
Дата:
Сообщение: Thoughts about bug #3883