X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id B14BF52816 for ; Fri, 24 Jun 2005 20:40:00 -0300 (ADT) 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 57477-08 for ; Fri, 24 Jun 2005 23:39:51 +0000 (GMT) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.201]) by svr1.postgresql.org (Postfix) with ESMTP id 5CC2552933 for ; Fri, 24 Jun 2005 20:39:50 -0300 (ADT) Received: by wproxy.gmail.com with SMTP id 58so1347wri for ; Fri, 24 Jun 2005 16:39:54 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=fkPW93anQ7IJyoxK9WpFvA11ZQQHxr/HDAP8BxC6VFbRQU/cVnXR6I8wHDgigKmB9oa3kY1BmNdc0byDqtp6uTTc7Tuc1y5o6yK6+Xz0XVSIku427H2BP9vy5zV3GIZQcFie0HFSyh5G4IR8FJ34nHRXjzGYGkHVwlX0590XQws= Received: by 10.54.42.17 with SMTP id p17mr2083769wrp; Fri, 24 Jun 2005 16:39:54 -0700 (PDT) Received: by 10.54.89.4 with HTTP; Fri, 24 Jun 2005 16:39:54 -0700 (PDT) Message-ID: <3fccaa6905062416392e578f58@mail.gmail.com> Date: Fri, 24 Jun 2005 17:39:54 -0600 From: Andres Olarte Reply-To: Andres Olarte To: pgsql-jdbc@postgresql.org Subject: Problem with Async (multiple) notifications Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.549 tagged_above=0 required=5 tests=AWL, RCVD_BY_IP X-Spam-Level: X-Archive-Number: 200506/127 X-Sequence-Number: 13089 I've been playing with async notifications lately, and I've found a small problem: when several notifications are issued at once (for example within a transaction) normally only one of those gets to the client. The rest of the notifications are not received until something happens on the connection, for example a query or another notification. I'm using the latest CVS, updated yesterday. I've looked over the code, and there's nothing obvious. I think that this has to do with java's handling of sockets, as the C example that deals with notifications works fine. It seems that some packages are "stuck" in the socket, but my knowledge of sockets is very limited. A possible workarround would be to issue the simplest possible query or message to the backend when a notification is found, to see if anymore notifications are "stuck". This would generate a little bit of extra traffic, but only when there is a notification. Here is a small test case showing what's happening: public class TestAsync extends TestCase { =20 Connection conn2,conn1; =20 public void testAsync() { String user =3D "andres"; String pass =3D ""; String url =3D "jdbc:postgresql://127.0.0.1/template1"; try { Class.forName("org.postgresql.Driver"); } catch (ClassNotFoundException cnf) { fail("Data Base Driver not Found: " + cnf.getMessage()); } try { conn1 =3D DriverManager.getConnection(url, user, pass); conn2 =3D DriverManager.getConnection(url, user, pass); conn2.setAutoCommit(true); Statement stmt2 =3D conn2.createStatement(); stmt2.execute("LISTEN test1"); stmt2.execute("LISTEN test2"); stmt2.execute("LISTEN test3"); PGConnection pgconn =3D (PGConnection) conn2; =20 =20 Statement stmt1=3Dconn1.createStatement(); stmt1.execute("NOTIFY test1;"); stmt1.execute("NOTIFY test2;"); stmt1.execute("NOTIFY test3;"); conn1.commit(); =20 PGNotification[] nots =3D pgconn.getNotifications(); =20 assertEquals(3,nots.length); =20 } catch (SQLException sqle) { fail("SQLException sql" + sqle.getLocalizedMessage()); } } I'm running a 7.4 backend, but I don't think that's the problem. But if someone thinks I'm doing something wrong, please let me know!! thanks to all of the people that have worked on PostreSQL Andres Olarte