RE: foreign key check makes a big LOCK
Vadim Mikheev <vmikheev@sectorbase.com>
From: "Mikheev, Vadim" <vmikheev@SECTORBASE.COM>
To: "'sygma@marr.irisz.hu'" <sygma@marr.irisz.hu>, "'pgsql-bugs@postgresql.org'" <pgsql-bugs@postgresql.org>
Cc: "'janwieck@Yahoo.com'" <janwieck@Yahoo.com>, "'pgsql-hackers@postgresql.org'" <pgsql-hackers@postgresql.org>
Date: 2000-12-05T20:59:50Z
Lists: pgsql-bugs, pgsql-hackers
> Short Description > foreign key check makes a big LOCK > > Long Description > in: src/backend/utils/adt/ri_triggers.c > > RI_FKey_check(), RI_FKey_noaction_upd(), RI_FKey_noaction_del(), etc.. > checking the referential with SELECT FOR UPDATE. > > After BEGIN TRANSACTION: the INSERT/DELETE/UPDATE calling > foreign-key checks, and the SELECT FOR UPDATE locking ALL > matched rows in referential table. > > I modify ri_triggers.c (remove "FOR UPDATE"). This working.. > but is correct? It's not. If one transaction inserts FK 1 and another one deletes PK 1 at the same time both will succeed. RI triggers should perform dirty reads (and test if returned tuples alive/dead/being updated by concurrent transaction) instead of SELECT FOR UPDATE but dirty reads are not implemented, yet. Vadim