Re: Notifications

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Donald Fraser <postgres(at)kiwi-fraser(dot)net>
Cc: "[ADMIN]" <pgsql-admin(at)postgresql(dot)org>
Subject: Re: Notifications
Date: 2004-12-17 18:23:34
Message-ID: 20041217182334.GA77516@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

On Fri, Dec 17, 2004 at 01:01:34PM -0000, Donald Fraser wrote:

> Looking at our software, which is java, the problem lies in the
> implementation of receiving NOTIFY messages. It uses a separate thread to
> check the input stream of the socket for incoming data. The problem is

Are you just looking for incoming data, or are you also checking
that the data indeed contains a notification?

> related to ssl, the ssl input stream (implemented by sun) does not appear
> to implement the "available()" method, or at least that is what I'm seeing.
> According to the documentation the default implementation always returns 0,
> where as the non-ssl input stream definitely does implement the
> "available()" method which returns the number of bytes that can be read
> from the input stream without blocking. According to sun subclasses of
> InputStream should implemet the "available()" method. Why didn't they just
> make it an abstract method forcing an implementation - now our code is
> broken because of it!

Do you have another way to check if the underlying socket is readable?
In C using libpq you'd get the connection's file descriptor with
PQsocket() and then call select() or poll() to wait for it to become
readable. Can you do that in Java? Apparently its available()
method abstracts those calls and adds some magic of its own -- can
you bypass available() and get at the lower-layer functions?

I wonder if there would be merit in PostgreSQL providing a server-side
function that you could use like this:

SELECT * FROM wait_for_notifies();
pid | condition
-------+-----------
77578 | test
(1 row)

This would provide a simple interface for clients that want to block
until a notification arrives, one that wouldn't require any special
handling by the underlying client library.

Thoughts from the developers? Has such a thing been proposed before?
Are there implementation issues that would make it difficult or
impossible to do?

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message mjmayfield 2004-12-17 19:50:00 unsubscribe pgsql-admin
Previous Message Tom Lane 2004-12-17 16:57:35 Re: archive is compressed - any data will not be available