62 #define BufHdrGetBlock(bufHdr) ((Block) (BufferBlocks + ((Size) (bufHdr)->buf_id) * BLCKSZ))
63 #define BufferGetLSN(bufHdr) (PageGetLSN(BufHdrGetBlock(bufHdr)))
66 #define LocalBufHdrGetBlock(bufHdr) \
67 LocalBufferBlockPointers[-((bufHdr)->buf_id + 2)]
70 #define BUF_WRITTEN 0x01
71 #define BUF_REUSABLE 0x02
73 #define RELS_BSEARCH_THRESHOLD 20
81 #define BUF_DROP_FULL_SCAN_THRESHOLD (uint64) (NBuffers / 32)
90 #define REFCOUNT_ARRAY_ENTRIES 8
365 free->refcount =
res->refcount;
441 #define BufferIsPinned(bufnum) \
443 !BufferIsValid(bufnum) ? \
446 BufferIsLocal(bufnum) ? \
447 (LocalRefCount[-(bufnum) - 1] > 0) \
449 (GetPrivateRefCount(bufnum) > 0) \
462 static int SyncOneBuffer(
int buf_id,
bool skip_recently_used,
593 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
594 errmsg(
"cannot access temporary tables of other sessions")));
620 bool have_private_ref;
630 int b = -recent_buffer - 1;
668 if (have_private_ref)
680 if (have_private_ref)
691 if (!have_private_ref)
763 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
764 errmsg(
"cannot access temporary tables of other sessions")));
772 forkNum, blockNum,
mode, strategy, &hit);
799 RELPERSISTENCE_UNLOGGED, forkNum, blockNum,
800 mode, strategy, &hit);
825 isExtend = (blockNum ==
P_NEW);
827 TRACE_POSTGRESQL_BUFFER_READ_START(forkNum, blockNum,
839 if (blockNum ==
P_NEW)
841 (
errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
842 errmsg(
"cannot extend relation %s beyond %u blocks",
864 bufHdr =
BufferAlloc(smgr, relpersistence, forkNum, blockNum,
889 TRACE_POSTGRESQL_BUFFER_READ_DONE(forkNum, blockNum,
929 (
errmsg(
"unexpected data beyond EOF in block %u of relation %s",
931 errhint(
"This has been seen to occur with buggy kernels; consider updating your system.")));
985 MemSet((
char *) bufBlock, 0, BLCKSZ);
987 smgrextend(smgr, forkNum, blockNum, (
char *) bufBlock,
false);
1003 MemSet((
char *) bufBlock, 0, BLCKSZ);
1014 smgrread(smgr, forkNum, blockNum, (
char *) bufBlock);
1032 errmsg(
"invalid page in block %u of relation %s; zeroing out page",
1035 MemSet((
char *) bufBlock, 0, BLCKSZ);
1040 errmsg(
"invalid page in block %u of relation %s",
1081 TRACE_POSTGRESQL_BUFFER_READ_DONE(forkNum, blockNum,
1119 LWLock *newPartitionLock;
1122 LWLock *oldPartitionLock;
1240 if (strategy != NULL)
1260 TRACE_POSTGRESQL_BUFFER_WRITE_DIRTY_START(forkNum, blockNum,
1271 TRACE_POSTGRESQL_BUFFER_WRITE_DIRTY_DONE(forkNum, blockNum,
1306 if (oldPartitionLock < newPartitionLock)
1311 else if (oldPartitionLock > newPartitionLock)
1327 oldPartitionLock = NULL;
1352 if (oldPartitionLock != NULL &&
1353 oldPartitionLock != newPartitionLock)
1406 if (oldPartitionLock != NULL &&
1407 oldPartitionLock != newPartitionLock)
1430 if (relpersistence == RELPERSISTENCE_PERMANENT || forkNum ==
INIT_FORKNUM)
1437 if (oldPartitionLock != NULL)
1440 if (oldPartitionLock != newPartitionLock)
1482 LWLock *oldPartitionLock;
1535 elog(
ERROR,
"buffer is pinned in InvalidateBuffer");
1603 buf_state = old_buf_state;
1719 buf_state = old_buf_state;
1724 if (strategy == NULL)
1743 result = (buf_state &
BM_VALID) != 0;
1885 buf_state = old_buf_state;
1910 int wait_backend_pgprocno =
buf->wait_backend_pgprocno;
1923 #define ST_SORT sort_checkpoint_bufferids
1924 #define ST_ELEMENT_TYPE CkptSortItem
1925 #define ST_COMPARE(a, b) ckpt_buforder_comparator(a, b)
1926 #define ST_SCOPE static
1985 for (buf_id = 0; buf_id <
NBuffers; buf_id++)
1995 if ((buf_state & mask) == mask)
2016 if (num_to_scan == 0)
2021 TRACE_POSTGRESQL_BUFFER_SYNC_START(
NBuffers, num_to_scan);
2039 for (
i = 0;
i < num_to_scan;
i++)
2050 if (last_tsid ==
InvalidOid || last_tsid != cur_tsid)
2062 if (per_ts_stat == NULL)
2067 s = &per_ts_stat[num_spaces - 1];
2068 memset(s, 0,
sizeof(*s));
2083 last_tsid = cur_tsid;
2087 s = &per_ts_stat[num_spaces - 1];
2108 for (
i = 0;
i < num_spaces;
i++)
2156 TRACE_POSTGRESQL_BUFFER_SYNC_WRITTEN(buf_id);
2202 TRACE_POSTGRESQL_BUFFER_SYNC_DONE(
NBuffers, num_written, num_to_scan);
2220 int strategy_buf_id;
2228 static bool saved_info_valid =
false;
2229 static int prev_strategy_buf_id;
2230 static uint32 prev_strategy_passes;
2231 static int next_to_clean;
2232 static uint32 next_passes;
2235 static float smoothed_alloc = 0;
2236 static float smoothed_density = 10.0;
2239 float smoothing_samples = 16;
2240 float scan_whole_pool_milliseconds = 120000.0;
2243 long strategy_delta;
2246 float scans_per_alloc;
2247 int reusable_buffers_est;
2248 int upcoming_alloc_est;
2249 int min_scan_buffers;
2254 int reusable_buffers;
2257 long new_strategy_delta;
2276 saved_info_valid =
false;
2288 if (saved_info_valid)
2290 int32 passes_delta = strategy_passes - prev_strategy_passes;
2292 strategy_delta = strategy_buf_id - prev_strategy_buf_id;
2293 strategy_delta += (long) passes_delta *
NBuffers;
2295 Assert(strategy_delta >= 0);
2297 if ((
int32) (next_passes - strategy_passes) > 0)
2300 bufs_to_lap = strategy_buf_id - next_to_clean;
2302 elog(
DEBUG2,
"bgwriter ahead: bgw %u-%u strategy %u-%u delta=%ld lap=%d",
2303 next_passes, next_to_clean,
2304 strategy_passes, strategy_buf_id,
2305 strategy_delta, bufs_to_lap);
2308 else if (next_passes == strategy_passes &&
2309 next_to_clean >= strategy_buf_id)
2312 bufs_to_lap =
NBuffers - (next_to_clean - strategy_buf_id);
2314 elog(
DEBUG2,
"bgwriter ahead: bgw %u-%u strategy %u-%u delta=%ld lap=%d",
2315 next_passes, next_to_clean,
2316 strategy_passes, strategy_buf_id,
2317 strategy_delta, bufs_to_lap);
2327 elog(
DEBUG2,
"bgwriter behind: bgw %u-%u strategy %u-%u delta=%ld",
2328 next_passes, next_to_clean,
2329 strategy_passes, strategy_buf_id,
2332 next_to_clean = strategy_buf_id;
2333 next_passes = strategy_passes;
2344 elog(
DEBUG2,
"bgwriter initializing: strategy %u-%u",
2345 strategy_passes, strategy_buf_id);
2348 next_to_clean = strategy_buf_id;
2349 next_passes = strategy_passes;
2354 prev_strategy_buf_id = strategy_buf_id;
2355 prev_strategy_passes = strategy_passes;
2356 saved_info_valid =
true;
2364 if (strategy_delta > 0 && recent_alloc > 0)
2366 scans_per_alloc = (float) strategy_delta / (
float) recent_alloc;
2367 smoothed_density += (scans_per_alloc - smoothed_density) /
2376 bufs_ahead =
NBuffers - bufs_to_lap;
2377 reusable_buffers_est = (float) bufs_ahead / smoothed_density;
2384 if (smoothed_alloc <= (
float) recent_alloc)
2385 smoothed_alloc = recent_alloc;
2387 smoothed_alloc += ((float) recent_alloc - smoothed_alloc) /
2401 if (upcoming_alloc_est == 0)
2416 if (upcoming_alloc_est < (min_scan_buffers + reusable_buffers_est))
2419 elog(
DEBUG2,
"bgwriter: alloc_est=%d too small, using min=%d + reusable_est=%d",
2420 upcoming_alloc_est, min_scan_buffers, reusable_buffers_est);
2422 upcoming_alloc_est = min_scan_buffers + reusable_buffers_est;
2435 num_to_scan = bufs_to_lap;
2437 reusable_buffers = reusable_buffers_est;
2440 while (num_to_scan > 0 && reusable_buffers < upcoming_alloc_est)
2468 elog(
DEBUG1,
"bgwriter: recent_alloc=%u smoothed=%.2f delta=%ld ahead=%d density=%.2f reusable_est=%d upcoming_est=%d scanned=%d wrote=%d reusable=%d",
2469 recent_alloc, smoothed_alloc, strategy_delta, bufs_ahead,
2470 smoothed_density, reusable_buffers_est, upcoming_alloc_est,
2471 bufs_to_lap - num_to_scan,
2473 reusable_buffers - reusable_buffers_est);
2484 new_strategy_delta = bufs_to_lap - num_to_scan;
2485 new_recent_alloc = reusable_buffers - reusable_buffers_est;
2486 if (new_strategy_delta > 0 && new_recent_alloc > 0)
2488 scans_per_alloc = (float) new_strategy_delta / (
float) new_recent_alloc;
2489 smoothed_density += (scans_per_alloc - smoothed_density) /
2493 elog(
DEBUG2,
"bgwriter: cleaner density alloc=%u scan=%ld density=%.2f new smoothed=%.2f",
2494 new_recent_alloc, new_strategy_delta,
2495 scans_per_alloc, smoothed_density);
2500 return (bufs_to_lap == 0 && recent_alloc == 0);
2545 else if (skip_recently_used)
2650 #ifdef USE_ASSERT_CHECKING
2651 int RefCountErrors = 0;
2680 Assert(RefCountErrors == 0);
2715 "buffer refcount leak: [%03d] "
2716 "(rel=%s, blockNum=%u, flags=0x%x, refcount=%u %d)",
2836 errcallback.
arg = (
void *)
buf;
2947 if (RELKIND_HAS_TABLE_AM(relation->
rd_rel->relkind))
2959 return (szbytes + (BLCKSZ - 1)) / BLCKSZ;
2961 else if (RELKIND_HAS_STORAGE(relation->
rd_rel->relkind))
3060 uint64 nBlocksToInvalidate = 0;
3069 for (
j = 0;
j < nforks;
j++)
3098 for (
i = 0;
i < nforks;
i++)
3110 nBlocksToInvalidate += (nForkBlock[
i] - firstDelBlock[
i]);
3120 for (
j = 0;
j < nforks;
j++)
3122 nForkBlock[
j], firstDelBlock[
j]);
3152 for (
j = 0;
j < nforks;
j++)
3182 uint64 nBlocksToInvalidate = 0;
3193 for (
i = 0;
i < nlocators;
i++)
3197 if (smgr_reln[
i]->smgr_rlocator.backend ==
MyBackendId)
3201 rels[n++] = smgr_reln[
i];
3225 for (
i = 0;
i < n && cached;
i++)
3242 nBlocksToInvalidate += block[
i][
j];
3252 for (
i = 0;
i < n;
i++)
3273 for (
i = 0;
i < n;
i++)
3274 locators[
i] = rels[
i]->smgr_rlocator.locator;
3303 for (
j = 0;
j < n;
j++)
3307 rlocator = &locators[
j];
3317 rlocator = bsearch((
const void *) &(locator),
3323 if (rlocator == NULL)
3353 for (curBlock = firstDelBlock; curBlock < nForkBlock; curBlock++)
3357 LWLock *bufPartitionLock;
3446 PrintBufferDescs(
void)
3457 "[%02d] (freeNext=%d, rel=%s, "
3458 "blockNum=%u, flags=0x%x, refcount=%u %d)",
3462 buf->tag.blockNum,
buf->flags,
3470 PrintPinnedBufs(
void)
3483 "[%02d] (freeNext=%d, rel=%s, "
3484 "blockNum=%u, flags=0x%x, refcount=%u %d)",
3488 buf->tag.blockNum,
buf->flags,
3537 errcallback.
arg = (
void *) bufHdr;
3615 for (
i = 0;
i < nrels;
i++)
3620 srels[
i].
srel = smgrs[
i];
3651 for (
j = 0;
j < nrels;
j++)
3655 srelent = &srels[
j];
3665 srelent = bsearch((
const void *) &(rlocator),
3671 if (srelent == NULL)
3738 memset(
buf.data, 0, BLCKSZ);
3747 for (blkno = 0; blkno < nblocks; blkno++)
3768 memcpy(dstPage, srcPage, BLCKSZ);
3798 char relpersistence;
3801 relpersistence = permanent ?
3802 RELPERSISTENCE_PERMANENT : RELPERSISTENCE_UNLOGGED;
3840 rlocator.
locator = src_rlocator;
3843 rlocator.
locator = dst_rlocator;
4031 bool dirtied =
false;
4032 bool delayChkptFlags =
false;
4084 delayChkptFlags =
true;
4116 if (delayChkptFlags)
4227 char *new_status = NULL;
4229 bool logged_recovery_conflict =
false;
4238 elog(
ERROR,
"incorrect local pin count: %d",
4246 elog(
ERROR,
"incorrect local pin count: %d",
4270 if (logged_recovery_conflict)
4288 elog(
ERROR,
"multiple backends attempting to wait for pincount 1");
4302 const char *old_status;
4306 new_status = (
char *)
palloc(
len + 8 + 1);
4307 memcpy(new_status, old_status,
len);
4308 strcpy(new_status +
len,
" waiting");
4310 new_status[
len] =
'\0';
4321 if (waitStart != 0 && !logged_recovery_conflict)
4329 waitStart,
now, NULL,
true);
4330 logged_recovery_conflict =
true;
4619 buf_state |= set_flag_bits;
4669 errmsg(
"could not write block %u of %s",
4670 buf->tag.blockNum, path),
4671 errdetail(
"Multiple failures --- write error might be permanent.")));
4693 errcontext(
"writing block %u of relation %s",
4713 errcontext(
"writing block %u of relation %s",
4839 if (
a->tsId <
b->tsId)
4841 else if (
a->tsId >
b->tsId)
4844 if (
a->relNumber <
b->relNumber)
4846 else if (
a->relNumber >
b->relNumber)
4849 else if (
a->forkNum <
b->forkNum)
4851 else if (
a->forkNum >
b->forkNum)
4854 else if (
a->blockNum <
b->blockNum)
4856 else if (
a->blockNum >
b->blockNum)
4916 pending->
tag = *tag;
4928 #define ST_SORT sort_pending_writebacks
4929 #define ST_ELEMENT_TYPE PendingWriteback
4930 #define ST_COMPARE(a, b) buffertag_comparator(&a->tag, &b->tag)
4931 #define ST_SCOPE static
4979 for (ahead = 0;
i + ahead + 1 < context->
nr_pending; ahead++)
4991 if (
cur->tag.blockNum ==
next->tag.blockNum)
4995 if (
cur->tag.blockNum + 1 !=
next->tag.blockNum)
5025 (
errcode(ERRCODE_SNAPSHOT_TOO_OLD),
5026 errmsg(
"snapshot too old")));
static bool pg_atomic_compare_exchange_u32(volatile pg_atomic_uint32 *ptr, uint32 *expected, uint32 newval)
static uint32 pg_atomic_fetch_or_u32(volatile pg_atomic_uint32 *ptr, uint32 or_)
static void pg_atomic_unlocked_write_u32(volatile pg_atomic_uint32 *ptr, uint32 val)
static uint32 pg_atomic_read_u32(volatile pg_atomic_uint32 *ptr)
bool TimestampDifferenceExceeds(TimestampTz start_time, TimestampTz stop_time, int msec)
TimestampTz GetCurrentTimestamp(void)
Datum now(PG_FUNCTION_ARGS)
void binaryheap_build(binaryheap *heap)
void binaryheap_add_unordered(binaryheap *heap, Datum d)
binaryheap * binaryheap_allocate(int capacity, binaryheap_comparator compare, void *arg)
Datum binaryheap_remove_first(binaryheap *heap)
void binaryheap_free(binaryheap *heap)
void binaryheap_replace_first(binaryheap *heap, Datum d)
Datum binaryheap_first(binaryheap *heap)
#define binaryheap_empty(h)
#define InvalidBlockNumber
static bool BlockNumberIsValid(BlockNumber blockNumber)
#define BufferIsLocal(buffer)
CkptSortItem * CkptBufferIds
WritebackContext BackendWritebackContext
#define BM_MAX_USAGE_COUNT
static void InitBufferTag(BufferTag *tag, const RelFileLocator *rlocator, ForkNumber forkNum, BlockNumber blockNum)
#define BUF_USAGECOUNT_MASK
static ForkNumber BufTagGetForkNum(const BufferTag *tag)
static BufferDesc * GetLocalBufferDescriptor(uint32 id)
static BufferDesc * GetBufferDescriptor(uint32 id)
static void UnlockBufHdr(BufferDesc *desc, uint32 buf_state)
static bool BufferTagsEqual(const BufferTag *tag1, const BufferTag *tag2)
static RelFileNumber BufTagGetRelNumber(const BufferTag *tag)
static bool BufTagMatchesRelFileLocator(const BufferTag *tag, const RelFileLocator *rlocator)
static LWLock * BufMappingPartitionLock(uint32 hashcode)
#define BM_PIN_COUNT_WAITER
#define BUF_STATE_GET_USAGECOUNT(state)
#define BM_IO_IN_PROGRESS
static void ClearBufferTag(BufferTag *tag)
static ConditionVariable * BufferDescriptorGetIOCV(const BufferDesc *bdesc)
#define BUF_USAGECOUNT_ONE
#define BUF_STATE_GET_REFCOUNT(state)
static RelFileLocator BufTagGetRelFileLocator(const BufferTag *tag)
static Buffer BufferDescriptorGetBuffer(const BufferDesc *bdesc)
#define BM_CHECKPOINT_NEEDED
static LWLock * BufferDescriptorGetContentLock(const BufferDesc *bdesc)
void BufTableDelete(BufferTag *tagPtr, uint32 hashcode)
int BufTableLookup(BufferTag *tagPtr, uint32 hashcode)
uint32 BufTableHashCode(BufferTag *tagPtr)
int BufTableInsert(BufferTag *tagPtr, uint32 hashcode, int buf_id)
void FlushRelationsAllBuffers(SMgrRelation *smgrs, int nrels)
void IncrBufferRefCount(Buffer buffer)
void DropDatabaseBuffers(Oid dbid)
static int ckpt_buforder_comparator(const CkptSortItem *a, const CkptSortItem *b)
BlockNumber BufferGetBlockNumber(Buffer buffer)
static PrivateRefCountEntry * NewPrivateRefCountEntry(Buffer buffer)
void DropRelationBuffers(SMgrRelation smgr_reln, ForkNumber *forkNum, int nforks, BlockNumber *firstDelBlock)
Buffer ReleaseAndReadBuffer(Buffer buffer, Relation relation, BlockNumber blockNum)
PrefetchBufferResult PrefetchBuffer(Relation reln, ForkNumber forkNum, BlockNumber blockNum)
static uint32 PrivateRefCountClock
static bool PinBuffer(BufferDesc *buf, BufferAccessStrategy strategy)
#define BUF_DROP_FULL_SCAN_THRESHOLD
static void PinBuffer_Locked(BufferDesc *buf)
static uint32 WaitBufHdrUnlocked(BufferDesc *buf)
static int buffertag_comparator(const BufferTag *ba, const BufferTag *bb)
#define LocalBufHdrGetBlock(bufHdr)
bool IsBufferCleanupOK(Buffer buffer)
#define BufferGetLSN(bufHdr)
void AtEOXact_Buffers(bool isCommit)
static void CheckForBufferLeaks(void)
void CreateAndCopyRelationData(RelFileLocator src_rlocator, RelFileLocator dst_rlocator, bool permanent)
void DropRelationsAllBuffers(SMgrRelation *smgr_reln, int nlocators)
static int rlocator_comparator(const void *p1, const void *p2)
void TestForOldSnapshot_impl(Snapshot snapshot, Relation relation)
struct SMgrSortArray SMgrSortArray
static void AtProcExit_Buffers(int code, Datum arg)
static int ts_ckpt_progress_comparator(Datum a, Datum b, void *arg)
void BufferGetTag(Buffer buffer, RelFileLocator *rlocator, ForkNumber *forknum, BlockNumber *blknum)
#define BufHdrGetBlock(bufHdr)
void ScheduleBufferTagForWriteback(WritebackContext *context, BufferTag *tag)
static void local_buffer_write_error_callback(void *arg)
static void BufferSync(int flags)
static BufferDesc * BufferAlloc(SMgrRelation smgr, char relpersistence, ForkNumber forkNum, BlockNumber blockNum, BufferAccessStrategy strategy, bool *foundPtr)
static BufferDesc * InProgressBuf
void CheckPointBuffers(int flags)
bool BgBufferSync(WritebackContext *wb_context)
bool BufferIsPermanent(Buffer buffer)
#define REFCOUNT_ARRAY_ENTRIES
PrefetchBufferResult PrefetchSharedBuffer(SMgrRelation smgr_reln, ForkNumber forkNum, BlockNumber blockNum)
bool ConditionalLockBuffer(Buffer buffer)
static bool StartBufferIO(BufferDesc *buf, bool forInput)
BlockNumber RelationGetNumberOfBlocksInFork(Relation relation, ForkNumber forkNum)
void ReleaseBuffer(Buffer buffer)
static void FindAndDropRelationBuffers(RelFileLocator rlocator, ForkNumber forkNum, BlockNumber nForkBlock, BlockNumber firstDelBlock)
XLogRecPtr BufferGetLSNAtomic(Buffer buffer)
bool HoldingBufferPinThatDelaysRecovery(void)
int checkpoint_flush_after
void UnlockReleaseBuffer(Buffer buffer)
static void shared_buffer_write_error_callback(void *arg)
void WritebackContextInit(WritebackContext *context, int *max_pending)
void MarkBufferDirty(Buffer buffer)
void InitBufferPoolAccess(void)
#define BufferIsPinned(bufnum)
double bgwriter_lru_multiplier
static void ReservePrivateRefCountEntry(void)
static BufferDesc * PinCountWaitBuf
void PrintBufferLeakWarning(Buffer buffer)
static int32 GetPrivateRefCount(Buffer buffer)
void LockBufferForCleanup(Buffer buffer)
void LockBuffer(Buffer buffer, int mode)
static PrivateRefCountEntry * ReservedRefCountEntry
void MarkBufferDirtyHint(Buffer buffer, bool buffer_std)
void FlushRelationBuffers(Relation rel)
static void ForgetPrivateRefCountEntry(PrivateRefCountEntry *ref)
Buffer ReadBufferWithoutRelcache(RelFileLocator rlocator, ForkNumber forkNum, BlockNumber blockNum, ReadBufferMode mode, BufferAccessStrategy strategy, bool permanent)
bool ReadRecentBuffer(RelFileLocator rlocator, ForkNumber forkNum, BlockNumber blockNum, Buffer recent_buffer)
#define RELS_BSEARCH_THRESHOLD
int maintenance_io_concurrency
static Buffer ReadBuffer_common(SMgrRelation smgr, char relpersistence, ForkNumber forkNum, BlockNumber blockNum, ReadBufferMode mode, BufferAccessStrategy strategy, bool *hit)
static void UnpinBuffer(BufferDesc *buf)
void FlushDatabaseBuffers(Oid dbid)
static void InvalidateBuffer(BufferDesc *buf)
static void RelationCopyStorageUsingBuffer(RelFileLocator srclocator, RelFileLocator dstlocator, ForkNumber forkNum, bool permanent)
int effective_io_concurrency
static PrivateRefCountEntry * GetPrivateRefCountEntry(Buffer buffer, bool do_move)
struct PrivateRefCountEntry PrivateRefCountEntry
static void FlushBuffer(BufferDesc *buf, SMgrRelation reln)
struct CkptTsStatus CkptTsStatus
Buffer ReadBufferExtended(Relation reln, ForkNumber forkNum, BlockNumber blockNum, ReadBufferMode mode, BufferAccessStrategy strategy)
uint32 LockBufHdr(BufferDesc *desc)
static struct PrivateRefCountEntry PrivateRefCountArray[REFCOUNT_ARRAY_ENTRIES]
static void TerminateBufferIO(BufferDesc *buf, bool clear_dirty, uint32 set_flag_bits)
void IssuePendingWritebacks(WritebackContext *context)
static int SyncOneBuffer(int buf_id, bool skip_recently_used, WritebackContext *wb_context)
Buffer ReadBuffer(Relation reln, BlockNumber blockNum)
static HTAB * PrivateRefCountHash
static int32 PrivateRefCountOverflowed
bool ConditionalLockBufferForCleanup(Buffer buffer)
int bgwriter_lru_maxpages
static void WaitIO(BufferDesc *buf)
void FlushOneBuffer(Buffer buffer)
#define BUFFER_LOCK_UNLOCK
#define BUFFER_LOCK_SHARE
static Page BufferGetPage(Buffer buffer)
#define DEFAULT_EFFECTIVE_IO_CONCURRENCY
#define DEFAULT_MAINTENANCE_IO_CONCURRENCY
#define BUFFER_LOCK_EXCLUSIVE
@ RBM_ZERO_AND_CLEANUP_LOCK
static bool BufferIsValid(Buffer bufnum)
bool PageIsVerifiedExtended(Page page, BlockNumber blkno, int flags)
void PageSetChecksumInplace(Page page, BlockNumber blkno)
char * PageSetChecksumCopy(Page page, BlockNumber blkno)
static bool PageIsNew(Page page)
static void PageSetLSN(Page page, XLogRecPtr lsn)
static XLogRecPtr PageGetLSN(Page page)
#define MemSet(start, val, len)
void CheckpointWriteDelay(int flags, double progress)
void ConditionVariableBroadcast(ConditionVariable *cv)
void ConditionVariablePrepareToSleep(ConditionVariable *cv)
void ConditionVariableSleep(ConditionVariable *cv, uint32 wait_event_info)
void ConditionVariableCancelSleep(void)
static void PGresult const char * p2
static void PGresult * res
elog(ERROR, "%s: %s", p2, msg)
void * hash_search(HTAB *hashp, const void *keyPtr, HASHACTION action, bool *foundPtr)
HTAB * hash_create(const char *tabname, long nelem, const HASHCTL *info, int flags)
void * hash_seq_search(HASH_SEQ_STATUS *status)
void hash_seq_init(HASH_SEQ_STATUS *status, HTAB *hashp)
int errdetail(const char *fmt,...)
ErrorContextCallback * error_context_stack
int errhint(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
int StrategySyncStart(uint32 *complete_passes, uint32 *num_buf_alloc)
BufferAccessStrategy GetAccessStrategy(BufferAccessStrategyType btype)
BufferDesc * StrategyGetBuffer(BufferAccessStrategy strategy, uint32 *buf_state)
bool StrategyRejectBuffer(BufferAccessStrategy strategy, BufferDesc *buf)
void StrategyFreeBuffer(BufferDesc *buf)
volatile sig_atomic_t ProcSignalBarrierPending
#define INSTR_TIME_SET_CURRENT(t)
#define INSTR_TIME_ADD(x, y)
#define INSTR_TIME_SUBTRACT(x, y)
#define INSTR_TIME_GET_MICROSEC(t)
#define INSTR_TIME_SET_ZERO(t)
BufferUsage pgBufferUsage
void on_shmem_exit(pg_on_exit_callback function, Datum arg)
if(TABLE==NULL||TABLE_index==NULL)
Assert(fmt[strlen(fmt) - 1] !='\n')
BufferDesc * LocalBufferAlloc(SMgrRelation smgr, ForkNumber forkNum, BlockNumber blockNum, bool *foundPtr)
void AtEOXact_LocalBuffers(bool isCommit)
void DropRelationLocalBuffers(RelFileLocator rlocator, ForkNumber forkNum, BlockNumber firstDelBlock)
void AtProcExit_LocalBuffers(void)
void MarkLocalBufferDirty(Buffer buffer)
void DropRelationAllLocalBuffers(RelFileLocator rlocator)
PrefetchBufferResult PrefetchLocalBuffer(SMgrRelation smgr, ForkNumber forkNum, BlockNumber blockNum)
bool LWLockHeldByMe(LWLock *lock)
bool LWLockAcquire(LWLock *lock, LWLockMode mode)
bool LWLockHeldByMeInMode(LWLock *lock, LWLockMode mode)
void LWLockRelease(LWLock *lock)
bool LWLockConditionalAcquire(LWLock *lock, LWLockMode mode)
void pfree(void *pointer)
void * repalloc(void *pointer, Size size)
#define VALGRIND_MAKE_MEM_DEFINED(addr, size)
#define VALGRIND_MAKE_MEM_NOACCESS(addr, size)
#define START_CRIT_SECTION()
#define CHECK_FOR_INTERRUPTS()
#define END_CRIT_SECTION()
#define ERRCODE_DATA_CORRUPTED
static PgChecksumMode mode
#define WRITEBACK_MAX_PENDING_FLUSHES
#define DEFAULT_BACKEND_FLUSH_AFTER
#define DEFAULT_CHECKPOINT_FLUSH_AFTER
#define DEFAULT_BGWRITER_FLUSH_AFTER
#define pgstat_count_buffer_read_time(n)
#define pgstat_count_buffer_read(rel)
#define pgstat_count_buffer_write_time(n)
#define pgstat_count_buffer_hit(rel)
PgStat_BgWriterStats PendingBgWriterStats
PgStat_CheckpointerStats PendingCheckpointerStats
void pg_qsort(void *base, size_t nel, size_t elsize, int(*cmp)(const void *, const void *))
static Datum PointerGetDatum(const void *X)
static Pointer DatumGetPointer(Datum X)
#define DELAY_CHKPT_START
void ProcessProcSignalBarrier(void)
@ PROCSIG_RECOVERY_CONFLICT_BUFFERPIN
const char * get_ps_display(int *displen)
bool update_process_title
void set_ps_display(const char *activity)
static SMgrRelation RelationGetSmgr(Relation rel)
#define RelationUsesLocalBuffers(relation)
#define RELATION_IS_OTHER_TEMP(relation)
#define RelationIsValid(relation)
#define RelFileLocatorBackendIsTemp(rlocator)
#define RelFileLocatorEquals(locator1, locator2)
#define relpath(rlocator, forknum)
#define relpathbackend(rlocator, backend, forknum)
#define relpathperm(rlocator, forknum)
void ResourceOwnerForgetBuffer(ResourceOwner owner, Buffer buffer)
ResourceOwner CurrentResourceOwner
void ResourceOwnerEnlargeBuffers(ResourceOwner owner)
void ResourceOwnerRememberBuffer(ResourceOwner owner, Buffer buffer)
void perform_spin_delay(SpinDelayStatus *status)
void finish_spin_delay(SpinDelayStatus *status)
#define init_local_spin_delay(status)
BlockNumber smgrnblocks(SMgrRelation reln, ForkNumber forknum)
void smgrwriteback(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum, BlockNumber nblocks)
void smgrwrite(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum, char *buffer, bool skipFsync)
void smgrextend(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum, char *buffer, bool skipFsync)
bool smgrprefetch(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum)
void smgrcloserellocator(RelFileLocatorBackend rlocator)
void smgrcreate(SMgrRelation reln, ForkNumber forknum, bool isRedo)
BlockNumber smgrnblocks_cached(SMgrRelation reln, ForkNumber forknum)
SMgrRelation smgropen(RelFileLocator rlocator, BackendId backend)
void smgrread(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum, char *buffer)
bool smgrexists(SMgrRelation reln, ForkNumber forknum)
TimestampTz GetOldSnapshotThresholdTimestamp(void)
#define RelationAllowsEarlyPruning(rel)
void ProcSendSignal(int pgprocno)
int GetStartupBufferPinWaitBufId(void)
void SetStartupBufferPinWaitBufId(int bufid)
void ProcWaitForSignal(uint32 wait_event_info)
void ResolveRecoveryConflictWithBufferPin(void)
bool log_recovery_conflict_waits
void LogRecoveryConflict(ProcSignalReason reason, TimestampTz wait_start, TimestampTz now, VirtualTransactionId *wait_list, bool still_waiting)
bool RelFileLocatorSkippingWAL(RelFileLocator rlocator)
SMgrRelation RelationCreateStorage(RelFileLocator rlocator, char relpersistence, bool register_delete)
void log_smgrcreate(const RelFileLocator *rlocator, ForkNumber forkNum)
int wait_backend_pgprocno
int64 shared_blks_dirtied
instr_time blk_write_time
int64 shared_blks_written
struct ErrorContextCallback * previous
void(* callback)(void *arg)