1
0
mirror of https://github.com/postgres/postgres.git synced 2025-10-27 00:12:01 +03:00

Let caller of PageIsVerified() control ignore_checksum_failure

For AIO the completion of a read into shared buffers (i.e. verifying the page
including the checksum, updating the BufferDesc to reflect the IO) can happen
in a different backend than the backend that started the IO. As
ignore_checksum_failure can differ between backends, we need to allow the
caller of PageIsVerified() control whether to ignore checksum failures.

The commit leaves a gap in the PIV_* values, as an upcoming commit, which
depends on this commit, will add PIV_LOG_LOG, which better fits just after
PIV_LOG_WARNING.

Reviewed-by: Noah Misch <noah@leadboat.com>
Discussion: https://postgr.es/m/20250329212929.a6.nmisch@google.com
This commit is contained in:
Andres Freund
2025-03-30 16:10:51 -04:00
parent b96d3c3897
commit d445990adc
4 changed files with 17 additions and 5 deletions

View File

@@ -81,10 +81,14 @@ PageInit(Page page, Size pageSize, Size specialSize)
* If flag PIV_LOG_WARNING is set, a WARNING is logged in the event of
* a checksum failure.
*
* If flag PIV_IGNORE_CHECKSUM_FAILURE is set, checksum failures will cause a
* message about the failure to be emitted, but will not cause
* PageIsVerified() to return false.
*
* To allow the caller to report statistics about checksum failures,
* *checksum_failure_p can be passed in. Note that there may be checksum
* failures even if this function returns true, due to
* ignore_checksum_failure.
* IGNORE_CHECKSUM_FAILURE.
*/
bool
PageIsVerified(PageData *page, BlockNumber blkno, int flags, bool *checksum_failure_p)
@@ -150,7 +154,7 @@ PageIsVerified(PageData *page, BlockNumber blkno, int flags, bool *checksum_fail
errmsg("page verification failed, calculated checksum %u but expected %u",
checksum, p->pd_checksum)));
if (header_sane && ignore_checksum_failure)
if (header_sane && (flags & PIV_IGNORE_CHECKSUM_FAILURE))
return true;
}