diff options
author | Andres Freund <andres@anarazel.de> | 2025-03-30 17:28:03 -0400 |
---|---|---|
committer | Andres Freund <andres@anarazel.de> | 2025-03-30 17:28:03 -0400 |
commit | 047cba7fa0f8c6930b0dd1d93d98c736ef1e4a5a (patch) | |
tree | 29feb0de9ab74851134110b04486700444fa3852 /src/backend/storage/page/bufpage.c | |
parent | ef64fe26bad92a7b8425767cdbbe8b946d4637f0 (diff) | |
download | postgresql-047cba7fa0f8c6930b0dd1d93d98c736ef1e4a5a.tar.gz postgresql-047cba7fa0f8c6930b0dd1d93d98c736ef1e4a5a.zip |
bufmgr: Implement AIO read support
This commit implements the infrastructure to perform asynchronous reads into
the buffer pool.
To do so, it:
- Adds readv AIO callbacks for shared and local buffers
It may be worth calling out that shared buffer completions may be run in a
different backend than where the IO started.
- Adds an AIO wait reference to BufferDesc, to allow backends to wait for
in-progress asynchronous IOs
- Adapts StartBufferIO(), WaitIO(), TerminateBufferIO(), and their localbuf.c
equivalents, to be able to deal with AIO
- Moves the code to handle BM_PIN_COUNT_WAITER into a helper function, as it
now also needs to be called on IO completion
As of this commit, nothing issues AIO on shared/local buffers. A future commit
will update StartReadBuffers() to do so.
Buffer reads executed through this infrastructure will report invalid page /
checksum errors / warnings differently than before:
In the error case the error message will cover all the blocks that were
included in the read, rather than just the reporting the first invalid
block. If more than one block is invalid, the error will include information
about the range of the read, the first invalid block and the number of invalid
pages, with a HINT towards the server log for per-block details.
For the warning case (i.e. zero_damaged_buffers) we would previously emit one
warning message for each buffer in a multi-block read. Now there is only a
single warning message for the entire read, again referring to the server log
for more details in case of multiple checksum failures within a single larger
read.
Reviewed-by: Noah Misch <noah@leadboat.com>
Reviewed-by: Melanie Plageman <melanieplageman@gmail.com>
Reviewed-by: Nazir Bilal Yavuz <byavuz81@gmail.com>
Discussion: https://postgr.es/m/uvrtrknj4kdytuboidbhwclo4gxhswwcpgadptsjvjqcluzmah%40brqs62irg4dt
Discussion: https://postgr.es/m/20210223100344.llw5an2aklengrmn@alap3.anarazel.de
Discussion: https://postgr.es/m/stj36ea6yyhoxtqkhpieia2z4krnam7qyetc57rfezgk4zgapf@gcnactj4z56m
Diffstat (limited to 'src/backend/storage/page/bufpage.c')
-rw-r--r-- | src/backend/storage/page/bufpage.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/backend/storage/page/bufpage.c b/src/backend/storage/page/bufpage.c index 0afeab5140c..82457bacc62 100644 --- a/src/backend/storage/page/bufpage.c +++ b/src/backend/storage/page/bufpage.c @@ -78,8 +78,8 @@ PageInit(Page page, Size pageSize, Size specialSize) * treat such a page as empty and without free space. Eventually, VACUUM * will clean up such a page and make it usable. * - * If flag PIV_LOG_WARNING is set, a WARNING is logged in the event of - * a checksum failure. + * If flag PIV_LOG_WARNING/PIV_LOG_LOG is set, a WARNING/LOG message 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 @@ -143,13 +143,13 @@ PageIsVerified(PageData *page, BlockNumber blkno, int flags, bool *checksum_fail return true; /* - * Throw a WARNING if the checksum fails, but only after we've checked for - * the all-zeroes case. + * Throw a WARNING/LOG, as instructed by PIV_LOG_*, if the checksum fails, + * but only after we've checked for the all-zeroes case. */ if (checksum_failure) { - if ((flags & PIV_LOG_WARNING) != 0) - ereport(WARNING, + if ((flags & (PIV_LOG_WARNING | PIV_LOG_LOG)) != 0) + ereport(flags & PIV_LOG_WARNING ? WARNING : LOG, (errcode(ERRCODE_DATA_CORRUPTED), errmsg("page verification failed, calculated checksum %u but expected %u", checksum, p->pd_checksum))); |