Unix Technical Forum

db crash after power crash

This is a discussion on db crash after power crash within the Pgsql General forums, part of the PostgreSQL category; --> Hi. Some hours ago there was a power failure with my test machine while active inserting data. After power ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > Pgsql General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-09-2008, 10:58 AM
Anton Maksimenkov
 
Posts: n/a
Default db crash after power crash

Hi.

Some hours ago there was a power failure with my test machine while
active inserting data. After power back the OS done some "fsck", clean
some files (related to postgres working directory). Then I connect to
my DB and see this:

billing=# \d
ERROR: index "pg_attribute_relid_attnum_index" is not a btree
billing=# reindex index pg_attribute_relid_attnum_index;
ERROR: catalog is missing 1 attribute(s) for relid 2678

I searched through archives and tried to do some:

# reindexdb -s -U root -d billing
Password:
reindexdb: reindexing of system catalogs failed: ERROR: index
"pg_attribute_relid_attnum_index" is not a btree
# reindexdb -U root -d billing
Password:
reindexdb: reindexing of database "billing" failed: ERROR: index
"pg_attribute_relid_attnum_index" is not a btree

as you can see, without success. And so with vacuumdb.

That all was on my test (learning) environment... But this may occur
on production machine (who knows, anything may happens) and I want to
know how to play with such situations (or workaround them). My only
idea - to get the last 'pg_dump' file, drop database and restore it
from that file... but it is ugly idea because many recent data will be
lost. Is there other ways?

--
engineer

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-09-2008, 10:58 AM
Tom Lane
 
Posts: n/a
Default Re: db crash after power crash

"Anton Maksimenkov" <anton200@gmail.com> writes:
> # reindexdb -s -U root -d billing
> Password:
> reindexdb: reindexing of system catalogs failed: ERROR: index
> "pg_attribute_relid_attnum_index" is not a btree


This will not work unless backend is started with -P option.
See the REINDEX reference page for details.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-09-2008, 10:58 AM
Anton Maksimenkov
 
Posts: n/a
Default Re: db crash after power crash

May I ask - how can I do it...? My ordinary startup command (from
rc.local) like this
# su -l _postgresql -c "nohup /usr/local/bin/pg_ctl start -D
/var/postgresql/data -l /var/postgresql/logfile -o '-D
/var/postgresql/data'"

But I tried

# su -l _postgresql
$ postgres -D /var/postgresql/data/ -P billing
FATAL: catalog is missing 1 attribute(s) for relid 2662

Anyhow, after all it is completely refuse to log me on. After shutting
down and ordinary startup the RDBMS:

$ export PGOPTIONS="-P"
$ psql -d billing
Password:
psql: FATAL: catalog is missing 1 attribute(s) for relid 2662

$ unset PGOPTIONS
$ psql -d billing
Password:
psql: FATAL: catalog is missing 1 attribute(s) for relid 2662

I think I broke something while experimenting with feeding -P to my
ordinary startup string...
--
engineer

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-09-2008, 10:58 AM
Tom Lane
 
Posts: n/a
Default Re: db crash after power crash

"Anton Maksimenkov" <anton200@gmail.com> writes:
> But I tried


> # su -l _postgresql
> $ postgres -D /var/postgresql/data/ -P billing
> FATAL: catalog is missing 1 attribute(s) for relid 2662


In that case I'm afraid you're stuck: it looks like it's not just the
index but the underlying catalog that's lost data. Were you running
with fsync off by any chance?

For forensic purposes it might be interesting to dump out the
pg_attribute catalog (file 1249) with pg_filedump, just to see what sort
of corruption is there. But I'm afraid the odds of resurrecting the
database are small.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 02:22 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com