Using Debian Wheezy, Postgresql 9.3
My database went down because the partition where it keeps the WAL files got full.
So, I deleted everything inside ./pg_xlog/
, because I didn't know what they were (yea, incredibly stupid of me). Now the Postgres service won't start, though the problem, according to syslog:
00000: could not open tablespace directory "pg_tblspc/16386/PG_9.3_201306121": File or directory not found
LOCAL: RelationCacheInitFileRemoveInDir, relcache.c:4895
00000: Primary checkpoint record is invalid
LOCAL: ReadCheckpointRecord, xlog.c:6543
00000: Secondary checkpoint record is invalid
LOCAL: ReadCheckpointRecord, xlog.c:6547
PANIC: XX000: could not locate a valid checkpoint record
LOCAL: StartupXLOG, xlog.c:5228
I'm not entirely sure whether the problem is that it can't find the proper pg_tblspc or the total lack of checkpoint WAL files. The actual path to where the databases are stored is /dados/PG_9.3_201306121
. What can I do to make the service start again?
EDIT1:
Okay, I've managed to get the thing back online. Some databases got corrupt. I've managed to DROPDB
two of them (couldn't even connect to them without them forcing a service restart). I tried doing it to another one that got corrupt, but the error was related to xlog again. I've tried doing a clean restore over it, but the restore was incomplete. Then, I've created a new database and tried to restore an older backup of this database. It also came incomplete.
Now I can't drop any databases, nor create new ones, I always get a xlog flush request not satisfied
error. I've tried running pg_resetxlog
, but it didn't seem to do anything. Another thing the error shows is cannot write to block 1 of pg_tblspc/16385/PG_9.3_201306121/36596452/11773
, write error may be permanent
.
EDIT2: Part of the problem above was with that 11773 file. I've renamed it to 11773.corrupt and now the database allows me to create and drop again.
initdb
a new one (or use your package's wrapper, however you first set it up) and then restore your dumps to the new PostgreSQL instance.