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