Re: REINDEX deadlock - Postgresql -9.1

From: Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com>
To: Anoop K <anoopk6(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org, Venkatraju TV <venkatraju(at)gmail(dot)com>
Subject: Re: REINDEX deadlock - Postgresql -9.1
Date: 2013-02-07 11:22:22
Message-ID: CAOR=d=1G8PwMJdN0Nn-0xB8D8DDRrfii5wjj2=cfWQekXCebrA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, Feb 6, 2013 at 11:55 PM, Anoop K <anoopk6(at)gmail(dot)com> wrote:
> We are hitting a situation where REINDEX is resulting in postgresql to go to
> dead lock state for ever. On debugging the issue we found that
> 3 connections are going in to some dead lock state.
>
> idle in transaction
> REINDEX waiting
> SELECT waiting
>
> All these connections are made in the same minute. Once in deadlock state we
> are not able to make new connections to db.(So not able to view pg_locks
> also). New connections appears as 'startup waiting' in ps output. Initially
> we suspected <idle in transaction> is the result of not closing a
> connection. But it seems it got stuck after creating a connection and is not
> able to proceed.

This may or may not be a deadlock. Unless you've got a circle it's
not a deadlock, it's just a "cascading lock overloading your
connection limit" failure. You can get these with slony and vacuums
and ddl. Say I want to run a DDL script. Someone is running vacuum
(could be autovac process). I run slony execute to run ddl and it
waits with hard table locks, and all the updates stall behind that.
Your db then runs out of connections. What we need to know is what
that idle in transaction is just sitting there waiting to do, which is
usually a combination of db state and application state.

As a short term fix you can set some reasonable statement level
timeout on the reindex's connection, user or database. If no reindex
ever takes more than a minute and you give it 5 minutes and check the
logs for it you can see how often it fails (once every month or once
every minute you check for a while etc then you could set that user's
connect. If that user is the superuser things become problematic.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ranjeet Dhumal 2013-02-07 11:47:14 pg_shdepend vacuum.
Previous Message Thomas Kellerer 2013-02-07 11:18:17 Re: feature requests (possibly interested in working on this): functional foreign keys