Re: Solution to UPDATE or INSERT Problem

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Curt Sampson <cjs(at)cynic(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Solution to UPDATE or INSERT Problem
Date: 2004-01-19 05:34:16
Message-ID: 20893.1074490456@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Curt Sampson <cjs(at)cynic(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2004-01-19 05:37:31 Re: Solution to UPDATE or INSERT Problem
Previous Message Chris Travers 2004-01-19 05:23:52 Re: How should I get started?