mirror of
https://github.com/postgres/postgres.git
synced 2025-07-08 11:42:09 +03:00
Optionally prefetch referenced data in recovery.
Introduce a new GUC recovery_prefetch, disabled by default. When enabled, look ahead in the WAL and try to initiate asynchronous reading of referenced data blocks that are not yet cached in our buffer pool. For now, this is done with posix_fadvise(), which has several caveats. Better mechanisms will follow in later work on the I/O subsystem. The GUC maintenance_io_concurrency is used to limit the number of concurrent I/Os we allow ourselves to initiate, based on pessimistic heuristics used to infer that I/Os have begun and completed. The GUC wal_decode_buffer_size is used to limit the maximum distance we are prepared to read ahead in the WAL to find uncached blocks. Reviewed-by: Alvaro Herrera <alvherre@2ndquadrant.com> (parts) Reviewed-by: Andres Freund <andres@anarazel.de> (parts) Reviewed-by: Tomas Vondra <tomas.vondra@2ndquadrant.com> (parts) Tested-by: Tomas Vondra <tomas.vondra@2ndquadrant.com> Tested-by: Jakub Wartak <Jakub.Wartak@tomtom.com> Tested-by: Dmitry Dolgov <9erthalion6@gmail.com> Tested-by: Sait Talha Nisanci <Sait.Nisanci@microsoft.com> Discussion: https://postgr.es/m/CA%2BhUKGJ4VJN8ttxScUFM8dOKX0BrBiboo5uz1cq%3DAovOddfHpA%40mail.gmail.com
This commit is contained in:
@ -1927,6 +1927,8 @@ DecodeXLogRecord(XLogReaderState *state,
|
||||
blk->has_image = ((fork_flags & BKPBLOCK_HAS_IMAGE) != 0);
|
||||
blk->has_data = ((fork_flags & BKPBLOCK_HAS_DATA) != 0);
|
||||
|
||||
blk->recent_buffer = InvalidBuffer;
|
||||
|
||||
COPY_HEADER_FIELD(&blk->data_len, sizeof(uint16));
|
||||
/* cross-check that the HAS_DATA flag is set iff data_length > 0 */
|
||||
if (blk->has_data && blk->data_len == 0)
|
||||
@ -2134,6 +2136,15 @@ err:
|
||||
bool
|
||||
XLogRecGetBlockTag(XLogReaderState *record, uint8 block_id,
|
||||
RelFileNode *rnode, ForkNumber *forknum, BlockNumber *blknum)
|
||||
{
|
||||
return XLogRecGetRecentBuffer(record, block_id, rnode, forknum, blknum,
|
||||
NULL);
|
||||
}
|
||||
|
||||
bool
|
||||
XLogRecGetRecentBuffer(XLogReaderState *record, uint8 block_id,
|
||||
RelFileNode *rnode, ForkNumber *forknum,
|
||||
BlockNumber *blknum, Buffer *recent_buffer)
|
||||
{
|
||||
DecodedBkpBlock *bkpb;
|
||||
|
||||
@ -2148,6 +2159,8 @@ XLogRecGetBlockTag(XLogReaderState *record, uint8 block_id,
|
||||
*forknum = bkpb->forknum;
|
||||
if (blknum)
|
||||
*blknum = bkpb->blkno;
|
||||
if (recent_buffer)
|
||||
*recent_buffer = bkpb->recent_buffer;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user