Re: simple_heap_update: tuple concurrently updated -- during INSERT

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: SZŰCS Gábor <surrano(at)mailbox(dot)hu>
Cc: "PGH" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: simple_heap_update: tuple concurrently updated -- during INSERT
Date: 2004-06-10 13:57:25
Message-ID: 24065.1086875845@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

"=?iso-8859-2?B?U1rbQ1MgR+Fib3I=?=" <surrano(at)mailbox(dot)hu> writes:
> A final question: as far as you can remember, may this be an issue already
> fixed in later versions?

I should have looked in the code before, because indeed we have a recent
bug fix addressing exactly this issue. Here's the commit message:

2003-09-15 19:33 tgl

* src/: backend/access/heap/heapam.c, backend/commands/async.c,
backend/executor/execMain.c, include/access/heapam.h: Fix
LISTEN/NOTIFY race condition reported by Gavin Sherry. While a
really general fix might be difficult, I believe the only case
where AtCommit_Notify could see an uncommitted tuple is where the
other guy has just unlistened and not yet committed. The best
solution seems to be to just skip updating that tuple, on the
assumption that the other guy does not want to hear about the
notification anyway. This is not perfect --- if the other guy
rolls back his unlisten instead of committing, then he really
should have gotten this notify. But to do that, we'd have to wait
to see if he commits or not, or make UNLISTEN hold exclusive lock
on pg_listener until commit. Either of these answers is
deadlock-prone, not to mention horrible for interactive
performance. Do it this way for now. (What happened to that
project to do LISTEN/NOTIFY in memory with no table, anyway?)

This is in 7.4, but not 7.3.*.

You can duplicate the failure like so (in 7.3):

session one:
listen foo;
begin;
unlisten foo;
session two:
notify foo;
-- hangs
session one:
end;
-- session two now says
WARNING: AbortTransaction and not in in-progress state
ERROR: simple_heap_update: tuple concurrently updated

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2004-06-10 14:26:13 Re: I/O support for composite types
Previous Message Darko Prenosil 2004-06-10 13:29:58 trigger inheritance on inherited tables ?