Re: Who is LISTENing?

From: Jasen Betts <jasen(at)xnet(dot)co(dot)nz>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Who is LISTENing?
Date: 2012-10-16 12:18:55
Message-ID: k5jjbf$jk5$1@reversiblemaps.ath.cx
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 2012-10-15, rektide <rektide(at)voodoowarez(dot)com> wrote:
> Hi pgsql-general,
>
> I'm interested in writing a supervisory process that can insure worker processes are
> running/spawn new ones if not. These workers will mainly be responsible for LISTENing to
> the db, which is emitting triggered_change_notification s.
>
> Is there any means to check a NOTIFY queue to see who or if anyone is LISTEN ing on it?
>

Notifies are not reliable, what I mean is they are "best effort"
this is unlike the other things postgres does, there's no guarantee
that you'll get the message, for example the network might go down at
the same time as the notifiy is emitted, if that happenss a listening
client would miss the notify message and by the time it reconnects the
message is gone.

If you need reliable mesaging use a mesage queue in a table:
Emit a notify when you insert into the queue and the listeners can check
the queue when they connect, and again after each notify.

OTOH, if best effort is good enough, the table pg_stat_activity will give
you the username of each connected client. perhaps ypu can infer from that
who was probably listening when you last checked...

--
⚂⚃ 100% natural

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Mathew Thomas 2012-10-16 13:00:28 transaction log file "000000010000097600000051" could not be archived: too many failures
Previous Message Ryan Kelly 2012-10-16 10:59:03 Re: Strategies/Best Practises Handling Large Tables