mirror of
https://github.com/postgres/postgres.git
synced 2025-06-30 21:42:05 +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:
@ -54,17 +54,17 @@ static Block GetLocalBufferStorage(void);
|
||||
|
||||
|
||||
/*
|
||||
* LocalPrefetchBuffer -
|
||||
* PrefetchLocalBuffer -
|
||||
* initiate asynchronous read of a block of a relation
|
||||
*
|
||||
* Do PrefetchBuffer's work for temporary relations.
|
||||
* No-op if prefetching isn't compiled in.
|
||||
*/
|
||||
void
|
||||
LocalPrefetchBuffer(SMgrRelation smgr, ForkNumber forkNum,
|
||||
PrefetchBufferResult
|
||||
PrefetchLocalBuffer(SMgrRelation smgr, ForkNumber forkNum,
|
||||
BlockNumber blockNum)
|
||||
{
|
||||
#ifdef USE_PREFETCH
|
||||
PrefetchBufferResult result = {InvalidBuffer, false};
|
||||
BufferTag newTag; /* identity of requested block */
|
||||
LocalBufferLookupEnt *hresult;
|
||||
|
||||
@ -81,12 +81,18 @@ LocalPrefetchBuffer(SMgrRelation smgr, ForkNumber forkNum,
|
||||
if (hresult)
|
||||
{
|
||||
/* Yes, so nothing to do */
|
||||
return;
|
||||
result.recent_buffer = -hresult->id - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef USE_PREFETCH
|
||||
/* Not in buffers, so initiate prefetch */
|
||||
smgrprefetch(smgr, forkNum, blockNum);
|
||||
result.initiated_io = true;
|
||||
#endif /* USE_PREFETCH */
|
||||
}
|
||||
|
||||
/* Not in buffers, so initiate prefetch */
|
||||
smgrprefetch(smgr, forkNum, blockNum);
|
||||
#endif /* USE_PREFETCH */
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user