Re: How to prevent vacuum and reindex from deadlocking. - Mailing list pgsql-general

From Tom Lane
Subject Re: How to prevent vacuum and reindex from deadlocking.
Date
Msg-id 2587.1060614357@sss.pgh.pa.us
Whole thread Raw
In response to How to prevent vacuum and reindex from deadlocking.  (Robert Creager <Robert_Creager@LogicalChaos.org>)
Responses Re: How to prevent vacuum and reindex from deadlocking.  (Robert Creager <Robert_Creager@LogicalChaos.org>)
Re: How to prevent vacuum and reindex from deadlocking.  (Robert Creager <Robert_Creager@LogicalChaos.org>)
List pgsql-general
Robert Creager <Robert_Creager@LogicalChaos.org> writes:
> So, my guess is that 18735 is the vacuum process (likely vacuum analyze, driven
> from pg_autovacuum), and 188735 is a 'REINDEX INDEX temp_obs_i_loc_index'.

Can you use a "REINDEX TABLE" instead?  REINDEX INDEX is problematic
since it first finds/locks the index and then has to find/lock the
table.  Everything else (except perhaps DROP INDEX) goes the other way.

If you really want to rebuild only the one index, I think this will work:

begin;
lock table tab;
reindex index ndx;
commit;

I don't see a good system-level solution to this other than changing the
REINDEX syntax to include the table name (cf. CLUSTER).

            regards, tom lane

pgsql-general by date:

Previous
From: Oleg Bartunov
Date:
Subject: Re: Tsearch limitations
Next
From: Oscar Estevez Lopez
Date:
Subject: Re: extract and time zones