Re: Question on corruption (PostgreSQL 9.6.1)

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andy Halsall <andyh(at)live(dot)co(dot)uk>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Question on corruption (PostgreSQL 9.6.1)
Date: 2018-03-13 13:58:31
Message-ID: 19869.1520949511@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Andy Halsall <andyh(at)live(dot)co(dot)uk> writes:
> db=# select * from xxxxx where col_a = 4675635;
> col_a | col_b | col_c | col_d | col_e | last_modified
> --------+-------------+-----------------+-----------+---------------+---------------
> | | | | |
> (1 row)

> Row 4675635 is very odd - NULL columns and at the same time retrievable by a value in col_a.

Doesn't seem particularly surprising if col_a is indexed. That query
would choose an indexscan plan, which would normally not bother to
re-verify the index condition against heap tuples found via the index.

If you're continuing to use this damaged database, it might be a good
idea to try to REINDEX all your indexes. That'd be particularly
useful for primary/unique indexes, since if corruption has led to
any apparent duplicate rows, the reindex would fail and complain.
But in any case it'd clean up heap-vs-index inconsistencies like the
above, as well as repairing any cases where the corruption was in an
index rather than heap.

Another test I'd strongly recommend is to see if you can pg_dumpall
and reload into a spare server. That might catch forms of data
corruption that reindexing would not, such as violated CHECK constraints.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David G. Johnston 2018-03-13 14:02:29 Re: UPSERT on a view
Previous Message David G. Johnston 2018-03-13 13:57:04 Re: Programmatically duplicating a schema