Search Postgresql Archives

Re: check database integrity

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 21/07/14 16:17, Tom Lane wrote:
>> > 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?

# select pg_relation_filepath(2836::oid::regclass);
pg_relation_filepath
----------------------
 base/25317/11790


# ls -l data/base/25317/11790*
-rw------- 1 postgres postgres  8192 Jul 21 07:31 data/base/25317/11790
-rw------- 1 postgres postgres 24576 Jul 21 07:33 data/base/25317/11790_fsm
-rw------- 1 postgres postgres  8192 Jul 21 07:33 data/base/25317/11790_vm

You see, main and vm forks of the relation are one page. Only fsm is 3
pages.

After a fresh restart of the database I attached strace to the backend.
There are only 2 lines in the output that mention that relation:

open("base/25317/11790", O_RDWR)        = 35
lseek(35, 0, SEEK_END)                  = 8192

This happened during this query:

select get_raw_page(2836::oid::regclass::text, 'fsm', 1);

Shouldn't it rather open 11790_fsm?

Or is there something that first checks the main fork to see if the fsm
page makes sense?

It seems so because here is the same query for a relation where it works:

open("base/25317/60966", O_RDWR)        = 39
lseek(39, 0, SEEK_END)                  = 1490944
open("base/25317/60966_fsm", O_RDWR)    = 40
lseek(40, 8192, SEEK_SET)               = 8192
read(40, "\37\1\0\0\360\371\275\212\305\35\0\0\30\0\0 \0 \4
\0\0\0\0\0\0\0\0\372\372\0\372"..., 8192) = 8192

First it opens the main fork, then *_fsm where it reads a page at offset
8192.

Torsten



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux