pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Thomas Kenner <thomas.kenner@gmail.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Rename Index - Deadlock
Date: Tue, 16 Mar 2010 12:16:04 -0400
Message-ID: <10099.1268756164@sss.pgh.pa.us> (raw)
In-Reply-To: <201003161045.58639.thomas.kenner@gmail.com>
References: <201003161045.58639.thomas.kenner@gmail.com>

Thomas Kenner <thomas.kenner@gmail.com> writes:
> Each day I'm recreating the index my_index of the table my_table. Therefore I 
> create a new index my_index_new, drop the old index my_index, and rename the 
> new index:
> ALTER INDEX my_index_new RENAME TO my_index;

> If an insert or select statement is run at the same time as the "ALTER INDEX 
> ... RENAME TO" statement, it will end up in a deadlock.

I doubt it's the RENAME that's the problem, more likely the DROP of the
old index.  That has to get an exclusive lock on the parent table to be
sure there is nothing trying to use the index.

Why exactly do you feel you need to do this every day?

			regards, tom lane



view thread (3+ messages)  latest in thread

Message-ID: <10099.1268756164@sss.pgh.pa.us>
Permalink:  ../10099.1268756164@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/10099.1268756164@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 using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, thomas.kenner@gmail.com
  Subject: Re: Rename Index - Deadlock
  In-Reply-To: <10099.1268756164@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