Re: Broken HOT chains in system catalogs

From: Noah Misch <noah(at)leadboat(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Broken HOT chains in system catalogs
Date: 2011-04-16 16:48:08
Message-ID: 20110416164808.GA25433@tornado.leadboat.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, Apr 16, 2011 at 11:17:53AM -0400, Tom Lane wrote:
> Noah Misch <noah(at)leadboat(dot)com> writes:
> > On Fri, Apr 15, 2011 at 03:01:04PM -0400, Tom Lane wrote:
> >> What is happening is that the preceding "reindex table pg_index" set the
> >> indcheckxmin flag for pg_index's indexes. The new table built by vacuum
> >> full contains no HOT chains at all, let alone broken ones, so at the end
> >> of reindex_index we decide we ought to clear the indcheckxmin flag.
> >> But we are not done swapping the old and new indexes, so the uniqueness
> >> check doesn't work right --- I believe it's looking into the old index
> >> and finding a TID that means something totally different in the new
> >> table.
>
> > For that matter, I believe it's also attempting to insert into the old index.
>
> I wondered about that, but it seemed to me that if that happened, it
> ought to have much more visible symptoms --- ie, the committed row would
> not be findable through the new index. The typical case according to my
> testing was that the unique check wouldn't fail, so we should have been
> hearing reports of pg_index searches failing post-VACUUM, and we
> weren't. I did not expend the time to trace it down in detail, though,
> once I'd gotten the general picture of what was happening.

I'm not 100% sure, either.

> > I think we're safe _consulting_ the system catalogs, since systable_beginscan
> > notes that case and does not use obsolete indexes. Any other system catalog
> > _updates_ are potentially risky, though. Perhaps index_insert() and friends
> > should assert that the index is not pending rebuild?
>
> [ squint... ] Won't that result in the rebuild failing outright? We
> can't remove an index from the pending list till after it's rebuilt,
> for obvious reasons.

That would be a problem if an ambuild function were to call back through the
indexam.c layer to add an individual entry. No core access method does that,
and there's nothing I can see to recommend doing it.

nm

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Leonardo Francalanci 2011-04-16 16:52:05 Re: switch UNLOGGED to LOGGED
Previous Message Tom Lane 2011-04-16 15:52:47 Bizarre reindex_relation API