PG cannot be started because of invalid primary checkpoint record

Website content quality is poor, distribution efficiency is too low how to do?Huawei engineers offer 5 unique skills>>>

There is a development environment, because the disk space is full, someone directly put PG_ Wal under the file RM, and then restart the error

2020-06-28 18:13:59.148 CST   [10387]: LOG:  database system was shut down at 2020-06-28 18:12:41 CST
2020-06-28 18:13:59.148 CST   [10387]: LOG:  invalid primary checkpoint record
2020-06-28 18:13:59.148 CST   [10387]: PANIC:  could not locate a valid checkpoint record
2020-06-28 18:13:59.560 CST   [10342]: LOG:  startup process (PID 10387) was terminated by signal 6: Aborted
2020-06-28 18:13:59.560 CST   [10342]: LOG:  aborting startup due to startup process failure
2020-06-28 18:13:59.581 CST   [10342]: LOG:  database system is shut down

You can also see from the log file that the wal segment cannot be started because it cannot be found

$ more postgresql-Sun.log 
2020-06-28 18:17:25.882 CST   [12259]: LOG:  database system was shut down at 2020-06-28 18:16:48 CST
2020-06-28 18:17:25.882 CST   [12259]: LOG:  recovered replication state of node 1 to 2/F6A001C0
2020-06-28 18:17:25.887 CST   [12216]: LOG:  database system is ready to accept connections
2020-06-28 18:17:25.912 CST   [12269]: LOG:  logical replication apply worker for subscription "b_sub" has started
2020-06-28 18:17:25.922 CST ap a [12272]: LOG:  starting logical decoding for slot "publication_abce"
2020-06-28 18:17:25.922 CST ap a [12272]: DETAIL:  Streaming transactions committing after F/CD215498, reading WAL from F/CD215498.
2020-06-28 18:17:25.922 CST ap a [12272]: ERROR:  requested WAL segment 000000010000000F000000CD has already been removed
2020-06-28 18:17:25.922 CST   [12269]: ERROR:  could not receive data from WAL stream: ERROR:  requested WAL segment 000000010000000F000000CD has already been removed
2020-06-28 18:17:25.923 CST   [12216]: LOG:  background worker "logical replication worker" (PID 12269) exited with exit code 1
2020-06-28 18:17:30.935 CST   [12324]: LOG:  logical replication apply worker for subscription "b_sub" has started
2020-06-28 18:17:30.941 CST ap a [12325]: LOG:  starting logical decoding for slot "publication_abce"
2020-06-28 18:17:30.941 CST ap a [12325]: DETAIL:  Streaming transactions committing after F/CD215498, reading WAL from F/CD215498.
2020-06-28 18:17:30.941 CST ap a [12325]: ERROR:  requested WAL segment 000000010000000F000000CD has already been removed
2020-06-28 18:17:30.941 CST   [12324]: ERROR:  could not receive data from WAL stream: ERROR:  requested WAL segment 000000010000000F000000CD has already been removed
2020-06-28 18:17:30.943 CST   [12216]: LOG:  background worker "logical replication worker" (PID 12324) exited with exit code 1

  

Because it’s not an important environment, use PG directly_ Resetwal directly resets wal and other control information, and then restarts

$ pg_resetwal -f /data/pgdata/11/data
Write-ahead log reset

  

pg_ Resetwal will empty the data stored in PG_ Wal and other optional control information in the control file. Don’t use this command until you have to
after the tool is executed, the database can be started, but it may contain inconsistent data, because some transactions will be committed. After restart, it is recommended to dump the data immediately, run initdb and reload the data. Check data consistency and repair data as needed

You need to explicitly specify the directory, pg_ Resetwal does not use the environment variable pgdata

The – f parameter is to enforce PG_ resetwal。

Similar Posts: