From: | Craig Ringer <craig(at)postnewspapers(dot)com(dot)au> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | PG-General Mailing List <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Cheapest way to poll for notifications? |
Date: | 2009-12-10 16:10:06 |
Message-ID: | 4B211D5E.2070107@postnewspapers.com.au |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general pgsql-jdbc |
Tom Lane wrote:
> Craig Ringer <craig(at)postnewspapers(dot)com(dot)au> writes:
>> As Pg doesn't presently support client push for notifications arising
>> from LISTEN/NOTIFY, I'm wondering if anybody here has done any research
>> into the cheapest statement to issue to check for such notifications.
>
> The backend certainly will push the notification. Maybe you just have
> a client-side-software issue?
Testing with two plain old psql sessions to an 8.4.1 DB on linux (Ubuntu
9.10) here, I don't see the asynchronous notification until I send some
other command to the database from the client. It's the same over a
local UNIX socket or a loopback TCP/IP connection (with SSL).
Neither listener nor notifier are in a transaction, though it doesn't
seem to make any difference if I "BEGIN; NOTIFY test; COMMIT;" instead.
I only waited a few minutes after sending NOTIFY to see if psql would
notice, but if it's server-pushed it should be immediate, right?
Is this a psql limitation rather than a backend one? I know the JDBC
driver has such a limitation, and in fact the psql man page suggests
that it does too:
"
Whenever a command is executed, psql also polls for asynchronous noti‐
fication events generated by LISTEN [listen(7)] and NOTIFY [notify(7)].
"
... but if that is the case, is there any client software that _does_
support truly asynchronous receipt of notifications?
=====(SESSION 1, psql 8.4.1, local socket)====
test=> LISTEN x;
LISTEN
test=> SELECT current_timestamp;
now
-------------------------------
2009-12-10 23:54:16.988355+08
(1 row)
test=> SELECT current_timestamp;
now
-------------------------------
2009-12-10 23:55:04.872358+08
(1 row)
Asynchronous notification "x" received from server process with PID 14623.
test=>
=====(SESSION 2, psql 8.4.1, local socket)====
test=> SELECT current_timestamp;
now
-------------------------------
2009-12-10 23:54:34.252394+08
(1 row)
test=> NOTIFY x;
NOTIFY
test=>
*Self* notifications ( where listener == notifier ) are issued
immediately, but a NOTIFY to another backend doesn't seem to get pushed.
--
Craig Ringer
From | Date | Subject | |
---|---|---|---|
Next Message | Adrian Klaver | 2009-12-10 16:13:19 | Re: pg_dump and ON DELETE CASCADE problem |
Previous Message | Merlin Moncure | 2009-12-10 15:48:24 | Re: Cheapest way to poll for notifications? |
From | Date | Subject | |
---|---|---|---|
Next Message | Craig Ringer | 2009-12-10 16:14:39 | Re: Cheapest way to poll for notifications? |
Previous Message | Merlin Moncure | 2009-12-10 15:48:24 | Re: Cheapest way to poll for notifications? |