pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedCatalog for LISTEN'ed to notification channels?
3+ messages / 2 participants
[nested] [flat]
* Catalog for LISTEN'ed to notification channels?
@ 2023-06-22 08:22 Dominique Devienne <ddevienne@gmail.com>
0 siblings, 1 reply; 3+ messages in thread
From: Dominique Devienne @ 2023-06-22 08:22 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
Hi,
I've looked in the Catalogs, the doc for LISTEN, NOTIFY, even [LibPQ Async
Notif][1],
and I don't see anything about that.
Can I introspect which "channel(s)" the current (or any other session) is
LISTEN'ing to?
Any way to see pending notification(s) in that 8GB queue, from client apps?
pg_notification_queue_usage() return a ratio of "full-ness" of that queue,
but how to find out its actual max-size or how many pending notifications
there are?
Or discover client side which session(s) is/are blocking delivery with a
long running transaction?
FWIW, sounds to me motification would be more useful is the client could
decide
whether to have transaction "interfere" with delivery (the current
behavior), to opt-in
to a new "immediate" (or "best effort" as fast as possible) delivery,
independent of
transactions. At LISTEN time, or NOTIFY time, not sure. With the current
design,
one must almost always use specific connections just for notifications, to
ensure
timely discovery.
To be sure, I see value in transactional notifications, especially about
persistent
DDL and/or DML changes which could be undone on ROLLBACK.
But I also see notification a form of "extended IPC" mechanism for apps on
different
machines which happen to collaborate on data in particular databases. In
that context,
immediate / rapid delivery seem a lot more important and non-transactional.
Also, the doc is ambiguous whether the session-with-open-transaction
delivery issue
is per-channel, or global to the whole queue. I hope it's the former, since
the latter would
be disastrous I guess.
Perhaps the lack of introspection of channel names is a means to have
"secret" channels,
to mitigate the delivery issue mentioned above?
Sorry for all the questions, I'm only now getting into notifications, and
while the doc
does provide quite a bit of info, a few dark point remains for me, thus
this message.
I'm trying to understand what can go wrong, and how to avoid it.
Thanks, --DD
[1]: https://www.postgresql.org/docs/current/libpq-notify.html
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Catalog for LISTEN'ed to notification channels?
@ 2023-06-22 13:29 Tom Lane <tgl@sss.pgh.pa.us>
parent: Dominique Devienne <ddevienne@gmail.com>
0 siblings, 1 reply; 3+ messages in thread
From: Tom Lane @ 2023-06-22 13:29 UTC (permalink / raw)
To: Dominique Devienne <ddevienne@gmail.com>; +Cc: pgsql-general@lists.postgresql.org
Dominique Devienne <ddevienne@gmail.com> writes:
> Can I introspect which "channel(s)" the current (or any other session) is
> LISTEN'ing to?
The pg_listening_channels() function will show you channel names the
current session is listening to. There's no way to find out about
other sessions, because that state is only backend-local.
regards, tom lane
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Catalog for LISTEN'ed to notification channels?
@ 2023-06-22 14:16 Dominique Devienne <ddevienne@gmail.com>
parent: Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 3+ messages in thread
From: Dominique Devienne @ 2023-06-22 14:16 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-general@lists.postgresql.org
On Thu, Jun 22, 2023 at 3:30 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Dominique Devienne <ddevienne@gmail.com> writes:
> > Can I introspect which "channel(s)" the current (or any other session) is
> > LISTEN'ing to?
>
> The pg_listening_channels() function will show you channel names the
> current session is listening to. There's no way to find out about
> other sessions, because that state is only backend-local.
>
Thanks Tom. I'll take that. Useful for unit tests at least.
If anyone can share more info or pointers on the design and rationals for
async notification in PostgreSQL, why it is transactional only, with the
issue
that ensues, and whether there are any plans about it, I'd appreciate.
Thanks, --DD
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2023-06-22 14:16 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2023-06-22 08:22 Catalog for LISTEN'ed to notification channels? Dominique Devienne <ddevienne@gmail.com>
2023-06-22 13:29 ` Tom Lane <tgl@sss.pgh.pa.us>
2023-06-22 14:16 ` Dominique Devienne <ddevienne@gmail.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox