Re: Rename Index - Deadlock

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Thomas Kenner <thomas(dot)kenner(at)gmail(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Rename Index - Deadlock
Date: 2010-03-16 16:16:04
Message-ID: 10099.1268756164@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Thomas Kenner <thomas(dot)kenner(at)gmail(dot)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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Scott Marlowe 2010-03-16 16:39:37 Re: Rename Index - Deadlock
Previous Message Tom Lane 2010-03-16 14:24:47 Re: DROP RULE ... CASCADE