Thread: FATAL: root page 3 of "pg_class_oid_index" has level 0, expected 1

FATAL: root page 3 of "pg_class_oid_index" has level 0, expected 1

From
Andrew Radamis
Date:
Hello,

I'm pretty new to pgsql, so speak slowly and draw plenty of pictures please :P

I'm getting this error when I try to log into my database.

FATAL: root page 3 of "pg_class_oid_index" has level 0, expected 1

I've done some googleing and I found one mailing list item in another language, and I couldn't decipher any useful information out of. I have no idea what caused this or how it happened. The computer has been up for months, but the database doesn't get very much use, just when I occasionally use it with sql-ledger.

Thanks for your help,

Andrew
Andrew Radamis <rust710@gmail.com> writes:
> I'm getting this error when I try to log into my database.
> *FATAL: root page 3 of "pg_class_oid_index" has level 0, expected 1

You've got a corrupted index.  You can probably fix it like this:

    export PGOPTIONS="-P"
    psql ..usual options..
    reindex index pg_class_oid_index;

After that, a dump/initdb/reload might be in order, since it's hard to
tell whether there are other problems lurking.  Some testing of your
hardware might be advisable too; and I'd suggest updating your Postgres
if it's not a recent release.

            regards, tom lane

Re: FATAL: root page 3 of "pg_class_oid_index" has level 0, expected 1

From
Andrew Radamis
Date:
Hi Tom,

Thanks for the reply! The reindex command you provided did not work, it gave the same error as the one I got when logging in earlier, however I was feeling reckless so I did reindex database <mydatabase>; and that completed as follows:

NOTICE:  table "pg_class" was reindexed
NOTICE:  table "sql_features" was reindexed
NOTICE:  table "sql_implementation_info" was reindexed
NOTICE:  table "sql_languages" was reindexed
NOTICE:  table "sql_packages" was reindexed
NOTICE:  table "sql_sizing" was reindexed
NOTICE:  table "sql_sizing_profiles" was reindexed
NOTICE:  table "pg_statistic" was reindexed
ERROR:  invalid page header in block 43 of relation "pg_attribute"

So I tried the reindex index pg_class_oid_index; again, and it responded with REINDEX, so I assume it succeeded. I can also login to the database as normal now(with out the PGOPTIONS="-P"). I'm assuming I should probably worry about the ERROR above. Is there another repair command to fix this or should I try to dump/initdb/reload?

Thanks,

Andrew

On Fri, Jul 24, 2009 at 2:33 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
Andrew Radamis <rust710@gmail.com> writes:
> I'm getting this error when I try to log into my database.
> *FATAL: root page 3 of "pg_class_oid_index" has level 0, expected 1

You've got a corrupted index.  You can probably fix it like this:

       export PGOPTIONS="-P"
       psql ..usual options..
       reindex index pg_class_oid_index;

After that, a dump/initdb/reload might be in order, since it's hard to
tell whether there are other problems lurking.  Some testing of your
hardware might be advisable too; and I'd suggest updating your Postgres
if it's not a recent release.

                       regards, tom lane

Andrew Radamis <rust710@gmail.com> writes:
> ERROR:  invalid page header in block 43 of relation "pg_attribute"

At this point I think you should assume you've got serious hardware
problems.  Get hold of some memory and disk test programs and see what
you can find out.

            regards, tom lane