Re: LISTEN considered dangerous

From: Flemming Frandsen <ff(at)partyticket(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: LISTEN considered dangerous
Date: 2006-08-02 06:25:45
Message-ID: 44D04569.2010207@partyticket.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Martijn van Oosterhout wrote:
>>>>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
>
> 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.

No, that's all well and good it behaves as you'd expect when you know
how it's implemented, that doesn't make it more usable though.

> It's slightly surprising though. I havn't seen anyone else complain
> about this before though.

I'm likely to do that:)

> The only way to fix this is to make the
> LISTEN completely atransactional, so NOTIFY can see uncomitted LISTENs
> also.

Not at all.

The listen should simply listen for events issued at the start of the
transaction it's executed in.

To do that without timetravel we'd need to store all events from all
transactions, but that's not too bad if it's implemented right.

--
Regards Flemming Frandsen - http://dion.swamp.dk - YAPH

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Flemming Frandsen 2006-08-02 06:34:53 Re: LISTEN considered dangerous
Previous Message Tom Lane 2006-08-02 06:07:26 Re: LISTEN considered dangerous