Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U5dkB-0003i3-RX for pgsql-bugs@arkaria.postgresql.org; Wed, 13 Feb 2013 14:55:31 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1U5dkB-0000pe-5z for pgsql-bugs@arkaria.postgresql.org; Wed, 13 Feb 2013 14:55:31 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U5dkA-0000pY-7I for pgsql-bugs@postgresql.org; Wed, 13 Feb 2013 14:55:30 +0000 Received: from mail.endcrypt.com ([2607:f0d0:1301:23::3]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U5dk8-0007K1-Pj for pgsql-bugs@postgresql.org; Wed, 13 Feb 2013 14:55:29 +0000 Received: from broken.home (pool-71-175-44-21.phlapa.fios.verizon.net [71.175.44.21]) (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by mail.endcrypt.com (Postfix) with ESMTPSA id 805D982153; Wed, 13 Feb 2013 14:55:27 +0000 (UTC) Date: Wed, 13 Feb 2013 09:55:22 -0500 From: Greg Sabino Mullane To: pgsql-bugs@postgresql.org Subject: Unlisten / listen in a transaction failure Message-ID: <20130213145522.GI23404@broken.home> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-ripemd160; protocol="application/pgp-signature"; boundary="fmvA4kSBHQVZhkR6" Content-Disposition: inline X-PGP-Key: http://www.gtsm.com/Greg_Sabino_Mullane.key.html User-Agent: Mutt/1.5.21 (2010-09-15) X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org --fmvA4kSBHQVZhkR6 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable I came across some unusual behavior with listen. Basically, if you=20 unlisten and listen inside of a transaction, new notices are not=20 picked up right away - but they will show up if you send yourself=20 a notice. It also works as expected if you unlisten, commit, and=20 then re-listen. Tested on 9.1 and 9.2. Demo psql script: listen abc; \t \! psql -p 5491 -c 'notify abc' select * from pg_listening_channels(); begin; unlisten *; listen abc; commit; \! psql -p 5491 -c 'notify abc' select * from pg_listening_channels(); notify abc; Output of above on 9.1 with psql -e: listen abc; LISTEN Showing only tuples. NOTIFY select * from pg_listening_channels(); abc Asynchronous notification "abc" received from server process with PID 10879. begin; BEGIN unlisten *; UNLISTEN listen abc; LISTEN commit; COMMIT NOTIFY select * from pg_listening_channels(); abc notify abc; NOTIFY Asynchronous notification "abc" received from server process with PID 10882. Asynchronous notification "abc" received from server process with PID 10876. --=20 Greg Sabino Mullane greg@endpoint.com End Point Corporation PGP Key: 0x14964AC8 --fmvA4kSBHQVZhkR6 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- iEYEAREDAAYFAlEbqVoACgkQvJuQZxSWSshSywCfQWraTUr8Vxc2HDw3kymovt10 p3UAoKiNkU0J4m4VQvesEqSQ/FQdIKMS =vDTt -----END PGP SIGNATURE----- --fmvA4kSBHQVZhkR6--