Postgresql – Could not open file “pg_clog/0000”: No such file or directory

postgresqlpostgresql-9.2

My local PostgreSql 9.2 database won't start anymore this morning. I am on Windows 7. Yesterday, I performed a Windows Update before going to bed.

I have checked the log and found:

2014-05-28 10:16:03 CEST LOG:  database system was interrupted while in recovery at 2014-05-28 10:11:41 CEST
2014-05-28 10:16:03 CEST HINT:  This probably means that some data is corrupted and you will have to use the last backup for recovery.
2014-05-28 10:16:03 CEST LOG:  database system was not properly shut down; automatic recovery in progress
2014-05-28 10:16:03 CEST LOG:  redo starts at 0/25544D08
2014-05-28 10:16:03 CEST LOG:  file "pg_clog/0000" doesn't exist, reading as zeroes
2014-05-28 10:16:03 CEST CONTEXT:  xlog redo commit: 2014-04-24 18:48:48.775+02; rels: base/16855/140563 base/16855/140562 base/16855/140561 base/16855/140560 base/16855/140559 base/16855/140558 base/16855/140557 base/16855/140556
2014-05-28 10:16:03 CEST FATAL:  the database system is starting up
2014-05-28 10:16:04 CEST FATAL:  the database system is starting up
2014-05-28 10:16:05 CEST FATAL:  the database system is starting up
2014-05-28 10:16:06 CEST FATAL:  the database system is starting up
2014-05-28 10:16:07 CEST FATAL:  the database system is starting up
2014-05-28 10:16:08 CEST FATAL:  the database system is starting up
2014-05-28 10:16:12 CEST FATAL:  the database system is starting up
2014-05-28 10:16:13 CEST FATAL:  the database system is starting up
2014-05-28 10:16:14 CEST FATAL:  the database system is starting up
2014-05-28 10:16:15 CEST FATAL:  the database system is starting up
2014-05-28 10:16:16 CEST FATAL:  the database system is starting up
2014-05-28 10:16:18 CEST FATAL:  the database system is starting up
2014-05-28 10:16:19 CEST FATAL:  the database system is starting up
2014-05-28 10:16:20 CEST FATAL:  the database system is starting up
2014-05-28 10:16:21 CEST FATAL:  the database system is starting up
2014-05-28 10:16:22 CEST FATAL:  the database system is starting up
2014-05-28 10:16:23 CEST FATAL:  the database system is starting up
2014-05-28 10:16:24 CEST FATAL:  the database system is starting up
2014-05-28 10:16:25 CEST FATAL:  the database system is starting up
2014-05-28 10:16:26 CEST FATAL:  the database system is starting up
2014-05-28 10:16:27 CEST FATAL:  the database system is starting up
2014-05-28 10:16:28 CEST FATAL:  the database system is starting up
2014-05-28 10:16:29 CEST FATAL:  the database system is starting up
2014-05-28 10:16:30 CEST FATAL:  the database system is starting up
2014-05-28 10:16:31 CEST FATAL:  the database system is starting up
2014-05-28 10:16:32 CEST FATAL:  the database system is starting up
2014-05-28 10:16:33 CEST FATAL:  the database system is starting up
2014-05-28 10:16:34 CEST FATAL:  the database system is starting up
2014-05-28 10:16:35 CEST FATAL:  the database system is starting up
2014-05-28 10:16:36 CEST FATAL:  the database system is starting up
2014-05-28 10:16:37 CEST FATAL:  the database system is starting up
2014-05-28 10:16:38 CEST FATAL:  could not access status of transaction 0
2014-05-28 10:16:38 CEST DETAIL:  Could not open file "pg_clog/0000": No such file or directory.
2014-05-28 10:16:38 CEST CONTEXT:  xlog redo zeropage: 4
2014-05-28 10:16:38 CEST LOG:  startup process (PID 8024) exited with exit code 1
2014-05-28 10:16:38 CEST LOG:  aborting startup due to startup process failure

It is not a real issue if I have lost the database content, because I use it for development purposes only.

How should I proceed with this? Should I reinstall PostgreSql 9.2? Is there a command to restore it in a proper state?

Best Answer

If pg_clog is gone..... thats bad, this stores the commit log so the database knows what has and has not been committed. I would start looking at backups now, or if the data is disposable and there is no backup then building a new cluster. There are ways you can get the data out, but as far as I know they are very time consuming.

The bigger question though is what happened to your machine to cause this?