Re: LISTEN considered dangerous

Поиск
Список
Период
Сортировка
От Martijn van Oosterhout
Тема Re: LISTEN considered dangerous
Дата
Msg-id 20060802054528.GA29699@svana.org
обсуждение исходный текст
Ответ на Re: LISTEN considered dangerous  (Gregory Stark <gsstark@mit.edu>)
Ответы Re: LISTEN considered dangerous  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: LISTEN considered dangerous  (Flemming Frandsen <ff@partyticket.net>)
Список 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.

Вложения

В списке pgsql-general по дате отправления:

Предыдущее
От: "Joshua D. Drake"
Дата:
Сообщение: Re: Best Procedural Language?
Следующее
От: Flemming Frandsen
Дата:
Сообщение: Re: LISTEN considered dangerous