Recently, I learned some about PostgreSQL data checksum and feel confused about the relationship between checksum and full page image.
As the following comment said at:
If we need to protect hint bit updates from torn writes, WAL-log a full page image of the page. This full page image is only necessary if the hint bit update is the first change to the page since the last checkpoint.
We don't check full_page_writes here because that logic is included when we call XLogInsert() since the value changes dynamically.
As I known, if we need to protect pages from torn writes including hint bit updates, we should enable full_page_writes
. Why do I need to write full page images at the WAL if the checksum is able to detect torn pages even if full_page_writes
is off?
The checksum will produce an error if you have a torn page, but it won't correct the error. All it tells you is that it is time to restore from backup.
If you want to avoid the problem alogether, leave full_page_writes
set to on
.