Search Postgresql Archives

Re: Cheapest way to poll for notifications?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Tom Lane wrote:
> Craig Ringer <craig@xxxxxxxxxxxxxxxxxxxxx> 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

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux