Re: Solution to UPDATE or INSERT Problem - Mailing list pgsql-general

From Tom Lane
Subject Re: Solution to UPDATE or INSERT Problem
Date
Msg-id 20893.1074490456@sss.pgh.pa.us
Whole thread Raw
In response to Solution to UPDATE or INSERT Problem  (Curt Sampson <cjs@cynic.net>)
List pgsql-general
Curt Sampson <cjs@cynic.net> writes:
> On Mon, 19 Jan 2004, Tom Lane wrote:
>> You're quite mistaken.  Have you made any effort to test it?

> Yes. You appear to have changed my code somewhat:
> ...
> Take out that BEGIN.

The BEGIN was merely a convenient way of slowing down operations enough
so that a trivial manual test would expose the problem.  Concurrent
executions of that INSERT/SELECT *will* fail, it's just a matter of
getting them to actually overlap in time.  With BEGIN the window for
concurrency failures is wider than without --- but it's not zero without.

> Yup. You re-created the race condition that I'd gotten rid of when you
> put the INSERT and the UPDATE into the same transaction.

You need to go back and re-read the documentation... the UPDATE does not
actually have anything to do with the failure.

            regards, tom lane

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Compile postgre 7.1 on Redhat 9?
Next
From: Tom Lane
Date:
Subject: Re: Solution to UPDATE or INSERT Problem