pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Greg Sabino Mullane <greg@endpoint.com>
To: pgsql-bugs@postgresql.org
Subject: Unlisten / listen in a transaction failure
Date: Wed, 13 Feb 2013 09:55:22 -0500
Message-ID: <20130213145522.GI23404@broken.home> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

I came across some unusual behavior with listen. Basically, if you 
unlisten and listen inside of a transaction, new notices are not 
picked up right away - but they will show up if you send yourself 
a notice. It also works as expected if you unlisten, commit, and 
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.



-- 
Greg Sabino Mullane greg@endpoint.com
End Point Corporation
PGP Key: 0x14964AC8

Attachments:

  signature.asc (application/pgp-signature, 162B) download

view thread (2+ messages)  latest in thread

Message-ID: <20130213145522.GI23404@broken.home>
Permalink:  ../20130213145522.GI23404@broken.home/
Also on:    postgresql.org/message-id/20130213145522.GI23404@broken.home

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: greg@endpoint.com
  Subject: Re: Unlisten / listen in a transaction failure
  In-Reply-To: <20130213145522.GI23404@broken.home>
  References: <20130213145522.GI23404@broken.home>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox