Preventing page corruption
Database corruption is a major concern, since in a worst case scenario we may lose valuable customer related data. It is also a painful job, to recover the corrupted disk or restore the data from previous backups. Database corruption can happen due to the following reasons:
Bad hardware
Bug in database software
Bug in a kernel
Bad database configuration
As like other database management systems, PostgreSQL also provides few configuration settings, which will try to avoid the page corruption. If page corruption happens at disk level, then PostgreSQL has the ability to bypass the corrupted data, and return the uncorrupted data.
Getting ready
In this recipe, we will be discussing how to enable the checksums for each data block, and how to retain the uncorrupted data when any corruption happens.
To enable the checksums for each data block, we have to initialize the PostgreSQL cluster with the --data-checksums
option using the initdb
command. Adding this checksum option will...