pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Bill Moran <wmoran@potentialtech.com>
Cc: Aln Kapa <alnkapa@gmail.com>
Cc: Postgres General Postgres General <pgsql-general@postgresql.org>
Subject: Re: unexpected lock waits (was Re: Do not understand why this happens)
Date: Fri, 15 Mar 2013 09:38:06 -0400
Message-ID: <3598.1363354686@sss.pgh.pa.us> (raw)
In-Reply-To: <20130315071657.d767d368df0985fbff15d0a1@potentialtech.com>
References: <CAJqqVEU2dvMO+q=BjpkCnEopT-xiWjY2Pn3XmSN8D=6HVnDh3g@mail.gmail.com>
	<20130314074251.62f6efdcb2027f87fe63d997@potentialtech.com>
	<CAJqqVEXy_GimKe6Bp6YYyB5uk6wsg9Zm+3gkvinJHzTpmaFodA@mail.gmail.com>
	<20130315071657.d767d368df0985fbff15d0a1@potentialtech.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-general>

Bill Moran <wmoran@potentialtech.com> writes:
> I do wonder what else is happening in the transaction that you're
> calling NOTIFY within; and that some other statement could be causing
> the lock wait.

FWIW, the lock seems to be the one taken to serialize insertions into
the shared NOTIFY queue, from this bit in commands/async.c:

        /*
         * Serialize writers by acquiring a special lock that we hold till
         * after commit.  This ensures that queue entries appear in commit
         * order, and in particular that there are never uncommitted queue
         * entries ahead of committed ones, so an uncommitted transaction
         * can't block delivery of deliverable notifications.
         *
         * We use a heavyweight lock so that it'll automatically be released
         * after either commit or abort.  This also allows deadlocks to be
         * detected, though really a deadlock shouldn't be possible here.
         *
         * The lock is on "database 0", which is pretty ugly but it doesn't
         * seem worth inventing a special locktag category just for this.
         * (Historical note: before PG 9.0, a similar lock on "database 0" was
         * used by the flatfiles mechanism.)
         */
        LockSharedObject(DatabaseRelationId, InvalidOid, 0,
                         AccessExclusiveLock);

This lock is held while inserting the transaction's notify message(s),
after which the transaction commits and releases the lock.  There's not
very much code in that window.  So what we can conclude is that some
other transaction also doing NOTIFY hung up within that sequence for
something in excess of 3 seconds.  We have been shown no data whatsoever
that would allow us to speculate about what's causing that other
transaction to take so long to get through its commit sequence.

			regards, tom lane


-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



view thread (2+ messages)

Message-ID: <3598.1363354686@sss.pgh.pa.us>
Permalink:  ../3598.1363354686@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/3598.1363354686@sss.pgh.pa.us

 · 

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-general@postgresql.org
  Cc: tgl@sss.pgh.pa.us, wmoran@potentialtech.com, alnkapa@gmail.com
  Subject: Re: unexpected lock waits (was Re: Do not understand why this happens)
  In-Reply-To: <3598.1363354686@sss.pgh.pa.us>
  References: <CAJqqVEU2dvMO+q=BjpkCnEopT-xiWjY2Pn3XmSN8D=6HVnDh3g@mail.gmail.com> <20130314074251.62f6efdcb2027f87fe63d997@potentialtech.com> <CAJqqVEXy_GimKe6Bp6YYyB5uk6wsg9Zm+3gkvinJHzTpmaFodA@mail.gmail.com> <20130315071657.d767d368df0985fbff15d0a1@potentialtech.com> <3598.1363354686@sss.pgh.pa.us>

* 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