1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-25 12:03:53 +03:00

Support PrefetchBuffer() in recovery.

Provide PrefetchSharedBuffer(), a variant that takes SMgrRelation, for
use in recovery.  Rename LocalPrefetchBuffer() to PrefetchLocalBuffer()
for consistency.

Add a return value to all of these.  In recovery, tolerate and report
missing files, so we can handle relations unlinked before crash recovery
began.  Also report cache hits and misses, so that callers can do faster
buffer lookups and better I/O accounting.

Reviewed-by: Alvaro Herrera <alvherre@2ndquadrant.com>
Reviewed-by: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/CA%2BhUKGJ4VJN8ttxScUFM8dOKX0BrBiboo5uz1cq%3DAovOddfHpA%40mail.gmail.com
This commit is contained in:
Thomas Munro
2020-04-08 13:36:45 +12:00
parent 981643dcdb
commit 3985b600f5
8 changed files with 134 additions and 57 deletions

View File

@@ -46,6 +46,15 @@ typedef enum
* replay; otherwise same as RBM_NORMAL */
} ReadBufferMode;
/*
* Type returned by PrefetchBuffer().
*/
typedef struct PrefetchBufferResult
{
Buffer recent_buffer; /* If valid, a hit (recheck needed!) */
bool initiated_io; /* If true, a miss resulting in async I/O */
} PrefetchBufferResult;
/* forward declared, to avoid having to expose buf_internals.h here */
struct WritebackContext;
@@ -162,8 +171,11 @@ extern PGDLLIMPORT int32 *LocalRefCount;
/*
* prototypes for functions in bufmgr.c
*/
extern void PrefetchBuffer(Relation reln, ForkNumber forkNum,
BlockNumber blockNum);
extern PrefetchBufferResult PrefetchSharedBuffer(struct SMgrRelationData *smgr_reln,
ForkNumber forkNum,
BlockNumber blockNum);
extern PrefetchBufferResult PrefetchBuffer(Relation reln, ForkNumber forkNum,
BlockNumber blockNum);
extern Buffer ReadBuffer(Relation reln, BlockNumber blockNum);
extern Buffer ReadBufferExtended(Relation reln, ForkNumber forkNum,
BlockNumber blockNum, ReadBufferMode mode,