Re: ERROR: could not read block 3 in file "base/12511/12270" - Mailing list pgsql-general

From Tom Lane
Subject Re: ERROR: could not read block 3 in file "base/12511/12270"
Date
Msg-id 30442.1450917939@sss.pgh.pa.us
Whole thread Raw
In response to ERROR: could not read block 3 in file "base/12511/12270"  (Paul Jones <pbj@cmicdo.com>)
Responses Re: ERROR: could not read block 3 in file "base/12511/12270"
List pgsql-general
Paul Jones <pbj@cmicdo.com> writes:
> I have been having disk errors that have corrupted something in
> my postgres database.  Other databases work ok:

> postgres=# SELECT pg_catalog.pg_is_in_recovery();
> ERROR:  could not read block 3 in file "base/12511/12270": read only 4096 of 8192 bytes

Hm.  Evidently you've got a partially truncated file for some system
catalog or index.  It's fairly hard to estimate the consequences of
that without knowing which one it is.  Please see if this works:

$ export PGOPTIONS="-c ignore_system_indexes=true"
$ psql -U postgres

# show ignore_system_indexes;
(should say "on")

# select relname, relkind from pg_class where pg_relation_filenode(oid) = 12270;

If that works, and it tells you filenode 12270 is an index, you're in
luck: just REINDEX that index and you're done (at least with this problem,
there might be more lurking behind it).  Don't forget to unset PGOPTIONS
afterwards.

> Since this is the "postgres" database, dropping and re-creating it
> doesn't seem possible.

Sure it is, as long as you issue the commands from a non-broken database:

# drop database postgres;
DROP DATABASE
# create database postgres with template template0;
CREATE DATABASE

If you don't have any custom objects in the postgres database, this would
be by far the easiest way out.

            regards, tom lane


pgsql-general by date:

Previous
From: Paul Jones
Date:
Subject: ERROR: could not read block 3 in file "base/12511/12270"
Next
From: Adrian Klaver
Date:
Subject: Re: ERROR: could not read block 3 in file "base/12511/12270"