Re: Unfamous 'could not read block ... in file "...": read only 0 of 8192 bytes' again

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Maxim Boguk <maxim(dot)boguk(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Unfamous 'could not read block ... in file "...": read only 0 of 8192 bytes' again
Date: 2012-02-21 04:01:33
Message-ID: 21172.1329796893@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

Maxim Boguk <maxim(dot)boguk(at)gmail(dot)com> writes:
> On Tue, Feb 21, 2012 at 1:46 PM, Maxim Boguk <maxim(dot)boguk(at)gmail(dot)com> wrote:
>> There isn't possibility but close to 100% new inserted values were matched
>> a previously-existing primary
>> key value.
>> The table is hand-made 'materialyzed view'-type statistic table which is
>> getting recalculated via cron.

> To be clear - the new inserted values do match a previously-existing
> primary key values almost always.

OK, so that pretty much explains where the visible symptoms are coming
from: somehow, the table got truncated but its pkey index did not get
cleared out. So an insert creates an empty page zero, inserts a heap
tuple there, tries to insert an index entry. The btree code sees there
is an index entry for that key already, and tries to fetch the heap
tuple for that index entry to see if it's dead (which would allow the
insertion to proceed). But the block number the index is pointing at
isn't there, so you get the quoted error message. The insertion rolls
back, leaving a dead tuple that can be garbage-collected by autovacuum,
after which it truncates the table again --- but of course without
removing any index entries, except maybe one for TID (0,1) if that's
still there. Lather rinse repeat.

But this brings us little closer to understanding the cause of the
problem. How could the table have gotten truncated without vacuuming
out the index?

Are you sure the only operations happening on that table are INSERT,
DELETE, autovacuum? No DDL of any kind?

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2012-02-21 04:32:18 Re: Unfamous 'could not read block ... in file "...": read only 0 of 8192 bytes' again
Previous Message Maxim Boguk 2012-02-21 03:25:41 Re: Unfamous 'could not read block ... in file "...": read only 0 of 8192 bytes' again

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2012-02-21 04:21:10 Re: 16-bit page checksums for 9.2
Previous Message Fujii Masao 2012-02-21 03:59:27 Re: Displaying accumulated autovacuum cost