Re: pg_upgrade problem with invalid indexes

From: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pg_upgrade problem with invalid indexes
Date: 2012-12-07 14:12:36
Message-ID: 20121207141236.GB4699@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Bruce Momjian wrote:
> On Thu, Dec 6, 2012 at 09:23:14PM -0500, Bruce Momjian wrote:
> > On Thu, Dec 6, 2012 at 09:10:21PM -0500, Tom Lane wrote:
> > > Bruce Momjian <bruce(at)momjian(dot)us> writes:
> > > > On Thu, Dec 6, 2012 at 07:53:57PM -0500, Tom Lane wrote:
> > > >> Because CREATE INDEX CONCURRENTLY can't drop the index if it's already
> > > >> failed. It's not because we want to do that, it's an implementation
> > > >> restriction of the horrid kluge that is CREATE/DROP INDEX CONCURRENTLY.
> > >
> > > > Well, what is the logic that pg_dump dumps it then, even in
> > > > non-binary-upgrade mode?
> > >
> > > Actually, I was thinking about proposing exactly that. Ideally the
> > > system should totally ignore an invalid index (we just fixed some bugs
> > > in that line already). So it would be perfectly consistent for pg_dump
> > > to ignore it too, with or without --binary-upgrade.
> > >
> > > One possible spanner in the works for pg_upgrade is that this would mean
> > > there can be relation files in the database directories that it should
> > > ignore (not transfer over). Dunno if that takes any logic changes.
> >
> > As soon as pg_dump stopped dumping the CREATE INDEX, pg_upgrade would
> > stop creating creating it in the new cluster, and not transfer the index
> > files.
>
> Sorry, I was wrong about this. We would need to modify pg_dump to skip
> invalid indexes (perhaps only for --binary-upgrade),

Invalid indexes only persist in the database because the system cannot
drop them automatically. I see no reason to have pg_dump include them
in its output, with or without --binary-upgrade.

> and pg_upgrade would also need to be modified to skip such indexes.
> This is necessary because, as a safety check, pg_upgrade requires
> there to be an exact match of relations between old and new clusters.

Right. This shouldn't be too hard, though; just make sure to exclude
invalid indexes in the pg_upgrade query that obtains relations from the
old cluster. Since pg_dump would not include them in the dump, the
numbers should match.

--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Muhammad Usama 2012-12-07 14:13:56 Re: Review: Patch to compute Max LSN of Data Pages
Previous Message Bruce Momjian 2012-12-07 13:58:04 Re: pg_upgrade problem with invalid indexes