Re: Hard problem with concurrency - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Hard problem with concurrency
Date
Msg-id 1350.1045450734@sss.pgh.pa.us
Whole thread Raw
In response to Hard problem with concurrency  ("Christopher Kings-Lynne" <chriskl@familyhealth.com.au>)
List pgsql-hackers
"Christopher Kings-Lynne" <chriskl@familyhealth.com.au> writes:
> I can't try the insert and then the update because the INSERT, in Postgres,
> will cause an outright transaction failure.

Do the update, then try to insert if the update found nothing, and put
a retry loop around the whole transaction in case you fail because of
concurrent inserts.

Realistically you will need a retry loop in all but the most trivial
cases anyway --- certainly so if you want to use serializable
transaction mode.  So I don't think this solution is unworkably complex.
        regards, tom lane


pgsql-hackers by date:

Previous
From: greg@turnstep.com
Date:
Subject: Re: Hard problem with concurrency
Next
From: "Christopher Kings-Lynne"
Date:
Subject: Re: Hard problem with concurrency