Re: notification: pg_notify ?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Neil Conway <nconway(at)klamath(dot)dyndns(dot)org>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: notification: pg_notify ?
Date: 2002-03-23 05:13:21
Message-ID: 23721.1016860401@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Neil Conway <nconway(at)klamath(dot)dyndns(dot)org> writes:
> (1) Use the shared-memory-based buffer scheme you suggested. When a
> backend executes a NOTIFY, it stores it until transaction commit (as in
> current sources). When the transaction commits, it checks to see if
> there would be a buffer overflow if it added the NOTIFY to the buffer --
> if so, it complains loudly to the log, and sleeps. When it awakens, it
> repeats (try to add to buffer; else, sleep).

This is NOT an improvement over the current arrangement. It implies
that a notification might be postponed indefinitely, thereby allowing
listeners to keep using stale data indefinitely.

LISTEN/NOTIFY is basically designed for invalidate-your-cache
arrangements (which is what led into this discussion originally, no?).
In *any* caching arrangement, it is far better to have the occasional
spurious data drop than to fail to drop stale data when you need to.
Accordingly, a forced cache clear is an appropriate response to
overrun of the communications buffer.

I can certainly imagine applications where the messages are too
important to trust to a not-fully-reliable transmission medium;
but I don't think that LISTEN/NOTIFY should be loaded down with
that sort of requirement. You can easily build 100% reliable
(and correspondingly slow and expensive) communications mechanisms
using standard SQL operations. I think the design center for
LISTEN/NOTIFY should be exactly the case of maintaining client-side
caches --- at least that's what I used it for when I had occasion
to use it, several years ago when I first got involved with Postgres.
And for that application, a cheap mechanism that never loses a
notification, but might occasionally over-notify, is just what you
want.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Christopher Kings-Lynne 2002-03-23 09:36:29 Re: SET NULL / SET NOT NULL
Previous Message Neil Conway 2002-03-23 01:03:19 Re: notification: pg_notify ?