Re: unique index corruption

Поиск
Список
Период
Сортировка
От Merlin Moncure
Тема Re: unique index corruption
Дата
Msg-id CAHyXU0zfjYxznSM7V2U3r-9cH+2msCvexXxeTmn-oq14nPiprw@mail.gmail.com
обсуждение исходный текст
Ответ на unique index corruption  (pg noob <pgnube@gmail.com>)
Список pgsql-general
On Wed, Jul 24, 2013 at 1:50 PM, pg noob <pgnube@gmail.com> wrote:
>
> Hi all,
>
> In PostgreSQL 8.4...
>
> I am wondering if autovacuum will periodically rebuild indexes?

it will not. REINDEX requires a heavy lock and for most applications
it would be just plain untenable to be run without some type of
application coordination, especially if the index is large.

> If not, how advisable is it to reindex periodically?

no harm in that at all -- notwithstanding the locking issues.

> We recently had a case of unique index corruption which ended up allowing
> duplicate
> primary key IDs to get inserted and caused widespread data model integrity
> havoc.
>
> The system ran for several days before it was noticed.
>
> After the problem was discovered we found that a reindex would fail because
> there were
> duplicate ID values.
>
> Our thought is that if we had a scheduled cron job that would periodically
> do a reindex this
> corruption might have been caught sooner by detecting the reindex failure.
>
> If a reindex is something that should be done frequently as part of regular
> maintenance
> why isn't there a mode of autovacuum that does this automatically?  Or maybe
> there is and
> I just don't know about it..?


REINDEX to remove corruption is essentially dealing with the symptoms
of a problem and IMNSHO is not a real long term solution. First thing
to figure out is if we have a postgres bug or some other failure (in
particular, hardware).   Unusual circumstances, for example any
unplanned shutdowns around the time corruption started to appear,
might give some clues in terms of figuring where the real problem
lies.  Essentially this is not supposed to happen.

merlin


В списке pgsql-general по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: upgrading from 9.3-beta1 to 9.3-beta2 requires dump & reload?
Следующее
От: Sergey Konoplev
Дата:
Сообщение: Re: unique index corruption