Re: check database integrity

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Torsten Förtsch <torsten(dot)foertsch(at)gmx(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: check database integrity
Date: 2014-07-21 14:17:58
Message-ID: 23576.1405952278@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

=?ISO-8859-1?Q?Torsten_F=F6rtsch?= <torsten(dot)foertsch(at)gmx(dot)net> writes:
> Another question, just out of curiosity, for vm and main forks I use
> pg_relation_size to figure out the highest page number. That does not
> work for fsm. I have at least one fsm file that it 24 kb. Fetching page
> 0 works, page 1 and above gives an error:

> db=# select page_header(get_raw_page(2836::oid::regclass::text, 'fsm', 0));
> page_header
> ----------------------------------------------
> (114/23485F78,19084,0,24,8192,8192,8192,4,0)
> (1 row)

> db=# select page_header(get_raw_page(2836::oid::regclass::text, 'fsm',
> 1));
> ERROR: block number 1 is out of range for relation "pg_toast_1255"
> db=# select pg_relation_size(2836::oid::regclass, 'fsm');

> pg_relation_size
> ------------------
> 24576

That's bizarre. AFAICS, pg_relation_size() reduces to a stat() call,
while the other error looks like it's coming from rawpage.c's check on
RelationGetNumberOfBlocks() which depends on mdnblocks() which prefers
to look at the result of lseek(SEEK_END). But both of those should
surely get the same answer, if the file's not changing.

Could you trace through it and see where the results diverge? Also,
what's the actual size of the file on disk?

Alternatively, if you have a way to reproduce this from a standing
start, I'd be happy to poke into it here.

regards, tom lane

PS: you've not messed around with the value of BLCKSZ have you?
If different bits of code had different ideas of that constant's
value, it'd possibly explain this.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Sergey Konoplev 2014-07-21 14:59:01 Re: statement_timeout doesn't work
Previous Message Ramesh T 2014-07-21 14:13:10 cursor return null