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)
100#define REFCOUNT_ARRAY_ENTRIES 8
246 .
name =
"buffer pin",
483#define BufferIsPinned(bufnum) \
485 !BufferIsValid(bufnum) ? \
488 BufferIsLocal(bufnum) ? \
489 (LocalRefCount[-(bufnum) - 1] > 0) \
491 (GetPrivateRefCount(bufnum) > 0) \
516 bool skip_if_not_valid);
549#ifdef USE_ASSERT_CHECKING
551 void *unused_context);
663 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
664 errmsg(
"cannot access temporary tables of other sessions")));
699 int b = -recent_buffer - 1;
804 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
805 errmsg(
"cannot access temporary tables of other sessions")));
812 forkNum, blockNum,
mode, strategy);
836 permanent ? RELPERSISTENCE_PERMANENT : RELPERSISTENCE_UNLOGGED,
894 buffers, extended_by);
975 num_pages, extend_to,
976 buffers, &extended_by);
983 if (first_block +
i != extend_to - 1)
1000 fork, extend_to - 1,
mode, strategy);
1026 need_to_zero =
false;
1028 else if (isLocalBuf)
1072 else if (!isLocalBuf)
1106 Assert((persistence == RELPERSISTENCE_TEMP ||
1107 persistence == RELPERSISTENCE_PERMANENT ||
1108 persistence == RELPERSISTENCE_UNLOGGED));
1110 if (persistence == RELPERSISTENCE_TEMP)
1121 TRACE_POSTGRESQL_BUFFER_READ_START(forkNum, blockNum,
1127 if (persistence == RELPERSISTENCE_TEMP)
1135 bufHdr =
BufferAlloc(smgr, persistence, forkNum, blockNum,
1136 strategy, foundPtr, io_context);
1157 TRACE_POSTGRESQL_BUFFER_READ_DONE(forkNum, blockNum,
1205 persistence = rel->
rd_rel->relpersistence;
1207 persistence = smgr_persistence;
1215 forkNum, blockNum, strategy, &found);
1228 operation.
smgr = smgr;
1229 operation.
rel = rel;
1248 bool allow_forwarding)
1250 int actual_nblocks = *nblocks;
1254 Assert(*nblocks == 1 || allow_forwarding);
1258 for (
int i = 0;
i < actual_nblocks; ++
i)
1321#ifdef USE_ASSERT_CHECKING
1355 if (
i == 0 && actual_nblocks > 1)
1360 if (
unlikely(maxcombine < actual_nblocks))
1362 elog(
DEBUG2,
"limiting nblocks at %u from %u to %u",
1363 blockNum, actual_nblocks, maxcombine);
1364 actual_nblocks = maxcombine;
1369 *nblocks = actual_nblocks;
1374 operation->
flags = flags;
1375 operation->
nblocks = actual_nblocks;
1411 operation->
nblocks = *nblocks;
1438 did_start_io =
true;
1443 return did_start_io;
1510#ifdef USE_ASSERT_CHECKING
1524 if (i < operation->nblocks_done)
1578 int newly_read_blocks = 0;
1604 Assert(newly_read_blocks > 0);
1619 if (operation->
persistence == RELPERSISTENCE_TEMP)
1642 elog(
ERROR,
"waiting for read operation that didn't read");
1653 int ignored_nblocks_progress;
1748 int flags = operation->
flags;
1754 int io_buffers_len = 0;
1770 if (persistence == RELPERSISTENCE_TEMP)
1853 *nblocks_progress = 1;
1857 did_start_io =
false;
1864 TRACE_POSTGRESQL_BUFFER_READ_DONE(forknum, blocknum + operation->
nblocks_done,
1871 if (persistence == RELPERSISTENCE_TEMP)
1889 Assert(io_buffers[0] == buffers[nblocks_done]);
1899 for (
int i = nblocks_done + 1;
i < operation->
nblocks;
i++)
1906 Assert(io_buffers[io_buffers_len] == buffers[
i]);
1918 persistence == RELPERSISTENCE_TEMP ?
1936 blocknum + nblocks_done,
1937 io_pages, io_buffers_len);
1939 io_start, 1, io_buffers_len * BLCKSZ);
1941 if (persistence == RELPERSISTENCE_TEMP)
1954 *nblocks_progress = io_buffers_len;
1955 did_start_io =
true;
1958 return did_start_io;
1988 LWLock *newPartitionLock;
1989 int existing_buf_id;
2009 if (existing_buf_id >= 0)
2062 if (existing_buf_id >= 0)
2083 valid =
PinBuffer(existing_buf_hdr, strategy,
false);
2100 return existing_buf_hdr;
2106 victim_buf_state =
LockBufHdr(victim_buf_hdr);
2112 victim_buf_hdr->
tag = newTag;
2121 if (relpersistence == RELPERSISTENCE_PERMANENT || forkNum ==
INIT_FORKNUM)
2134 return victim_buf_hdr;
2158 LWLock *oldPartitionLock;
2210 elog(
ERROR,
"buffer is pinned in InvalidateBuffer");
2395 if (strategy != NULL)
2456#ifdef USE_ASSERT_CHECKING
2489 uint32 estimated_pins_held;
2517 if (*additional_pins <= 1)
2521 limit =
Max(limit, 1);
2522 if (limit < *additional_pins)
2523 *additional_pins = limit;
2542 TRACE_POSTGRESQL_BUFFER_EXTEND_START(fork,
2551 extend_by, extend_upto,
2552 buffers, &extend_by);
2555 extend_by, extend_upto,
2556 buffers, &extend_by);
2557 *extended_by = extend_by;
2559 TRACE_POSTGRESQL_BUFFER_EXTEND_DONE(fork,
2608 MemSet(buf_block, 0, BLCKSZ);
2641 uint32 orig_extend_by = extend_by;
2643 if (first_block > extend_upto)
2645 else if ((
uint64) first_block + extend_by > extend_upto)
2646 extend_by = extend_upto - first_block;
2648 for (
uint32 i = extend_by;
i < orig_extend_by;
i++)
2659 *extended_by = extend_by;
2667 (
errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
2668 errmsg(
"cannot extend relation %s beyond %u blocks",
2680 Buffer victim_buf = buffers[
i];
2712 if (existing_id >= 0)
2722 valid =
PinBuffer(existing_hdr, strategy,
false);
2732 (
errmsg(
"unexpected data beyond EOF in block %u of relation \"%s\"",
2762 victim_buf_hdr->
tag = tag;
2804 io_start, 1, extend_by * BLCKSZ);
2818 if (first_block +
i + 1 == extend_upto)
2830 *extended_by = extend_by;
2973 buf_state = old_buf_state;
3069 bool skip_if_not_valid)
3098 buf_state = old_buf_state;
3103 if (strategy == NULL)
3122 result = (buf_state &
BM_VALID) != 0;
3229 int wait_backend_pgprocno =
buf->wait_backend_pgprocno;
3325#define ST_SORT sort_checkpoint_bufferids
3326#define ST_ELEMENT_TYPE CkptSortItem
3327#define ST_COMPARE(a, b) ckpt_buforder_comparator(a, b)
3328#define ST_SCOPE static
3384 for (buf_id = 0; buf_id <
NBuffers; buf_id++)
3395 if ((buf_state & mask) == mask)
3418 if (num_to_scan == 0)
3423 TRACE_POSTGRESQL_BUFFER_SYNC_START(
NBuffers, num_to_scan);
3441 for (
i = 0;
i < num_to_scan;
i++)
3452 if (last_tsid ==
InvalidOid || last_tsid != cur_tsid)
3464 if (per_ts_stat == NULL)
3469 s = &per_ts_stat[num_spaces - 1];
3470 memset(s, 0,
sizeof(*s));
3485 last_tsid = cur_tsid;
3489 s = &per_ts_stat[num_spaces - 1];
3510 for (
i = 0;
i < num_spaces;
i++)
3558 TRACE_POSTGRESQL_BUFFER_SYNC_WRITTEN(buf_id);
3607 TRACE_POSTGRESQL_BUFFER_SYNC_DONE(
NBuffers, num_written, num_to_scan);
3625 int strategy_buf_id;
3633 static bool saved_info_valid =
false;
3634 static int prev_strategy_buf_id;
3635 static uint32 prev_strategy_passes;
3636 static int next_to_clean;
3637 static uint32 next_passes;
3640 static float smoothed_alloc = 0;
3641 static float smoothed_density = 10.0;
3644 float smoothing_samples = 16;
3645 float scan_whole_pool_milliseconds = 120000.0;
3648 long strategy_delta;
3651 float scans_per_alloc;
3652 int reusable_buffers_est;
3653 int upcoming_alloc_est;
3654 int min_scan_buffers;
3659 int reusable_buffers;
3662 long new_strategy_delta;
3681 saved_info_valid =
false;
3693 if (saved_info_valid)
3695 int32 passes_delta = strategy_passes - prev_strategy_passes;
3697 strategy_delta = strategy_buf_id - prev_strategy_buf_id;
3698 strategy_delta += (long) passes_delta *
NBuffers;
3700 Assert(strategy_delta >= 0);
3702 if ((
int32) (next_passes - strategy_passes) > 0)
3705 bufs_to_lap = strategy_buf_id - next_to_clean;
3707 elog(
DEBUG2,
"bgwriter ahead: bgw %u-%u strategy %u-%u delta=%ld lap=%d",
3708 next_passes, next_to_clean,
3709 strategy_passes, strategy_buf_id,
3710 strategy_delta, bufs_to_lap);
3713 else if (next_passes == strategy_passes &&
3714 next_to_clean >= strategy_buf_id)
3717 bufs_to_lap =
NBuffers - (next_to_clean - strategy_buf_id);
3719 elog(
DEBUG2,
"bgwriter ahead: bgw %u-%u strategy %u-%u delta=%ld lap=%d",
3720 next_passes, next_to_clean,
3721 strategy_passes, strategy_buf_id,
3722 strategy_delta, bufs_to_lap);
3732 elog(
DEBUG2,
"bgwriter behind: bgw %u-%u strategy %u-%u delta=%ld",
3733 next_passes, next_to_clean,
3734 strategy_passes, strategy_buf_id,
3737 next_to_clean = strategy_buf_id;
3738 next_passes = strategy_passes;
3749 elog(
DEBUG2,
"bgwriter initializing: strategy %u-%u",
3750 strategy_passes, strategy_buf_id);
3753 next_to_clean = strategy_buf_id;
3754 next_passes = strategy_passes;
3759 prev_strategy_buf_id = strategy_buf_id;
3760 prev_strategy_passes = strategy_passes;
3761 saved_info_valid =
true;
3769 if (strategy_delta > 0 && recent_alloc > 0)
3771 scans_per_alloc = (float) strategy_delta / (
float) recent_alloc;
3772 smoothed_density += (scans_per_alloc - smoothed_density) /
3781 bufs_ahead =
NBuffers - bufs_to_lap;
3782 reusable_buffers_est = (float) bufs_ahead / smoothed_density;
3789 if (smoothed_alloc <= (
float) recent_alloc)
3790 smoothed_alloc = recent_alloc;
3792 smoothed_alloc += ((float) recent_alloc - smoothed_alloc) /
3806 if (upcoming_alloc_est == 0)
3821 if (upcoming_alloc_est < (min_scan_buffers + reusable_buffers_est))
3824 elog(
DEBUG2,
"bgwriter: alloc_est=%d too small, using min=%d + reusable_est=%d",
3825 upcoming_alloc_est, min_scan_buffers, reusable_buffers_est);
3827 upcoming_alloc_est = min_scan_buffers + reusable_buffers_est;
3837 num_to_scan = bufs_to_lap;
3839 reusable_buffers = reusable_buffers_est;
3842 while (num_to_scan > 0 && reusable_buffers < upcoming_alloc_est)
3870 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",
3871 recent_alloc, smoothed_alloc, strategy_delta, bufs_ahead,
3872 smoothed_density, reusable_buffers_est, upcoming_alloc_est,
3873 bufs_to_lap - num_to_scan,
3875 reusable_buffers - reusable_buffers_est);
3886 new_strategy_delta = bufs_to_lap - num_to_scan;
3887 new_recent_alloc = reusable_buffers - reusable_buffers_est;
3888 if (new_strategy_delta > 0 && new_recent_alloc > 0)
3890 scans_per_alloc = (float) new_strategy_delta / (
float) new_recent_alloc;
3891 smoothed_density += (scans_per_alloc - smoothed_density) /
3895 elog(
DEBUG2,
"bgwriter: cleaner density alloc=%u scan=%ld density=%.2f new smoothed=%.2f",
3896 new_recent_alloc, new_strategy_delta,
3897 scans_per_alloc, smoothed_density);
3902 return (bufs_to_lap == 0 && recent_alloc == 0);
3947 else if (skip_recently_used)
4061#ifdef USE_ASSERT_CHECKING
4062 int RefCountErrors = 0;
4097 Assert(RefCountErrors == 0);
4101#ifdef USE_ASSERT_CHECKING
4120AssertBufferLocksPermitCatalogRead(
void)
4127 void *unused_context)
4141 ((
char *) lock - offsetof(
BufferDesc, content_lock));
4191 result =
psprintf(
"[%03d] (rel=%s, blockNum=%u, flags=0x%x, refcount=%u %d)",
4439 if (RELKIND_HAS_TABLE_AM(relation->
rd_rel->relkind))
4451 return (szbytes + (BLCKSZ - 1)) / BLCKSZ;
4453 else if (RELKIND_HAS_STORAGE(relation->
rd_rel->relkind))
4552 uint64 nBlocksToInvalidate = 0;
4588 for (
i = 0;
i < nforks;
i++)
4600 nBlocksToInvalidate += (nForkBlock[
i] - firstDelBlock[
i]);
4610 for (
j = 0;
j < nforks;
j++)
4612 nForkBlock[
j], firstDelBlock[
j]);
4641 for (
j = 0;
j < nforks;
j++)
4671 uint64 nBlocksToInvalidate = 0;
4682 for (
i = 0;
i < nlocators;
i++)
4690 rels[n++] = smgr_reln[
i];
4714 for (
i = 0;
i < n && cached;
i++)
4731 nBlocksToInvalidate += block[
i][
j];
4741 for (
i = 0;
i < n;
i++)
4762 for (
i = 0;
i < n;
i++)
4763 locators[
i] = rels[
i]->smgr_rlocator.locator;
4791 for (
j = 0;
j < n;
j++)
4795 rlocator = &locators[
j];
4805 rlocator = bsearch(&locator,
4811 if (rlocator == NULL)
4841 for (curBlock = firstDelBlock; curBlock < nForkBlock; curBlock++)
4845 LWLock *bufPartitionLock;
4963 errcallback.
arg = bufHdr;
5042 for (
i = 0;
i < nrels;
i++)
5047 srels[
i].
srel = smgrs[
i];
5075 for (
j = 0;
j < nrels;
j++)
5079 srelent = &srels[
j];
5089 srelent = bsearch(&rlocator,
5095 if (srelent == NULL)
5165 memset(
buf.data, 0, BLCKSZ);
5186 permanent ? RELPERSISTENCE_PERMANENT : RELPERSISTENCE_UNLOGGED,
5193 for (blkno = 0; blkno < nblocks; blkno++)
5211 memcpy(dstPage, srcPage, BLCKSZ);
5245 char relpersistence;
5250 relpersistence = permanent ?
5251 RELPERSISTENCE_PERMANENT : RELPERSISTENCE_UNLOGGED;
5465 bool dirtied =
false;
5466 bool delayChkptFlags =
false;
5518 delayChkptFlags =
true;
5551 if (delayChkptFlags)
5656 elog(
ERROR,
"incorrect local pin count: %d",
5662 elog(
ERROR,
"incorrect local pin count: %d",
5689 bool logged_recovery_conflict =
false;
5729 if (logged_recovery_conflict)
5747 elog(
ERROR,
"multiple backends attempting to wait for pincount 1");
5774 if (waitStart != 0 && !logged_recovery_conflict)
5782 waitStart,
now, NULL,
true);
5783 logged_recovery_conflict =
true;
6105 bool forget_owner,
bool release_aio)
6108 uint32 unset_flag_bits = 0;
6109 int refcount_change = 0;
6126 refcount_change = -1;
6131 set_flag_bits, unset_flag_bits,
6190 errmsg(
"could not write block %u of %s",
6194 errdetail(
"Multiple failures --- write error might be permanent.")));
6211 errcontext(
"writing block %u of relation \"%s\"",
6226 errcontext(
"writing block %u of relation \"%s\"",
6355 if (
a->tsId <
b->tsId)
6357 else if (
a->tsId >
b->tsId)
6360 if (
a->relNumber <
b->relNumber)
6362 else if (
a->relNumber >
b->relNumber)
6365 else if (
a->forkNum <
b->forkNum)
6367 else if (
a->forkNum >
b->forkNum)
6370 else if (
a->blockNum <
b->blockNum)
6372 else if (
a->blockNum >
b->blockNum)
6441 pending->
tag = *tag;
6453#define ST_SORT sort_pending_writebacks
6454#define ST_ELEMENT_TYPE PendingWriteback
6455#define ST_COMPARE(a, b) buffertag_comparator(&a->tag, &b->tag)
6456#define ST_SCOPE static
6508 for (ahead = 0;
i + ahead + 1 < wb_context->
nr_pending; ahead++)
6520 if (
cur->tag.blockNum ==
next->tag.blockNum)
6524 if (
cur->tag.blockNum + 1 !=
next->tag.blockNum)
6597 *buffer_flushed =
false;
6621 *buffer_flushed =
true;
6684 int32 *buffers_skipped)
6686 *buffers_evicted = 0;
6687 *buffers_skipped = 0;
6688 *buffers_flushed = 0;
6694 bool buffer_flushed;
6708 (*buffers_evicted)++;
6710 (*buffers_skipped)++;
6713 (*buffers_flushed)++;
6734 int32 *buffers_flushed,
int32 *buffers_skipped)
6738 *buffers_skipped = 0;
6739 *buffers_evicted = 0;
6740 *buffers_flushed = 0;
6746 bool buffer_flushed;
6770 (*buffers_evicted)++;
6772 (*buffers_skipped)++;
6775 (*buffers_flushed)++;
6797 uint8 handle_data_len;
6806 for (
int i = 0;
i < handle_data_len;
i++)
6822 first = buf_hdr->
tag;
6878 if (is_write && !is_temp)
6908 uint8 *zeroed_or_error_count,
6909 uint8 *checkfail_count,
6915#define READV_COUNT_BITS 7
6916#define READV_COUNT_MASK ((1 << READV_COUNT_BITS) - 1)
6918 *zeroed_any = rem_error & 1;
6921 *ignored_any = rem_error & 1;
6953 uint8 checkfail_count,
6954 uint8 first_error_off,
6955 uint8 first_zeroed_off,
6956 uint8 first_ignored_off)
6960 uint8 zeroed_or_error_count =
6961 error_count > 0 ? error_count : zeroed_count;
6965 "PG_IOV_MAX is bigger than reserved space for error data");
6967 "PGAIO_RESULT_ERROR_BITS is insufficient for buffer_readv");
6974 if (error_count > 0)
6975 first_off = first_error_off;
6976 else if (zeroed_count > 0)
6977 first_off = first_zeroed_off;
6979 first_off = first_ignored_off;
6981 Assert(!zeroed_any || error_count == 0);
7003 if (error_count > 0)
7012#ifdef USE_ASSERT_CHECKING
7016 uint8 zeroed_or_error_count_2,
7021 &zeroed_any_2, &ignored_any_2,
7022 &zeroed_or_error_count_2,
7025 Assert(zeroed_any == zeroed_any_2);
7026 Assert(ignored_any == ignored_any_2);
7027 Assert(zeroed_or_error_count == zeroed_or_error_count_2);
7028 Assert(checkfail_count == checkfail_count_2);
7029 Assert(first_off == first_off_2);
7033#undef READV_COUNT_BITS
7034#undef READV_COUNT_MASK
7043 uint8 flags,
bool failed,
bool is_temp,
7044 bool *buffer_invalid,
7045 bool *failed_checksum,
7046 bool *ignored_checksum,
7047 bool *zeroed_buffer)
7058#ifdef USE_ASSERT_CHECKING
7071 *buffer_invalid =
false;
7072 *failed_checksum =
false;
7073 *ignored_checksum =
false;
7074 *zeroed_buffer =
false;
7108 memset(bufdata, 0, BLCKSZ);
7109 *zeroed_buffer =
true;
7113 *buffer_invalid =
true;
7118 else if (*failed_checksum)
7119 *ignored_checksum =
true;
7141 if (*buffer_invalid || *failed_checksum || *zeroed_buffer)
7149 *zeroed_buffer ? 1 : 0,
7150 *failed_checksum ? 1 : 0,
7151 buf_off, buf_off, buf_off);
7170 TRACE_POSTGRESQL_BUFFER_READ_DONE(tag.
forkNum,
7187 uint8 cb_data,
bool is_temp)
7191 uint8 first_error_off = 0;
7192 uint8 first_zeroed_off = 0;
7193 uint8 first_ignored_off = 0;
7194 uint8 error_count = 0;
7195 uint8 zeroed_count = 0;
7196 uint8 ignored_count = 0;
7197 uint8 checkfail_count = 0;
7199 uint8 handle_data_len;
7214 for (
uint8 buf_off = 0; buf_off < handle_data_len; buf_off++)
7218 bool failed_verification =
false;
7219 bool failed_checksum =
false;
7220 bool zeroed_buffer =
false;
7221 bool ignored_checksum =
false;
7232 || prior_result.
result <= buf_off;
7235 &failed_verification,
7245 if (failed_verification && !zeroed_buffer && error_count++ == 0)
7246 first_error_off = buf_off;
7247 if (zeroed_buffer && zeroed_count++ == 0)
7248 first_zeroed_off = buf_off;
7249 if (ignored_checksum && ignored_count++ == 0)
7250 first_ignored_off = buf_off;
7251 if (failed_checksum)
7260 (error_count > 0 || ignored_count > 0 || zeroed_count > 0))
7263 zeroed_count > 0, ignored_count > 0,
7264 error_count, zeroed_count, checkfail_count,
7265 first_error_off, first_zeroed_off,
7274 if (is_temp && checkfail_count > 0)
7301 uint8 zeroed_or_error_count,
7304 uint8 affected_count;
7305 const char *msg_one,
7311 &zeroed_or_error_count,
7320 if (zeroed_any && ignored_any)
7322 Assert(zeroed_any && ignored_any);
7325 affected_count = zeroed_or_error_count;
7329 errmsg(
"zeroing %u page(s) and ignoring %u checksum failure(s) among blocks %u..%u of relation \"%s\"",
7330 affected_count, checkfail_count, first, last, rpath.
str),
7331 affected_count > 1 ?
7332 errdetail(
"Block %u held the first zeroed page.",
7333 first + first_off) : 0,
7334 errhint_plural(
"See server log for details about the other %d invalid block.",
7335 "See server log for details about the other %d invalid blocks.",
7336 affected_count + checkfail_count - 1,
7337 affected_count + checkfail_count - 1));
7349 affected_count = zeroed_or_error_count;
7350 msg_one =
_(
"invalid page in block %u of relation \"%s\"");
7351 msg_mult =
_(
"%u invalid pages among blocks %u..%u of relation \"%s\"");
7352 det_mult =
_(
"Block %u held the first invalid page.");
7353 hint_mult =
_(
"See server log for the other %u invalid block(s).");
7355 else if (zeroed_any && !ignored_any)
7357 affected_count = zeroed_or_error_count;
7358 msg_one =
_(
"invalid page in block %u of relation \"%s\"; zeroing out page");
7359 msg_mult =
_(
"zeroing out %u invalid pages among blocks %u..%u of relation \"%s\"");
7360 det_mult =
_(
"Block %u held the first zeroed page.");
7361 hint_mult =
_(
"See server log for the other %u zeroed block(s).");
7363 else if (!zeroed_any && ignored_any)
7365 affected_count = checkfail_count;
7366 msg_one =
_(
"ignoring checksum failure in block %u of relation \"%s\"");
7367 msg_mult =
_(
"ignoring %u checksum failures among blocks %u..%u of relation \"%s\"");
7368 det_mult =
_(
"Block %u held the first ignored page.");
7369 hint_mult =
_(
"See server log for the other %u ignored block(s).");
7376 affected_count == 1 ?
7409 uint8 zeroed_or_error_count,
7414 return prior_result;
7419 &zeroed_or_error_count,
7423 if (checkfail_count)
7431 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 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 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)
bool BufferIsLockedByMeInMode(Buffer buffer, int mode)
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
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)
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)
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)
#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)
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 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 LockBuffer(Buffer buffer, int mode)
static PrivateRefCountEntry * ReservedRefCountEntry
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
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)
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)
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 BUFFER_LOCK_UNLOCK
#define BUFFER_LOCK_SHARE
#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
#define BUFFER_LOCK_EXCLUSIVE
@ 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 StaticAssertStmt(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,...)
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
#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)