X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id CBCFC3CC495 for ; Fri, 17 Dec 2004 18:23:53 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 01062-07 for ; Fri, 17 Dec 2004 18:23:42 +0000 (GMT) Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) by svr1.postgresql.org (Postfix) with ESMTP id 12FC93CCF15 for ; Fri, 17 Dec 2004 18:23:42 +0000 (GMT) Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) by tigger.fuhr.org (8.13.1/8.13.1) with ESMTP id iBHINZ7u014357 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 17 Dec 2004 11:23:38 -0700 (MST) (envelope-from mfuhr@winnie.fuhr.org) Received: from winnie.fuhr.org (localhost [127.0.0.1]) by winnie.fuhr.org (8.13.1/8.13.1) with ESMTP id iBHINZw4077640; Fri, 17 Dec 2004 11:23:35 -0700 (MST) (envelope-from mfuhr@winnie.fuhr.org) Received: (from mfuhr@localhost) by winnie.fuhr.org (8.13.1/8.13.1/Submit) id iBHINYEZ077639; Fri, 17 Dec 2004 11:23:35 -0700 (MST) (envelope-from mfuhr) Date: Fri, 17 Dec 2004 11:23:34 -0700 From: Michael Fuhr To: Donald Fraser Cc: "[ADMIN]" Subject: Re: Notifications Message-ID: <20041217182334.GA77516@winnie.fuhr.org> References: <002e01c4e37a$5ab3bae0$6464a8c0@DonAcer> <20041216170721.GA67633@winnie.fuhr.org> <003701c4e396$d9b4a270$6464a8c0@DonAcer> <20041216185426.GA80816@winnie.fuhr.org> <003301c4e438$8a304fe0$6464a8c0@DonAcer> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <003301c4e438$8a304fe0$6464a8c0@DonAcer> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.002 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200412/196 X-Sequence-Number: 15782 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/