43#ifdef USE_ASSERT_CHECKING
44#include "catalog/pg_tablespace_d.h"
72#define BufHdrGetBlock(bufHdr) ((Block) (BufferBlocks + ((Size) (bufHdr)->buf_id) * BLCKSZ))
73#define BufferGetLSN(bufHdr) (PageGetLSN(BufHdrGetBlock(bufHdr)))
76#define LocalBufHdrGetBlock(bufHdr) \
77 LocalBufferBlockPointers[-((bufHdr)->buf_id + 2)]
80#define BUF_WRITTEN 0x01
81#define BUF_REUSABLE 0x02
83#define RELS_BSEARCH_THRESHOLD 20
91#define BUF_DROP_FULL_SCAN_THRESHOLD (uint64) (NBuffers / 32)
122#define REFCOUNT_ARRAY_ENTRIES 8
271 .
name =
"buffer pin",
352 memset(&victim_entry->
data, 0,
sizeof(victim_entry->
data));
577#define BufferIsPinned(bufnum) \
579 !BufferIsValid(bufnum) ? \
582 BufferIsLocal(bufnum) ? \
583 (LocalRefCount[-(bufnum) - 1] > 0) \
585 (GetPrivateRefCount(bufnum) > 0) \
610 bool skip_if_not_valid);
643#ifdef USE_ASSERT_CHECKING
645 void *unused_context);
757 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
758 errmsg(
"cannot access temporary tables of other sessions")));
793 int b = -recent_buffer - 1;
898 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
899 errmsg(
"cannot access temporary tables of other sessions")));
906 forkNum, blockNum,
mode, strategy);
930 permanent ? RELPERSISTENCE_PERMANENT : RELPERSISTENCE_UNLOGGED,
988 buffers, extended_by);
1069 num_pages, extend_to,
1070 buffers, &extended_by);
1075 for (
uint32 i = 0;
i < extended_by;
i++)
1077 if (first_block +
i != extend_to - 1)
1092 Assert(extended_by == 0);
1094 fork, extend_to - 1,
mode, strategy);
1120 need_to_zero =
false;
1122 else if (isLocalBuf)
1166 else if (!isLocalBuf)
1200 Assert((persistence == RELPERSISTENCE_TEMP ||
1201 persistence == RELPERSISTENCE_PERMANENT ||
1202 persistence == RELPERSISTENCE_UNLOGGED));
1204 if (persistence == RELPERSISTENCE_TEMP)
1215 TRACE_POSTGRESQL_BUFFER_READ_START(forkNum, blockNum,
1221 if (persistence == RELPERSISTENCE_TEMP)
1229 bufHdr =
BufferAlloc(smgr, persistence, forkNum, blockNum,
1230 strategy, foundPtr, io_context);
1251 TRACE_POSTGRESQL_BUFFER_READ_DONE(forkNum, blockNum,
1299 persistence = rel->
rd_rel->relpersistence;
1301 persistence = smgr_persistence;
1309 forkNum, blockNum, strategy, &found);
1322 operation.
smgr = smgr;
1323 operation.
rel = rel;
1342 bool allow_forwarding)
1344 int actual_nblocks = *nblocks;
1348 Assert(*nblocks == 1 || allow_forwarding);
1352 for (
int i = 0;
i < actual_nblocks; ++
i)
1415#ifdef USE_ASSERT_CHECKING
1449 if (
i == 0 && actual_nblocks > 1)
1454 if (
unlikely(maxcombine < actual_nblocks))
1456 elog(
DEBUG2,
"limiting nblocks at %u from %u to %u",
1457 blockNum, actual_nblocks, maxcombine);
1458 actual_nblocks = maxcombine;
1463 *nblocks = actual_nblocks;
1468 operation->
flags = flags;
1469 operation->
nblocks = actual_nblocks;
1505 operation->
nblocks = *nblocks;
1532 did_start_io =
true;
1537 return did_start_io;
1604#ifdef USE_ASSERT_CHECKING
1618 if (i < operation->nblocks_done)
1672 int newly_read_blocks = 0;
1698 Assert(newly_read_blocks > 0);
1713 if (operation->
persistence == RELPERSISTENCE_TEMP)
1736 elog(
ERROR,
"waiting for read operation that didn't read");
1747 int ignored_nblocks_progress;
1842 int flags = operation->
flags;
1848 int io_buffers_len = 0;
1864 if (persistence == RELPERSISTENCE_TEMP)
1947 *nblocks_progress = 1;
1951 did_start_io =
false;
1958 TRACE_POSTGRESQL_BUFFER_READ_DONE(forknum, blocknum + operation->
nblocks_done,
1965 if (persistence == RELPERSISTENCE_TEMP)
1983 Assert(io_buffers[0] == buffers[nblocks_done]);
1993 for (
int i = nblocks_done + 1;
i < operation->
nblocks;
i++)
2000 Assert(io_buffers[io_buffers_len] == buffers[
i]);
2012 persistence == RELPERSISTENCE_TEMP ?
2030 blocknum + nblocks_done,
2031 io_pages, io_buffers_len);
2033 io_start, 1, io_buffers_len * BLCKSZ);
2035 if (persistence == RELPERSISTENCE_TEMP)
2048 *nblocks_progress = io_buffers_len;
2049 did_start_io =
true;
2052 return did_start_io;
2082 LWLock *newPartitionLock;
2083 int existing_buf_id;
2103 if (existing_buf_id >= 0)
2156 if (existing_buf_id >= 0)
2177 valid =
PinBuffer(existing_buf_hdr, strategy,
false);
2194 return existing_buf_hdr;
2200 victim_buf_state =
LockBufHdr(victim_buf_hdr);
2206 victim_buf_hdr->
tag = newTag;
2215 if (relpersistence == RELPERSISTENCE_PERMANENT || forkNum ==
INIT_FORKNUM)
2228 return victim_buf_hdr;
2252 LWLock *oldPartitionLock;
2304 elog(
ERROR,
"buffer is pinned in InvalidateBuffer");
2489 if (strategy != NULL)
2550#ifdef USE_ASSERT_CHECKING
2583 uint32 estimated_pins_held;
2611 if (*additional_pins <= 1)
2615 limit =
Max(limit, 1);
2616 if (limit < *additional_pins)
2617 *additional_pins = limit;
2636 TRACE_POSTGRESQL_BUFFER_EXTEND_START(fork,
2645 extend_by, extend_upto,
2646 buffers, &extend_by);
2649 extend_by, extend_upto,
2650 buffers, &extend_by);
2651 *extended_by = extend_by;
2653 TRACE_POSTGRESQL_BUFFER_EXTEND_DONE(fork,
2702 MemSet(buf_block, 0, BLCKSZ);
2735 uint32 orig_extend_by = extend_by;
2737 if (first_block > extend_upto)
2739 else if ((
uint64) first_block + extend_by > extend_upto)
2740 extend_by = extend_upto - first_block;
2742 for (
uint32 i = extend_by;
i < orig_extend_by;
i++)
2753 *extended_by = extend_by;
2761 (
errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
2762 errmsg(
"cannot extend relation %s beyond %u blocks",
2774 Buffer victim_buf = buffers[
i];
2806 if (existing_id >= 0)
2816 valid =
PinBuffer(existing_hdr, strategy,
false);
2826 (
errmsg(
"unexpected data beyond EOF in block %u of relation \"%s\"",
2856 victim_buf_hdr->
tag = tag;
2898 io_start, 1, extend_by * BLCKSZ);
2912 if (first_block +
i + 1 == extend_upto)
2924 *extended_by = extend_by;
3067 buf_state = old_buf_state;
3163 bool skip_if_not_valid)
3192 buf_state = old_buf_state;
3197 if (strategy == NULL)
3216 result = (buf_state &
BM_VALID) != 0;
3323 int wait_backend_pgprocno =
buf->wait_backend_pgprocno;
3419#define ST_SORT sort_checkpoint_bufferids
3420#define ST_ELEMENT_TYPE CkptSortItem
3421#define ST_COMPARE(a, b) ckpt_buforder_comparator(a, b)
3422#define ST_SCOPE static
3478 for (buf_id = 0; buf_id <
NBuffers; buf_id++)
3489 if ((buf_state & mask) == mask)
3512 if (num_to_scan == 0)
3517 TRACE_POSTGRESQL_BUFFER_SYNC_START(
NBuffers, num_to_scan);
3535 for (
i = 0;
i < num_to_scan;
i++)
3546 if (last_tsid ==
InvalidOid || last_tsid != cur_tsid)
3558 if (per_ts_stat == NULL)
3563 s = &per_ts_stat[num_spaces - 1];
3564 memset(s, 0,
sizeof(*s));
3579 last_tsid = cur_tsid;
3583 s = &per_ts_stat[num_spaces - 1];
3604 for (
i = 0;
i < num_spaces;
i++)
3652 TRACE_POSTGRESQL_BUFFER_SYNC_WRITTEN(buf_id);
3701 TRACE_POSTGRESQL_BUFFER_SYNC_DONE(
NBuffers, num_written, num_to_scan);
3719 int strategy_buf_id;
3727 static bool saved_info_valid =
false;
3728 static int prev_strategy_buf_id;
3729 static uint32 prev_strategy_passes;
3730 static int next_to_clean;
3731 static uint32 next_passes;
3734 static float smoothed_alloc = 0;
3735 static float smoothed_density = 10.0;
3738 float smoothing_samples = 16;
3739 float scan_whole_pool_milliseconds = 120000.0;
3742 long strategy_delta;
3745 float scans_per_alloc;
3746 int reusable_buffers_est;
3747 int upcoming_alloc_est;
3748 int min_scan_buffers;
3753 int reusable_buffers;
3756 long new_strategy_delta;
3775 saved_info_valid =
false;
3787 if (saved_info_valid)
3789 int32 passes_delta = strategy_passes - prev_strategy_passes;
3791 strategy_delta = strategy_buf_id - prev_strategy_buf_id;
3792 strategy_delta += (long) passes_delta *
NBuffers;
3794 Assert(strategy_delta >= 0);
3796 if ((
int32) (next_passes - strategy_passes) > 0)
3799 bufs_to_lap = strategy_buf_id - next_to_clean;
3801 elog(
DEBUG2,
"bgwriter ahead: bgw %u-%u strategy %u-%u delta=%ld lap=%d",
3802 next_passes, next_to_clean,
3803 strategy_passes, strategy_buf_id,
3804 strategy_delta, bufs_to_lap);
3807 else if (next_passes == strategy_passes &&
3808 next_to_clean >= strategy_buf_id)
3811 bufs_to_lap =
NBuffers - (next_to_clean - strategy_buf_id);
3813 elog(
DEBUG2,
"bgwriter ahead: bgw %u-%u strategy %u-%u delta=%ld lap=%d",
3814 next_passes, next_to_clean,
3815 strategy_passes, strategy_buf_id,
3816 strategy_delta, bufs_to_lap);
3826 elog(
DEBUG2,
"bgwriter behind: bgw %u-%u strategy %u-%u delta=%ld",
3827 next_passes, next_to_clean,
3828 strategy_passes, strategy_buf_id,
3831 next_to_clean = strategy_buf_id;
3832 next_passes = strategy_passes;
3843 elog(
DEBUG2,
"bgwriter initializing: strategy %u-%u",
3844 strategy_passes, strategy_buf_id);
3847 next_to_clean = strategy_buf_id;
3848 next_passes = strategy_passes;
3853 prev_strategy_buf_id = strategy_buf_id;
3854 prev_strategy_passes = strategy_passes;
3855 saved_info_valid =
true;
3863 if (strategy_delta > 0 && recent_alloc > 0)
3865 scans_per_alloc = (float) strategy_delta / (
float) recent_alloc;
3866 smoothed_density += (scans_per_alloc - smoothed_density) /
3875 bufs_ahead =
NBuffers - bufs_to_lap;
3876 reusable_buffers_est = (float) bufs_ahead / smoothed_density;
3883 if (smoothed_alloc <= (
float) recent_alloc)
3884 smoothed_alloc = recent_alloc;
3886 smoothed_alloc += ((float) recent_alloc - smoothed_alloc) /
3900 if (upcoming_alloc_est == 0)
3915 if (upcoming_alloc_est < (min_scan_buffers + reusable_buffers_est))
3918 elog(
DEBUG2,
"bgwriter: alloc_est=%d too small, using min=%d + reusable_est=%d",
3919 upcoming_alloc_est, min_scan_buffers, reusable_buffers_est);
3921 upcoming_alloc_est = min_scan_buffers + reusable_buffers_est;
3931 num_to_scan = bufs_to_lap;
3933 reusable_buffers = reusable_buffers_est;
3936 while (num_to_scan > 0 && reusable_buffers < upcoming_alloc_est)
3964 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",
3965 recent_alloc, smoothed_alloc, strategy_delta, bufs_ahead,
3966 smoothed_density, reusable_buffers_est, upcoming_alloc_est,
3967 bufs_to_lap - num_to_scan,
3969 reusable_buffers - reusable_buffers_est);
3980 new_strategy_delta = bufs_to_lap - num_to_scan;
3981 new_recent_alloc = reusable_buffers - reusable_buffers_est;
3982 if (new_strategy_delta > 0 && new_recent_alloc > 0)
3984 scans_per_alloc = (float) new_strategy_delta / (
float) new_recent_alloc;
3985 smoothed_density += (scans_per_alloc - smoothed_density) /
3989 elog(
DEBUG2,
"bgwriter: cleaner density alloc=%u scan=%ld density=%.2f new smoothed=%.2f",
3990 new_recent_alloc, new_strategy_delta,
3991 scans_per_alloc, smoothed_density);
3996 return (bufs_to_lap == 0 && recent_alloc == 0);
4041 else if (skip_recently_used)
4156#ifdef USE_ASSERT_CHECKING
4157 int RefCountErrors = 0;
4192 Assert(RefCountErrors == 0);
4196#ifdef USE_ASSERT_CHECKING
4215AssertBufferLocksPermitCatalogRead(
void)
4222 void *unused_context)
4236 ((
char *) lock - offsetof(
BufferDesc, content_lock));
4286 result =
psprintf(
"[%03d] (rel=%s, blockNum=%u, flags=0x%x, refcount=%u %d)",
4534 if (RELKIND_HAS_TABLE_AM(relation->
rd_rel->relkind))
4546 return (szbytes + (BLCKSZ - 1)) / BLCKSZ;
4548 else if (RELKIND_HAS_STORAGE(relation->
rd_rel->relkind))
4647 uint64 nBlocksToInvalidate = 0;
4683 for (
i = 0;
i < nforks;
i++)
4695 nBlocksToInvalidate += (nForkBlock[
i] - firstDelBlock[
i]);
4705 for (
j = 0;
j < nforks;
j++)
4707 nForkBlock[
j], firstDelBlock[
j]);
4736 for (
j = 0;
j < nforks;
j++)
4766 uint64 nBlocksToInvalidate = 0;
4777 for (
i = 0;
i < nlocators;
i++)
4785 rels[n++] = smgr_reln[
i];
4809 for (
i = 0;
i < n && cached;
i++)
4826 nBlocksToInvalidate += block[
i][
j];
4836 for (
i = 0;
i < n;
i++)
4857 for (
i = 0;
i < n;
i++)
4858 locators[
i] = rels[
i]->smgr_rlocator.locator;
4886 for (
j = 0;
j < n;
j++)
4890 rlocator = &locators[
j];
4900 rlocator = bsearch(&locator,
4906 if (rlocator == NULL)
4936 for (curBlock = firstDelBlock; curBlock < nForkBlock; curBlock++)
4940 LWLock *bufPartitionLock;
5058 errcallback.
arg = bufHdr;
5137 for (
i = 0;
i < nrels;
i++)
5142 srels[
i].
srel = smgrs[
i];
5170 for (
j = 0;
j < nrels;
j++)
5174 srelent = &srels[
j];
5184 srelent = bsearch(&rlocator,
5190 if (srelent == NULL)
5260 memset(
buf.data, 0, BLCKSZ);
5281 permanent ? RELPERSISTENCE_PERMANENT : RELPERSISTENCE_UNLOGGED,
5288 for (blkno = 0; blkno < nblocks; blkno++)
5306 memcpy(dstPage, srcPage, BLCKSZ);
5340 char relpersistence;
5345 relpersistence = permanent ?
5346 RELPERSISTENCE_PERMANENT : RELPERSISTENCE_UNLOGGED;
5560 bool dirtied =
false;
5561 bool delayChkptFlags =
false;
5613 delayChkptFlags =
true;
5646 if (delayChkptFlags)
5751 elog(
ERROR,
"incorrect local pin count: %d",
5757 elog(
ERROR,
"incorrect local pin count: %d",
5784 bool logged_recovery_conflict =
false;
5824 if (logged_recovery_conflict)
5842 elog(
ERROR,
"multiple backends attempting to wait for pincount 1");
5869 if (waitStart != 0 && !logged_recovery_conflict)
5877 waitStart,
now, NULL,
true);
5878 logged_recovery_conflict =
true;
6200 bool forget_owner,
bool release_aio)
6203 uint32 unset_flag_bits = 0;
6204 int refcount_change = 0;
6221 refcount_change = -1;
6226 set_flag_bits, unset_flag_bits,
6285 errmsg(
"could not write block %u of %s",
6289 errdetail(
"Multiple failures --- write error might be permanent.")));
6306 errcontext(
"writing block %u of relation \"%s\"",
6321 errcontext(
"writing block %u of relation \"%s\"",
6450 if (
a->tsId <
b->tsId)
6452 else if (
a->tsId >
b->tsId)
6455 if (
a->relNumber <
b->relNumber)
6457 else if (
a->relNumber >
b->relNumber)
6460 else if (
a->forkNum <
b->forkNum)
6462 else if (
a->forkNum >
b->forkNum)
6465 else if (
a->blockNum <
b->blockNum)
6467 else if (
a->blockNum >
b->blockNum)
6536 pending->
tag = *tag;
6548#define ST_SORT sort_pending_writebacks
6549#define ST_ELEMENT_TYPE PendingWriteback
6550#define ST_COMPARE(a, b) buffertag_comparator(&a->tag, &b->tag)
6551#define ST_SCOPE static
6603 for (ahead = 0;
i + ahead + 1 < wb_context->
nr_pending; ahead++)
6615 if (
cur->tag.blockNum ==
next->tag.blockNum)
6619 if (
cur->tag.blockNum + 1 !=
next->tag.blockNum)
6692 *buffer_flushed =
false;
6716 *buffer_flushed =
true;
6779 int32 *buffers_skipped)
6781 *buffers_evicted = 0;
6782 *buffers_skipped = 0;
6783 *buffers_flushed = 0;
6789 bool buffer_flushed;
6803 (*buffers_evicted)++;
6805 (*buffers_skipped)++;
6808 (*buffers_flushed)++;
6829 int32 *buffers_flushed,
int32 *buffers_skipped)
6833 *buffers_skipped = 0;
6834 *buffers_evicted = 0;
6835 *buffers_flushed = 0;
6841 bool buffer_flushed;
6865 (*buffers_evicted)++;
6867 (*buffers_skipped)++;
6870 (*buffers_flushed)++;
6880 bool *buffer_already_dirty)
6883 bool result =
false;
6885 *buffer_already_dirty =
false;
6915 *buffer_already_dirty =
true;
6938 bool buffer_dirtied =
false;
6951 Assert(!(buffer_dirtied && *buffer_already_dirty));
6953 return buffer_dirtied;
6972 int32 *buffers_dirtied,
6973 int32 *buffers_already_dirty,
6974 int32 *buffers_skipped)
6978 *buffers_dirtied = 0;
6979 *buffers_already_dirty = 0;
6980 *buffers_skipped = 0;
6986 bool buffer_already_dirty;
7010 (*buffers_dirtied)++;
7011 else if (buffer_already_dirty)
7012 (*buffers_already_dirty)++;
7014 (*buffers_skipped)++;
7029 int32 *buffers_already_dirty,
7030 int32 *buffers_skipped)
7032 *buffers_dirtied = 0;
7033 *buffers_already_dirty = 0;
7034 *buffers_skipped = 0;
7040 bool buffer_already_dirty;
7054 (*buffers_dirtied)++;
7055 else if (buffer_already_dirty)
7056 (*buffers_already_dirty)++;
7058 (*buffers_skipped)++;
7080 uint8 handle_data_len;
7089 for (
int i = 0;
i < handle_data_len;
i++)
7105 first = buf_hdr->
tag;
7161 if (is_write && !is_temp)
7191 uint8 *zeroed_or_error_count,
7192 uint8 *checkfail_count,
7198#define READV_COUNT_BITS 7
7199#define READV_COUNT_MASK ((1 << READV_COUNT_BITS) - 1)
7201 *zeroed_any = rem_error & 1;
7204 *ignored_any = rem_error & 1;
7236 uint8 checkfail_count,
7237 uint8 first_error_off,
7238 uint8 first_zeroed_off,
7239 uint8 first_ignored_off)
7243 uint8 zeroed_or_error_count =
7244 error_count > 0 ? error_count : zeroed_count;
7248 "PG_IOV_MAX is bigger than reserved space for error data");
7250 "PGAIO_RESULT_ERROR_BITS is insufficient for buffer_readv");
7257 if (error_count > 0)
7258 first_off = first_error_off;
7259 else if (zeroed_count > 0)
7260 first_off = first_zeroed_off;
7262 first_off = first_ignored_off;
7264 Assert(!zeroed_any || error_count == 0);
7286 if (error_count > 0)
7295#ifdef USE_ASSERT_CHECKING
7299 uint8 zeroed_or_error_count_2,
7304 &zeroed_any_2, &ignored_any_2,
7305 &zeroed_or_error_count_2,
7308 Assert(zeroed_any == zeroed_any_2);
7309 Assert(ignored_any == ignored_any_2);
7310 Assert(zeroed_or_error_count == zeroed_or_error_count_2);
7311 Assert(checkfail_count == checkfail_count_2);
7312 Assert(first_off == first_off_2);
7316#undef READV_COUNT_BITS
7317#undef READV_COUNT_MASK
7326 uint8 flags,
bool failed,
bool is_temp,
7327 bool *buffer_invalid,
7328 bool *failed_checksum,
7329 bool *ignored_checksum,
7330 bool *zeroed_buffer)
7341#ifdef USE_ASSERT_CHECKING
7354 *buffer_invalid =
false;
7355 *failed_checksum =
false;
7356 *ignored_checksum =
false;
7357 *zeroed_buffer =
false;
7391 memset(bufdata, 0, BLCKSZ);
7392 *zeroed_buffer =
true;
7396 *buffer_invalid =
true;
7401 else if (*failed_checksum)
7402 *ignored_checksum =
true;
7424 if (*buffer_invalid || *failed_checksum || *zeroed_buffer)
7432 *zeroed_buffer ? 1 : 0,
7433 *failed_checksum ? 1 : 0,
7434 buf_off, buf_off, buf_off);
7453 TRACE_POSTGRESQL_BUFFER_READ_DONE(tag.
forkNum,
7470 uint8 cb_data,
bool is_temp)
7474 uint8 first_error_off = 0;
7475 uint8 first_zeroed_off = 0;
7476 uint8 first_ignored_off = 0;
7477 uint8 error_count = 0;
7478 uint8 zeroed_count = 0;
7479 uint8 ignored_count = 0;
7480 uint8 checkfail_count = 0;
7482 uint8 handle_data_len;
7497 for (
uint8 buf_off = 0; buf_off < handle_data_len; buf_off++)
7501 bool failed_verification =
false;
7502 bool failed_checksum =
false;
7503 bool zeroed_buffer =
false;
7504 bool ignored_checksum =
false;
7515 || prior_result.
result <= buf_off;
7518 &failed_verification,
7528 if (failed_verification && !zeroed_buffer && error_count++ == 0)
7529 first_error_off = buf_off;
7530 if (zeroed_buffer && zeroed_count++ == 0)
7531 first_zeroed_off = buf_off;
7532 if (ignored_checksum && ignored_count++ == 0)
7533 first_ignored_off = buf_off;
7534 if (failed_checksum)
7543 (error_count > 0 || ignored_count > 0 || zeroed_count > 0))
7546 zeroed_count > 0, ignored_count > 0,
7547 error_count, zeroed_count, checkfail_count,
7548 first_error_off, first_zeroed_off,
7557 if (is_temp && checkfail_count > 0)
7584 uint8 zeroed_or_error_count,
7587 uint8 affected_count;
7588 const char *msg_one,
7594 &zeroed_or_error_count,
7603 if (zeroed_any && ignored_any)
7605 Assert(zeroed_any && ignored_any);
7608 affected_count = zeroed_or_error_count;
7612 errmsg(
"zeroing %u page(s) and ignoring %u checksum failure(s) among blocks %u..%u of relation \"%s\"",
7613 affected_count, checkfail_count, first, last, rpath.
str),
7614 affected_count > 1 ?
7615 errdetail(
"Block %u held the first zeroed page.",
7616 first + first_off) : 0,
7617 errhint_plural(
"See server log for details about the other %d invalid block.",
7618 "See server log for details about the other %d invalid blocks.",
7619 affected_count + checkfail_count - 1,
7620 affected_count + checkfail_count - 1));
7632 affected_count = zeroed_or_error_count;
7633 msg_one =
_(
"invalid page in block %u of relation \"%s\"");
7634 msg_mult =
_(
"%u invalid pages among blocks %u..%u of relation \"%s\"");
7635 det_mult =
_(
"Block %u held the first invalid page.");
7636 hint_mult =
_(
"See server log for the other %u invalid block(s).");
7638 else if (zeroed_any && !ignored_any)
7640 affected_count = zeroed_or_error_count;
7641 msg_one =
_(
"invalid page in block %u of relation \"%s\"; zeroing out page");
7642 msg_mult =
_(
"zeroing out %u invalid pages among blocks %u..%u of relation \"%s\"");
7643 det_mult =
_(
"Block %u held the first zeroed page.");
7644 hint_mult =
_(
"See server log for the other %u zeroed block(s).");
7646 else if (!zeroed_any && ignored_any)
7648 affected_count = checkfail_count;
7649 msg_one =
_(
"ignoring checksum failure in block %u of relation \"%s\"");
7650 msg_mult =
_(
"ignoring %u checksum failures among blocks %u..%u of relation \"%s\"");
7651 det_mult =
_(
"Block %u held the first ignored page.");
7652 hint_mult =
_(
"See server log for the other %u ignored block(s).");
7659 affected_count == 1 ?
7692 uint8 zeroed_or_error_count,
7697 return prior_result;
7702 &zeroed_or_error_count,
7706 if (checkfail_count)
7714 return prior_result;
bool pgaio_wref_valid(PgAioWaitRef *iow)
PgAioHandle * pgaio_io_acquire(struct ResourceOwnerData *resowner, PgAioReturn *ret)
void pgaio_wref_clear(PgAioWaitRef *iow)
void pgaio_io_get_wref(PgAioHandle *ioh, PgAioWaitRef *iow)
void pgaio_io_set_flag(PgAioHandle *ioh, PgAioHandleFlags flag)
bool pgaio_have_staged(void)
bool pgaio_wref_check_done(PgAioWaitRef *iow)
ProcNumber pgaio_io_get_owner(PgAioHandle *ioh)
void pgaio_submit_staged(void)
void pgaio_wref_wait(PgAioWaitRef *iow)
void pgaio_io_release(PgAioHandle *ioh)
PgAioHandle * pgaio_io_acquire_nb(struct ResourceOwnerData *resowner, PgAioReturn *ret)
@ PGAIO_HCB_LOCAL_BUFFER_READV
@ PGAIO_HCB_SHARED_BUFFER_READV
@ PGAIO_HF_REFERENCES_LOCAL
void pgaio_io_set_handle_data_32(PgAioHandle *ioh, uint32 *data, uint8 len)
void pgaio_io_register_callbacks(PgAioHandle *ioh, PgAioHandleCallbackID cb_id, uint8 cb_data)
uint64 * pgaio_io_get_handle_data(PgAioHandle *ioh, uint8 *len)
void pgaio_result_report(PgAioResult result, const PgAioTargetData *target_data, int elevel)
PgAioTargetData * pgaio_io_get_target_data(PgAioHandle *ioh)
#define PGAIO_RESULT_ERROR_BITS
static uint32 pg_atomic_fetch_and_u32(volatile pg_atomic_uint32 *ptr, uint32 and_)
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 uint32 pg_atomic_fetch_sub_u32(volatile pg_atomic_uint32 *ptr, int32 sub_)
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_replace_first(binaryheap *heap, bh_node_type d)
bh_node_type binaryheap_first(binaryheap *heap)
bh_node_type binaryheap_remove_first(binaryheap *heap)
void binaryheap_free(binaryheap *heap)
void binaryheap_add_unordered(binaryheap *heap, bh_node_type d)
binaryheap * binaryheap_allocate(int capacity, binaryheap_comparator compare, void *arg)
#define binaryheap_empty(h)
#define InvalidBlockNumber
static bool BlockNumberIsValid(BlockNumber blockNumber)
#define BufferIsLocal(buffer)
CkptSortItem * CkptBufferIds
WritebackContext BackendWritebackContext
BufferDescPadded * BufferDescriptors
#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 ConditionVariable * BufferDescriptorGetIOCV(const BufferDesc *bdesc)
static bool BufferTagsEqual(const BufferTag *tag1, const BufferTag *tag2)
static RelFileNumber BufTagGetRelNumber(const BufferTag *tag)
static LWLock * BufferDescriptorGetContentLock(const BufferDesc *bdesc)
static void UnlockBufHdr(BufferDesc *desc)
static bool BufTagMatchesRelFileLocator(const BufferTag *tag, const RelFileLocator *rlocator)
#define BM_PIN_COUNT_WAITER
static uint32 UnlockBufHdrExt(BufferDesc *desc, uint32 old_buf_state, uint32 set_bits, uint32 unset_bits, int refcount_change)
static void ResourceOwnerRememberBufferIO(ResourceOwner owner, Buffer buffer)
#define BUF_STATE_GET_USAGECOUNT(state)
static void ResourceOwnerForgetBufferIO(ResourceOwner owner, Buffer buffer)
#define BM_IO_IN_PROGRESS
static void ClearBufferTag(BufferTag *tag)
static void ResourceOwnerRememberBuffer(ResourceOwner owner, Buffer buffer)
static void ResourceOwnerForgetBuffer(ResourceOwner owner, Buffer buffer)
#define BUF_USAGECOUNT_ONE
#define BUF_STATE_GET_REFCOUNT(state)
static LWLock * BufMappingPartitionLock(uint32 hashcode)
static RelFileLocator BufTagGetRelFileLocator(const BufferTag *tag)
static BufferDesc * GetLocalBufferDescriptor(uint32 id)
static BufferDesc * GetBufferDescriptor(uint32 id)
static Buffer BufferDescriptorGetBuffer(const BufferDesc *bdesc)
#define BM_CHECKPOINT_NEEDED
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 CheckBufferIsPinnedOnce(Buffer buffer)
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)
static pg_attribute_always_inline PgAioResult buffer_readv_complete(PgAioHandle *ioh, PgAioResult prior_result, uint8 cb_data, bool is_temp)
const ResourceOwnerDesc buffer_pin_resowner_desc
BlockNumber BufferGetBlockNumber(Buffer buffer)
static PrivateRefCountEntry * NewPrivateRefCountEntry(Buffer buffer)
static Buffer PrivateRefCountArrayKeys[REFCOUNT_ARRAY_ENTRIES]
static bool ReadBuffersCanStartIO(Buffer buffer, bool nowait)
void DropRelationBuffers(SMgrRelation smgr_reln, ForkNumber *forkNum, int nforks, BlockNumber *firstDelBlock)
Buffer ReleaseAndReadBuffer(Buffer buffer, Relation relation, BlockNumber blockNum)
static int ReservedRefCountSlot
static PgAioResult shared_buffer_readv_complete_local(PgAioHandle *ioh, PgAioResult prior_result, uint8 cb_data)
static pg_attribute_always_inline bool StartReadBuffersImpl(ReadBuffersOperation *operation, Buffer *buffers, BlockNumber blockNum, int *nblocks, int flags, bool allow_forwarding)
static void CheckReadBuffersOperation(ReadBuffersOperation *operation, bool is_complete)
PrefetchBufferResult PrefetchBuffer(Relation reln, ForkNumber forkNum, BlockNumber blockNum)
static uint32 PrivateRefCountClock
static void FlushBuffer(BufferDesc *buf, SMgrRelation reln, IOObject io_object, IOContext io_context)
static void ResOwnerReleaseBufferIO(Datum res)
static PgAioResult local_buffer_readv_complete(PgAioHandle *ioh, PgAioResult prior_result, uint8 cb_data)
bool StartReadBuffers(ReadBuffersOperation *operation, Buffer *buffers, BlockNumber blockNum, int *nblocks, int flags)
void EvictAllUnpinnedBuffers(int32 *buffers_evicted, int32 *buffers_flushed, int32 *buffers_skipped)
static void FlushUnlockedBuffer(BufferDesc *buf, SMgrRelation reln, IOObject io_object, IOContext io_context)
const ResourceOwnerDesc buffer_io_resowner_desc
#define BUF_DROP_FULL_SCAN_THRESHOLD
void LockBuffer(Buffer buffer, BufferLockMode mode)
static void PinBuffer_Locked(BufferDesc *buf)
void EvictRelUnpinnedBuffers(Relation rel, int32 *buffers_evicted, int32 *buffers_flushed, int32 *buffers_skipped)
static pg_attribute_always_inline void buffer_readv_complete_one(PgAioTargetData *td, uint8 buf_off, Buffer buffer, uint8 flags, bool failed, bool is_temp, bool *buffer_invalid, bool *failed_checksum, bool *ignored_checksum, bool *zeroed_buffer)
static int buffertag_comparator(const BufferTag *ba, const BufferTag *bb)
bool IsBufferCleanupOK(Buffer buffer)
#define BufferGetLSN(bufHdr)
static char * ResOwnerPrintBufferIO(Datum res)
bool BufferIsLockedByMeInMode(Buffer buffer, BufferLockMode mode)
Buffer ExtendBufferedRel(BufferManagerRelation bmr, ForkNumber forkNum, BufferAccessStrategy strategy, uint32 flags)
void AtEOXact_Buffers(bool isCommit)
static void AbortBufferIO(Buffer buffer)
const PgAioHandleCallbacks aio_shared_buffer_readv_cb
BlockNumber ExtendBufferedRelBy(BufferManagerRelation bmr, ForkNumber fork, BufferAccessStrategy strategy, uint32 flags, uint32 extend_by, Buffer *buffers, uint32 *extended_by)
static Buffer ReadBuffer_common(Relation rel, SMgrRelation smgr, char smgr_persistence, ForkNumber forkNum, BlockNumber blockNum, ReadBufferMode mode, BufferAccessStrategy strategy)
struct PrivateRefCountData PrivateRefCountData
static void ProcessReadBuffersResult(ReadBuffersOperation *operation)
static void ZeroAndLockBuffer(Buffer buffer, ReadBufferMode mode, bool already_valid)
static BufferDesc * BufferAlloc(SMgrRelation smgr, char relpersistence, ForkNumber forkNum, BlockNumber blockNum, BufferAccessStrategy strategy, bool *foundPtr, IOContext io_context)
static void CheckForBufferLeaks(void)
static bool ReadBuffersCanStartIOOnce(Buffer buffer, bool nowait)
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)
Buffer ExtendBufferedRelTo(BufferManagerRelation bmr, ForkNumber fork, BufferAccessStrategy strategy, uint32 flags, BlockNumber extend_to, ReadBufferMode mode)
struct SMgrSortArray SMgrSortArray
const PgAioHandleCallbacks aio_local_buffer_readv_cb
static bool InvalidateVictimBuffer(BufferDesc *buf_hdr)
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)
static pg_attribute_always_inline void buffer_stage_common(PgAioHandle *ioh, bool is_write, bool is_temp)
static void local_buffer_write_error_callback(void *arg)
static void BufferSync(int flags)
static bool AsyncReadBuffers(ReadBuffersOperation *operation, int *nblocks_progress)
static void local_buffer_readv_stage(PgAioHandle *ioh, uint8 cb_data)
char * DebugPrintBufferRefcount(Buffer buffer)
static char * ResOwnerPrintBufferPin(Datum res)
void CheckPointBuffers(int flags)
bool BufferIsDirty(Buffer buffer)
static uint32 MaxProportionalPins
static BlockNumber ExtendBufferedRelShared(BufferManagerRelation bmr, ForkNumber fork, BufferAccessStrategy strategy, uint32 flags, uint32 extend_by, BlockNumber extend_upto, Buffer *buffers, uint32 *extended_by)
bool BgBufferSync(WritebackContext *wb_context)
static void WakePinCountWaiter(BufferDesc *buf)
bool BufferIsPermanent(Buffer buffer)
void MarkDirtyAllUnpinnedBuffers(int32 *buffers_dirtied, int32 *buffers_already_dirty, int32 *buffers_skipped)
#define REFCOUNT_ARRAY_ENTRIES
static void shared_buffer_readv_stage(PgAioHandle *ioh, uint8 cb_data)
PrefetchBufferResult PrefetchSharedBuffer(SMgrRelation smgr_reln, ForkNumber forkNum, BlockNumber blockNum)
static PgAioResult shared_buffer_readv_complete(PgAioHandle *ioh, PgAioResult prior_result, uint8 cb_data)
static Buffer GetVictimBuffer(BufferAccessStrategy strategy, IOContext io_context)
bool ConditionalLockBuffer(Buffer buffer)
BlockNumber RelationGetNumberOfBlocksInFork(Relation relation, ForkNumber forkNum)
void ReleaseBuffer(Buffer buffer)
pg_noinline uint32 WaitBufHdrUnlocked(BufferDesc *buf)
bool BufferIsLockedByMe(Buffer buffer)
static bool PinBuffer(BufferDesc *buf, BufferAccessStrategy strategy, bool skip_if_not_valid)
static void FindAndDropRelationBuffers(RelFileLocator rlocator, ForkNumber forkNum, BlockNumber nForkBlock, BlockNumber firstDelBlock)
XLogRecPtr BufferGetLSNAtomic(Buffer buffer)
bool HoldingBufferPinThatDelaysRecovery(void)
bool MarkDirtyUnpinnedBuffer(Buffer buf, bool *buffer_already_dirty)
int checkpoint_flush_after
void UnlockReleaseBuffer(Buffer buffer)
static pg_attribute_always_inline Buffer PinBufferForBlock(Relation rel, SMgrRelation smgr, char persistence, ForkNumber forkNum, BlockNumber blockNum, BufferAccessStrategy strategy, bool *foundPtr)
void TerminateBufferIO(BufferDesc *buf, bool clear_dirty, uint32 set_flag_bits, bool forget_owner, bool release_aio)
static void UnpinBufferNoOwner(BufferDesc *buf)
static void shared_buffer_write_error_callback(void *arg)
void ScheduleBufferTagForWriteback(WritebackContext *wb_context, IOContext io_context, BufferTag *tag)
void WaitReadBuffers(ReadBuffersOperation *operation)
void WritebackContextInit(WritebackContext *context, int *max_pending)
void MarkBufferDirty(Buffer buffer)
#define BufferIsPinned(bufnum)
double bgwriter_lru_multiplier
static bool EvictUnpinnedBufferInternal(BufferDesc *desc, bool *buffer_flushed)
void LimitAdditionalPins(uint32 *additional_pins)
static void buffer_readv_report(PgAioResult result, const PgAioTargetData *td, int elevel)
static void ReservePrivateRefCountEntry(void)
static BufferDesc * PinCountWaitBuf
static pg_noinline PrivateRefCountEntry * GetPrivateRefCountEntrySlow(Buffer buffer, bool do_move)
static int32 GetPrivateRefCount(Buffer buffer)
static BlockNumber ExtendBufferedRelCommon(BufferManagerRelation bmr, ForkNumber fork, BufferAccessStrategy strategy, uint32 flags, uint32 extend_by, BlockNumber extend_upto, Buffer *buffers, uint32 *extended_by)
void LockBufferForCleanup(Buffer buffer)
void MarkBufferDirtyHint(Buffer buffer, bool buffer_std)
void FlushRelationBuffers(Relation rel)
void IssuePendingWritebacks(WritebackContext *wb_context, IOContext io_context)
static void ForgetPrivateRefCountEntry(PrivateRefCountEntry *ref)
bool EvictUnpinnedBuffer(Buffer buf, bool *buffer_flushed)
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 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)
bool StartBufferIO(BufferDesc *buf, bool forInput, bool nowait)
struct PrivateRefCountEntry PrivateRefCountEntry
void MarkDirtyRelUnpinnedBuffers(Relation rel, int32 *buffers_dirtied, int32 *buffers_already_dirty, int32 *buffers_skipped)
struct CkptTsStatus CkptTsStatus
bool StartReadBuffer(ReadBuffersOperation *operation, Buffer *buffer, BlockNumber blocknum, int flags)
Buffer ReadBufferExtended(Relation reln, ForkNumber forkNum, BlockNumber blockNum, ReadBufferMode mode, BufferAccessStrategy strategy)
static bool MarkDirtyUnpinnedBufferInternal(Buffer buf, BufferDesc *desc, bool *buffer_already_dirty)
uint32 LockBufHdr(BufferDesc *desc)
static void ResOwnerReleaseBufferPin(Datum res)
static struct PrivateRefCountEntry PrivateRefCountArray[REFCOUNT_ARRAY_ENTRIES]
static void buffer_readv_decode_error(PgAioResult result, bool *zeroed_any, bool *ignored_any, uint8 *zeroed_or_error_count, uint8 *checkfail_count, uint8 *first_off)
static int PrivateRefCountEntryLast
void InitBufferManagerAccess(void)
static void buffer_readv_encode_error(PgAioResult *result, bool is_temp, bool zeroed_any, bool ignored_any, uint8 error_count, uint8 zeroed_count, uint8 checkfail_count, uint8 first_error_off, uint8 first_zeroed_off, uint8 first_ignored_off)
static int SyncOneBuffer(int buf_id, bool skip_recently_used, WritebackContext *wb_context)
uint32 GetAdditionalPinLimit(void)
Buffer ReadBuffer(Relation reln, BlockNumber blockNum)
void TrackNewBufferPin(Buffer buf)
static HTAB * PrivateRefCountHash
static int32 PrivateRefCountOverflowed
bool ConditionalLockBufferForCleanup(Buffer buffer)
int bgwriter_lru_maxpages
static void WaitIO(BufferDesc *buf)
void FlushOneBuffer(Buffer buffer)
#define READ_BUFFERS_ZERO_ON_ERROR
static Page BufferGetPage(Buffer buffer)
#define DEFAULT_IO_COMBINE_LIMIT
static Block BufferGetBlock(Buffer buffer)
#define READ_BUFFERS_ISSUE_ADVICE
#define MAX_IO_COMBINE_LIMIT
#define DEFAULT_EFFECTIVE_IO_CONCURRENCY
#define READ_BUFFERS_IGNORE_CHECKSUM_FAILURES
#define DEFAULT_MAINTENANCE_IO_CONCURRENCY
#define BMR_GET_SMGR(bmr)
@ EB_CREATE_FORK_IF_NEEDED
#define READ_BUFFERS_SYNCHRONOUSLY
@ RBM_ZERO_AND_CLEANUP_LOCK
static bool BufferIsValid(Buffer bufnum)
bool ignore_checksum_failure
char * PageSetChecksumCopy(Page page, BlockNumber blkno)
bool PageIsVerified(PageData *page, BlockNumber blkno, int flags, bool *checksum_failure_p)
static bool PageIsNew(const PageData *page)
static void PageSetLSN(Page page, XLogRecPtr lsn)
static XLogRecPtr PageGetLSN(const PageData *page)
#define PIV_IGNORE_CHECKSUM_FAILURE
#define PG_USED_FOR_ASSERTS_ONLY
#define pg_attribute_always_inline
#define MemSet(start, val, len)
#define StaticAssertDecl(condition, errmessage)
bool IsCatalogRelationOid(Oid relid)
bool IsCatalogTextUniqueIndexOid(Oid relid)
void CheckpointWriteDelay(int flags, double progress)
bool ConditionVariableCancelSleep(void)
void ConditionVariableBroadcast(ConditionVariable *cv)
void ConditionVariablePrepareToSleep(ConditionVariable *cv)
void ConditionVariableSleep(ConditionVariable *cv, uint32 wait_event_info)
void * hash_search(HTAB *hashp, const void *keyPtr, HASHACTION action, bool *foundPtr)
HTAB * hash_create(const char *tabname, int64 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 errmsg_internal(const char *fmt,...)
int errdetail_internal(const char *fmt,...)
int errdetail(const char *fmt,...)
ErrorContextCallback * error_context_stack
int errhint_internal(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
int errhint_plural(const char *fmt_singular, const char *fmt_plural, unsigned long n,...)
#define ereport(elevel,...)
#define palloc_array(type, count)
int StrategySyncStart(uint32 *complete_passes, uint32 *num_buf_alloc)
BufferAccessStrategy GetAccessStrategy(BufferAccessStrategyType btype)
void FreeAccessStrategy(BufferAccessStrategy strategy)
IOContext IOContextForStrategy(BufferAccessStrategy strategy)
BufferDesc * StrategyGetBuffer(BufferAccessStrategy strategy, uint32 *buf_state, bool *from_ring)
bool StrategyRejectBuffer(BufferAccessStrategy strategy, BufferDesc *buf, bool from_ring)
volatile sig_atomic_t ProcSignalBarrierPending
Assert(PointerIsAligned(start, uint64))
BufferUsage pgBufferUsage
void on_shmem_exit(pg_on_exit_callback function, Datum arg)
if(TABLE==NULL||TABLE_index==NULL)
void LockRelationForExtension(Relation relation, LOCKMODE lockmode)
void UnlockRelationForExtension(Relation relation, LOCKMODE lockmode)
void FlushLocalBuffer(BufferDesc *bufHdr, SMgrRelation reln)
void UnpinLocalBuffer(Buffer buffer)
bool StartLocalBufferIO(BufferDesc *bufHdr, bool forInput, bool nowait)
void AtEOXact_LocalBuffers(bool isCommit)
void AtProcExit_LocalBuffers(void)
bool PinLocalBuffer(BufferDesc *buf_hdr, bool adjust_usagecount)
void MarkLocalBufferDirty(Buffer buffer)
void DropRelationAllLocalBuffers(RelFileLocator rlocator)
void TerminateLocalBufferIO(BufferDesc *bufHdr, bool clear_dirty, uint32 set_flag_bits, bool release_aio)
PrefetchBufferResult PrefetchLocalBuffer(SMgrRelation smgr, ForkNumber forkNum, BlockNumber blockNum)
BlockNumber ExtendBufferedRelLocal(BufferManagerRelation bmr, ForkNumber fork, uint32 flags, uint32 extend_by, BlockNumber extend_upto, Buffer *buffers, uint32 *extended_by)
void UnpinLocalBufferNoOwner(Buffer buffer)
void DropRelationLocalBuffers(RelFileLocator rlocator, ForkNumber *forkNum, int nforks, BlockNumber *firstDelBlock)
BufferDesc * LocalBufferAlloc(SMgrRelation smgr, ForkNumber forkNum, BlockNumber blockNum, bool *foundPtr)
bool LWLockHeldByMe(LWLock *lock)
bool LWLockAcquire(LWLock *lock, LWLockMode mode)
void LWLockDisown(LWLock *lock)
bool LWLockHeldByMeInMode(LWLock *lock, LWLockMode mode)
void LWLockRelease(LWLock *lock)
bool LWLockConditionalAcquire(LWLock *lock, LWLockMode mode)
void ForEachLWLockHeldByMe(void(*callback)(LWLock *, LWLockMode, void *), void *context)
void * repalloc(void *pointer, Size size)
void pfree(void *pointer)
#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
static int64 current_size
#define WRITEBACK_MAX_PENDING_FLUSHES
#define DEFAULT_BACKEND_FLUSH_AFTER
#define DEFAULT_CHECKPOINT_FLUSH_AFTER
#define DEFAULT_BGWRITER_FLUSH_AFTER
static char buf[DEFAULT_XLOG_SEG_SIZE]
#define pgstat_count_buffer_read(rel)
#define pgstat_count_buffer_hit(rel)
PgStat_BgWriterStats PendingBgWriterStats
PgStat_CheckpointerStats PendingCheckpointerStats
void pgstat_prepare_report_checksum_failure(Oid dboid)
void pgstat_report_checksum_failures_in_db(Oid dboid, int failurecount)
instr_time pgstat_prepare_io_time(bool track_io_guc)
void pgstat_count_io_op(IOObject io_object, IOContext io_context, IOOp io_op, uint32 cnt, uint64 bytes)
void pgstat_count_io_op_time(IOObject io_object, IOContext io_context, IOOp io_op, instr_time start_time, uint32 cnt, uint64 bytes)
#define qsort(a, b, c, d)
static Datum PointerGetDatum(const void *X)
static Pointer DatumGetPointer(Datum X)
static int32 DatumGetInt32(Datum X)
#define NUM_AUXILIARY_PROCS
#define DELAY_CHKPT_START
#define INVALID_PROC_NUMBER
void ProcessProcSignalBarrier(void)
@ PROCSIG_RECOVERY_CONFLICT_BUFFERPIN
void set_ps_display_remove_suffix(void)
void set_ps_display_suffix(const char *suffix)
char * psprintf(const char *fmt,...)
ReadStream * read_stream_begin_smgr_relation(int flags, BufferAccessStrategy strategy, SMgrRelation smgr, char smgr_persistence, ForkNumber forknum, ReadStreamBlockNumberCB callback, void *callback_private_data, size_t per_buffer_data_size)
Buffer read_stream_next_buffer(ReadStream *stream, void **per_buffer_data)
void read_stream_end(ReadStream *stream)
BlockNumber block_range_read_stream_cb(ReadStream *stream, void *callback_private_data, void *per_buffer_data)
#define READ_STREAM_USE_BATCHING
static unsigned hash(unsigned *uv, int n)
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)
ResourceOwner CurrentResourceOwner
void ResourceOwnerEnlarge(ResourceOwner owner)
#define RELEASE_PRIO_BUFFER_IOS
@ RESOURCE_RELEASE_BEFORE_LOCKS
#define RELEASE_PRIO_BUFFER_PINS
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 smgrstartreadv(PgAioHandle *ioh, SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum, void **buffers, BlockNumber nblocks)
void smgrwriteback(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum, BlockNumber nblocks)
SMgrRelation smgropen(RelFileLocator rlocator, ProcNumber backend)
void smgrcreate(SMgrRelation reln, ForkNumber forknum, bool isRedo)
BlockNumber smgrnblocks_cached(SMgrRelation reln, ForkNumber forknum)
uint32 smgrmaxcombine(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum)
void smgrzeroextend(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum, int nblocks, bool skipFsync)
void smgrextend(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum, const void *buffer, bool skipFsync)
bool smgrexists(SMgrRelation reln, ForkNumber forknum)
bool smgrprefetch(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum, int nblocks)
static void smgrwrite(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum, const void *buffer, bool skipFsync)
void ProcSendSignal(ProcNumber procNumber)
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)
BlockNumber last_exclusive
BlockNumber current_blocknum
int wait_backend_pgprocno
int64 shared_blks_dirtied
int64 shared_blks_written
struct ErrorContextCallback * previous
void(* callback)(void *arg)
PgAioHandleCallbackStage stage
PgAioTargetData target_data
PgStat_Counter buf_written_clean
PgStat_Counter maxwritten_clean
PgStat_Counter buffers_written
BufferAccessStrategy strategy
char str[REL_PATH_STR_MAXLEN+1]
RelFileLocator rd_locator
RelFileLocatorBackend smgr_rlocator
PendingWriteback pending_writebacks[WRITEBACK_MAX_PENDING_FLUSHES]
static uint64 table_relation_size(Relation rel, ForkNumber forkNumber)
struct PgAioTargetData::@125 smgr
static volatile sig_atomic_t waiting
bool RecoveryInProgress(void)
bool XLogNeedsFlush(XLogRecPtr record)
CheckpointStatsData CheckpointStats
void XLogFlush(XLogRecPtr record)
#define CHECKPOINT_FLUSH_UNLOGGED
#define CHECKPOINT_END_OF_RECOVERY
#define CHECKPOINT_IS_SHUTDOWN
#define XLogHintBitIsNeeded()
#define XLogRecPtrIsValid(r)
#define InvalidXLogRecPtr
XLogRecPtr XLogSaveBufferForHint(Buffer buffer, bool buffer_std)
XLogRecPtr log_newpage_buffer(Buffer buffer, bool page_std)