Re: Referential Integrity and SHARE locks

Поиск
Список
Период
Сортировка
От Csaba Nagy
Тема Re: Referential Integrity and SHARE locks
Дата
Msg-id 1170411255.3101.75.camel@coppola.muc.ecircle.de
обсуждение исходный текст
Ответ на Referential Integrity and SHARE locks  ("Simon Riggs" <simon@2ndquadrant.com>)
Ответы Re: Referential Integrity and SHARE locks
Список pgsql-hackers
On Fri, 2007-02-02 at 10:51, Simon Riggs wrote:
[snip]
> Why do we need a SHARE lock at all, on the **referenc(ed)** table?
> 
> It sounds like if we don't put a SHARE lock on the referenced table then
> we can end the transaction in an inconsistent state if the referenced
> table has concurrent UPDATEs or DELETEs. BUT those operations do impose
> locking rules back onto the referencing tables that would not be granted
> until after any changes to the referencing table complete, whereupon
> they would restrict or cascade. So an inconsistent state doesn't seem
> possible to me.
> 
> What am I missing?

Well, here we do have a patch (deployed on production servers) which
does not put the shared lock on the referenced table, and it lets in
occasionally rows in the referencing tables which do not have parent
rows in the referenced table. I'm not sure what is the mechanism, but it
does happen, I can assure you. It happens rare enough that is not
disturbing for us, compared to the deadlocks which happen without the
patch - that's another matter...

In our application we never update any key ids, so only deletes/inserts
come in play, and I guess it happens when a referenced row is deleted
just between a newly inserted child row checks that the parent row
exists and the row is really inserted. Or something like that...

Cheers,
Csaba.




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

Предыдущее
От: Richard Huxton
Дата:
Сообщение: Re: Function proposal to find the type of a datum
Следующее
От: Richard Huxton
Дата:
Сообщение: Re: Referential Integrity and SHARE locks