Re: ERROR: could not read block 3 in file "base/12511/12270"

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Paul Jones <pbj(at)cmicdo(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: ERROR: could not read block 3 in file "base/12511/12270"
Date: 2015-12-24 00:45:39
Message-ID: 30442.1450917939@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Paul Jones <pbj(at)cmicdo(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2015-12-24 00:48:42 Re: ERROR: could not read block 3 in file "base/12511/12270"
Previous Message Paul Jones 2015-12-24 00:17:19 ERROR: could not read block 3 in file "base/12511/12270"