Re: LISTEN considered dangerous - Mailing list pgsql-general

From Martijn van Oosterhout
Subject Re: LISTEN considered dangerous
Date
Msg-id 20060802054528.GA29699@svana.org
Whole thread Raw
In response to Re: LISTEN considered dangerous  (Gregory Stark <gsstark@mit.edu>)
Responses Re: LISTEN considered dangerous  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: LISTEN considered dangerous  (Flemming Frandsen <ff@partyticket.net>)
List pgsql-general
On Tue, Aug 01, 2006 at 07:50:19PM -0400, Gregory Stark wrote:
> > > However that just doesn't work, because listen is broken, allow me to
> > > illustrate, here A and B are two clients:
> > >
> > > A: BEGIN
> > > A: SELECT * FROM foo and cache the result.
> > > A: LISTEN foochange
> > > B: BEGIN
> > > B: update foo
> > > B: NOTIFY foochange
> > > B: COMMIT
> > > A: COMMIT

> I haven't used LISTEN/NOTIFY myself yet and I do indeed find the behaviour he
> shows somewhat surprising. Normally in read-committed mode uncommitted
> transactions are affected by other transactions when they commit. In this case
> the uncommitted LISTEN is not being affected by the committed NOTIFY.

Eh? At the point the LISTEN is run, the NOTIFY hasn't committed, so a
row is inserted. At the time the NOTIFY is committed, the LISTEN hasn't
committed yet so won't be visible. Only LISTEN is stored, not NOTIFY so
there's nothing wrong with the read-committed semantics.

It's slightly surprising though. I havn't seen anyone else complain
about this before though. The only way to fix this is to make the
LISTEN completely atransactional, so NOTIFY can see uncomitted LISTENs
also.

Have a nice day,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.

Attachment

pgsql-general by date:

Previous
From: "Joshua D. Drake"
Date:
Subject: Re: Best Procedural Language?
Next
From: Flemming Frandsen
Date:
Subject: Re: LISTEN considered dangerous