校验和与整页图像有什么关系?

What's the relationship between checksum and full page image?

最近学习了一些关于PostgreSQL数据校验和的知识,对校验和与整页图片的关系感到困惑。

正如以下评论所说:

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.

据我所知,如果我们需要保护页面免受包括提示位更新在内的撕裂写入,我们应该启用 full_page_writes。如果校验和能够检测到撕裂的页面,即使 full_page_writes 关闭,为什么我需要在 WAL 中写入整页图像?

如果您有损坏的页面,校验和会产生错误,但不会更正错误。它只告诉您是时候从备份中恢复了。

如果您想同时避免该问题,请将 full_page_writes 设置为 on