Postgres: PANIC: could not locate a valid checkpoint record

I recently started to play with Postgres and this was one of the errors I got from my setup when I was trying to bring up the database:

 

[Tue Nov 06 09:58:10 [email protected]:~ ] $ su - postgres -c '/usr/pgsql-10/bin/pg_ctl -D $PGDATA start'
waiting for server to start....2018-11-06 09:58:37.346 UTC [21595] LOG: listening on IPv4 address "127.0.0.1", port 5444
2018-11-06 09:58:37.349 UTC [21595] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5444"
2018-11-06 09:58:37.355 UTC [21595] LOG: listening on Unix socket "/tmp/.s.PGSQL.5444"
2018-11-06 09:58:37.375 UTC [21595] LOG: redirecting log output to logging collector process
2018-11-06 09:58:37.375 UTC [21595] HINT: Future log output will appear in directory "/app/pgsql/admin/test/pg_log".
stopped waiting
pg_ctl: could not start server
Examine the log output.


[Tue Nov 06 10:04:29 [email protected]:/app/pgsql/admin/test/pg_log ] $ tail -f pglog_test_20181106.log
2018-11-06 09:56:12.529 UTC [21573] LOG: startup process (PID 21575) was terminated by signal 6: Aborted
2018-11-06 09:56:12.529 UTC [21573] LOG: aborting startup due to startup process failure
2018-11-06 09:56:12.530 UTC [21573] LOG: database system is shut down
2018-11-06 09:58:37.379 UTC [21597] LOG: database system was shut down at 2018-11-06 09:46:58 UTC
2018-11-06 09:58:37.379 UTC [21597] LOG: invalid primary checkpoint record
2018-11-06 09:58:37.379 UTC [21597] LOG: invalid secondary checkpoint record
2018-11-06 09:58:37.379 UTC [21597] PANIC: could not locate a valid checkpoint record
2018-11-06 09:58:37.379 UTC [21595] LOG: startup process (PID 21597) was terminated by signal 6: Aborted
2018-11-06 09:58:37.379 UTC [21595] LOG: aborting startup due to startup process failure
2018-11-06 09:58:37.381 UTC [21595] LOG: database system is shut down

 

The solution is to perform a “Write-ahead log reset”:

[Tue Nov 06 10:02:24 [email protected]:/app/pgsql/admin/test/pg_log ] $ su - postgres -c '/usr/pgsql-10/bin/pg_resetwal $PGDATA'
Write-ahead log reset

 

And start the database:

[Tue Nov 06 10:06:25 [email protected]:/app/pgsql/admin/test/pg_log ] $ su - postgres -c '/usr/pgsql-10/bin/pg_ctl -D $PGDATA start'
waiting for server to start....2018-11-06 10:06:33.452 UTC [21668] LOG: listening on IPv4 address "127.0.0.1", port 5444
2018-11-06 10:06:33.454 UTC [21668] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5444"
2018-11-06 10:06:33.458 UTC [21668] LOG: listening on Unix socket "/tmp/.s.PGSQL.5444"
2018-11-06 10:06:33.467 UTC [21668] LOG: redirecting log output to logging collector process
2018-11-06 10:06:33.467 UTC [21668] HINT: Future log output will appear in directory "/app/pgsql/admin/test/pg_log".
done
server started

 

Leave Comment

Your email address will not be published. Required fields are marked *