Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Pgsql General > Foreign keys ca...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 6 Topic 15126 of 17637
Post > Topic >>

Foreign keys causing conflicts leading to serialization failures

by peter.schuller@[EMAIL PROTECTED] (Peter Schuller) Apr 1, 2008 at 07:48 PM

--C7zPtVaVf+AK4Oqc
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Hello,

Using PostgreSQL 8.2, I have "atable" one of whose columns reference a
column in "othertable". I see serialization failures as a result of
*inserts* to atable in the context of:

  '"SELECT 1 FROM ONLY othertable x WHERE "otherid" =3D $1 FOR SHARE OF
  x" ' in 'INSERT INTO atable (otherid, col2, col3) VALUES (.., ..,
  ..)'

My interpretation is that the acquisition of a lock on the row in
question is due to the enforcement of the foreign key constraint, and
that, combined with the fact that this locking is performed on a
per-row level, this creates a conflict with any concurrent transaction
updating that row in othertable, regardless of whether 'otherid' is
touched.

First off, is this correct?

If yes:

To me, it would be advantegous if "bogus" conflicts were not generated
like this. Although I realize that serializable transactions are
subject to retries, one still tends to design transactions
specifically to avoid generating conflicts. It is useful to know that
a particular transaction is guaranteed to not generate serialization
failures. And if that is not possible, than at least minimizing the
risk is useful. Normally, an INSERT is conflict-free and it would be
nice to keep it that way.

Unfortunately, the introduction of enforced referential integrity has
this negative side effect.

If my interpretation above is correct; is the use of row-level locking
due to:

(1) it being mandated by a standard?
(2) "cell"-level beinginefficient?
(3) no one having implemented "cell"-level locking?
(4) there being a problem with having a DELETE correctly
    conflict with a "cell"-level lock?
(*) something else?

In short, I am wondering whether this behavior is intended or a
side-efffect of implementation details.

--=20
/ Peter Schuller

PGP userID: 0xE9758B7D or 'Peter Schuller <peter.schuller@[EMAIL PROTECTED]
>'
Key retrieval: Send an E-Mail to getpgpkey@[EMAIL PROTECTED]
 peter.schuller@[EMAIL PROTECTED]
 Web: http://www.scode.org


--C7zPtVaVf+AK4Oqc
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.8 (FreeBSD)

iEYEARECAAYFAkfydYIACgkQDNor2+l1i31wvwCffFDzcs8jU4MJsomL3Eksa4p9
zlAAnR+R5p2cFbxjzPmkLRzCr9lHV4SF
=FzYh
-----END PGP SIGNATURE-----

--C7zPtVaVf+AK4Oqc--
 




 6 Posts in Topic:
Foreign keys causing conflicts leading to serialization failures
peter.schuller@[EMAIL PRO  2008-04-01 19:48:51 
Re: Foreign keys causing conflicts leading to serialization fail
laurenz.albe@[EMAIL PROTE  2008-04-02 11:49:24 
Re: Foreign keys causing conflicts leading to
peter.schuller@[EMAIL PRO  2008-04-02 13:56:31 
Re: Foreign keys causing conflicts leading toserialization failu
laurenz.albe@[EMAIL PROTE  2008-04-02 14:18:25 
Re: Foreign keys causing conflicts leading toserialization failu
tgl@[EMAIL PROTECTED] (T  2008-04-02 11:33:35 
Re: Foreign keys causing conflicts leading toserialization failu
laurenz.albe@[EMAIL PROTE  2008-04-03 09:25:57 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Dec 5 7:19:01 CST 2008.