Re: DISCARD ALL failing to acquire locks on pg_listen

From: Matteo Beccati <php(at)beccati(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Postgres Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: DISCARD ALL failing to acquire locks on pg_listen
Date: 2009-02-12 12:05:24
Message-ID: 49941084.5080403@beccati.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Tom,

>> Given I was using 8.3, it seemed quite right to set the reset statement
>> to "ABORT; DISCARD ALL". Everything works fine, until a load spike
>> happens and pgpool-II reset queries start to lag behind, with DISCARD
>> ALL failing to acquire an exclusive locks on the pg_listen system table,
>> although the application isn't using any LISTEN/NOTIFY. The reason was
>> not obvious to me, but looking at the man page explained a lot: DISCARD
>> ALL also performs an "UNLISTEN *".
>
> Seems like we could/should fix UNLISTEN * to not do anything if it is
> known that the current backend never did any LISTENs.

Here's my proposed patch, both for HEAD and 8.3:

http://www.beccati.com/misc/pgsql/async_unlisten_skip_HEAD.patch
http://www.beccati.com/misc/pgsql/async_unlisten_skip_REL8_3_STABLE.patch

I tried to write a regression test, but couldn't find a suitable way to
get the regression framework cope with trace_notify printing the backend
pid. I even tried to add a @backend_pid@ variable to pg_regress, but
soon realised that the pid is not available to psql when variable
substitution happens.

So, here's the output of some tests I made:

http://www.beccati.com/misc/pgsql/async_unlisten_skip.out

Note: DISCARD doesn't produce any debug output, because the guc
variables are being reset before the Async_UnlistenAll is called.

Cheers

--
Matteo Beccati

OpenX - http://www.openx.org

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Gurjeet Singh 2009-02-12 12:13:33 Need help in porting Oracle PL/SQL's OUT paramater based procedures
Previous Message Bernd Helmle 2009-02-12 10:04:37 Re: temporarily stop autovacuum