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,
889 if (bmr.
smgr == NULL)
897 buffers, extended_by);
925 if (bmr.
smgr == NULL)
981 num_pages, extend_to,
982 buffers, &extended_by);
989 if (first_block +
i != extend_to - 1)
1004 Assert(extended_by == 0);
1006 fork, extend_to - 1,
mode, strategy);
1032 need_to_zero =
false;
1034 else if (isLocalBuf)
1078 else if (!isLocalBuf)
1112 Assert((persistence == RELPERSISTENCE_TEMP ||
1113 persistence == RELPERSISTENCE_PERMANENT ||
1114 persistence == RELPERSISTENCE_UNLOGGED));
1116 if (persistence == RELPERSISTENCE_TEMP)
1127 TRACE_POSTGRESQL_BUFFER_READ_START(forkNum, blockNum,
1133 if (persistence == RELPERSISTENCE_TEMP)
1141 bufHdr =
BufferAlloc(smgr, persistence, forkNum, blockNum,
1142 strategy, foundPtr, io_context);
1163 TRACE_POSTGRESQL_BUFFER_READ_DONE(forkNum, blockNum,
1211 persistence = rel->
rd_rel->relpersistence;
1213 persistence = smgr_persistence;
1221 forkNum, blockNum, strategy, &found);
1234 operation.
smgr = smgr;
1235 operation.
rel = rel;
1254 bool allow_forwarding)
1256 int actual_nblocks = *nblocks;
1260 Assert(*nblocks == 1 || allow_forwarding);
1264 for (
int i = 0;
i < actual_nblocks; ++
i)
1327#ifdef USE_ASSERT_CHECKING
1361 if (
i == 0 && actual_nblocks > 1)
1366 if (
unlikely(maxcombine < actual_nblocks))
1368 elog(
DEBUG2,
"limiting nblocks at %u from %u to %u",
1369 blockNum, actual_nblocks, maxcombine);
1370 actual_nblocks = maxcombine;
1375 *nblocks = actual_nblocks;
1380 operation->
flags = flags;
1381 operation->
nblocks = actual_nblocks;
1417 operation->
nblocks = *nblocks;
1444 did_start_io =
true;
1449 return did_start_io;
1516#ifdef USE_ASSERT_CHECKING
1530 if (i < operation->nblocks_done)
1584 int newly_read_blocks = 0;
1610 Assert(newly_read_blocks > 0);
1625 if (operation->
persistence == RELPERSISTENCE_TEMP)
1648 elog(
ERROR,
"waiting for read operation that didn't read");
1659 int ignored_nblocks_progress;
1754 int flags = operation->
flags;
1760 int io_buffers_len = 0;
1776 if (persistence == RELPERSISTENCE_TEMP)
1859 *nblocks_progress = 1;
1863 did_start_io =
false;
1870 TRACE_POSTGRESQL_BUFFER_READ_DONE(forknum, blocknum + operation->
nblocks_done,
1877 if (persistence == RELPERSISTENCE_TEMP)
1895 Assert(io_buffers[0] == buffers[nblocks_done]);
1905 for (
int i = nblocks_done + 1;
i < operation->
nblocks;
i++)
1912 Assert(io_buffers[io_buffers_len] == buffers[
i]);
1924 persistence == RELPERSISTENCE_TEMP ?
1942 blocknum + nblocks_done,
1943 io_pages, io_buffers_len);
1945 io_start, 1, io_buffers_len * BLCKSZ);
1947 if (persistence == RELPERSISTENCE_TEMP)
1960 *nblocks_progress = io_buffers_len;
1961 did_start_io =
true;
1964 return did_start_io;
1994 LWLock *newPartitionLock;
1995 int existing_buf_id;
2014 if (existing_buf_id >= 0)
2067 if (existing_buf_id >= 0)
2088 valid =
PinBuffer(existing_buf_hdr, strategy,
false);
2105 return existing_buf_hdr;
2111 victim_buf_state =
LockBufHdr(victim_buf_hdr);
2117 victim_buf_hdr->
tag = newTag;
2126 if (relpersistence == RELPERSISTENCE_PERMANENT || forkNum ==
INIT_FORKNUM)
2138 return victim_buf_hdr;
2162 LWLock *oldPartitionLock;
2216 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];
2711 if (existing_id >= 0)
2721 valid =
PinBuffer(existing_hdr, strategy,
false);
2731 (
errmsg(
"unexpected data beyond EOF in block %u of relation \"%s\"",
2749 buf_state &= ~BM_VALID;
2763 victim_buf_hdr->
tag = tag;
2803 io_start, 1, extend_by * BLCKSZ);
2817 if (first_block +
i + 1 == extend_upto)
2829 *extended_by = extend_by;
2968 buf_state = old_buf_state;
3064 bool skip_if_not_valid)
3089 buf_state = old_buf_state;
3094 if (strategy == NULL)
3113 result = (buf_state &
BM_VALID) != 0;
3236 int wait_backend_pgprocno =
buf->wait_backend_pgprocno;
3238 buf_state &= ~BM_PIN_COUNT_WAITER;
3306 buf_state = old_buf_state;
3334#define ST_SORT sort_checkpoint_bufferids
3335#define ST_ELEMENT_TYPE CkptSortItem
3336#define ST_COMPARE(a, b) ckpt_buforder_comparator(a, b)
3337#define ST_SCOPE static
3393 for (buf_id = 0; buf_id <
NBuffers; buf_id++)
3403 if ((buf_state & mask) == mask)
3424 if (num_to_scan == 0)
3429 TRACE_POSTGRESQL_BUFFER_SYNC_START(
NBuffers, num_to_scan);
3447 for (
i = 0;
i < num_to_scan;
i++)
3458 if (last_tsid ==
InvalidOid || last_tsid != cur_tsid)
3470 if (per_ts_stat == NULL)
3475 s = &per_ts_stat[num_spaces - 1];
3476 memset(s, 0,
sizeof(*s));
3491 last_tsid = cur_tsid;
3495 s = &per_ts_stat[num_spaces - 1];
3516 for (
i = 0;
i < num_spaces;
i++)
3564 TRACE_POSTGRESQL_BUFFER_SYNC_WRITTEN(buf_id);
3613 TRACE_POSTGRESQL_BUFFER_SYNC_DONE(
NBuffers, num_written, num_to_scan);
3631 int strategy_buf_id;
3639 static bool saved_info_valid =
false;
3640 static int prev_strategy_buf_id;
3641 static uint32 prev_strategy_passes;
3642 static int next_to_clean;
3643 static uint32 next_passes;
3646 static float smoothed_alloc = 0;
3647 static float smoothed_density = 10.0;
3650 float smoothing_samples = 16;
3651 float scan_whole_pool_milliseconds = 120000.0;
3654 long strategy_delta;
3657 float scans_per_alloc;
3658 int reusable_buffers_est;
3659 int upcoming_alloc_est;
3660 int min_scan_buffers;
3665 int reusable_buffers;
3668 long new_strategy_delta;
3687 saved_info_valid =
false;
3699 if (saved_info_valid)
3701 int32 passes_delta = strategy_passes - prev_strategy_passes;
3703 strategy_delta = strategy_buf_id - prev_strategy_buf_id;
3704 strategy_delta += (long) passes_delta *
NBuffers;
3706 Assert(strategy_delta >= 0);
3708 if ((
int32) (next_passes - strategy_passes) > 0)
3711 bufs_to_lap = strategy_buf_id - next_to_clean;
3713 elog(
DEBUG2,
"bgwriter ahead: bgw %u-%u strategy %u-%u delta=%ld lap=%d",
3714 next_passes, next_to_clean,
3715 strategy_passes, strategy_buf_id,
3716 strategy_delta, bufs_to_lap);
3719 else if (next_passes == strategy_passes &&
3720 next_to_clean >= strategy_buf_id)
3723 bufs_to_lap =
NBuffers - (next_to_clean - strategy_buf_id);
3725 elog(
DEBUG2,
"bgwriter ahead: bgw %u-%u strategy %u-%u delta=%ld lap=%d",
3726 next_passes, next_to_clean,
3727 strategy_passes, strategy_buf_id,
3728 strategy_delta, bufs_to_lap);
3738 elog(
DEBUG2,
"bgwriter behind: bgw %u-%u strategy %u-%u delta=%ld",
3739 next_passes, next_to_clean,
3740 strategy_passes, strategy_buf_id,
3743 next_to_clean = strategy_buf_id;
3744 next_passes = strategy_passes;
3755 elog(
DEBUG2,
"bgwriter initializing: strategy %u-%u",
3756 strategy_passes, strategy_buf_id);
3759 next_to_clean = strategy_buf_id;
3760 next_passes = strategy_passes;
3765 prev_strategy_buf_id = strategy_buf_id;
3766 prev_strategy_passes = strategy_passes;
3767 saved_info_valid =
true;
3775 if (strategy_delta > 0 && recent_alloc > 0)
3777 scans_per_alloc = (float) strategy_delta / (
float) recent_alloc;
3778 smoothed_density += (scans_per_alloc - smoothed_density) /
3787 bufs_ahead =
NBuffers - bufs_to_lap;
3788 reusable_buffers_est = (float) bufs_ahead / smoothed_density;
3795 if (smoothed_alloc <= (
float) recent_alloc)
3796 smoothed_alloc = recent_alloc;
3798 smoothed_alloc += ((float) recent_alloc - smoothed_alloc) /
3812 if (upcoming_alloc_est == 0)
3827 if (upcoming_alloc_est < (min_scan_buffers + reusable_buffers_est))
3830 elog(
DEBUG2,
"bgwriter: alloc_est=%d too small, using min=%d + reusable_est=%d",
3831 upcoming_alloc_est, min_scan_buffers, reusable_buffers_est);
3833 upcoming_alloc_est = min_scan_buffers + reusable_buffers_est;
3843 num_to_scan = bufs_to_lap;
3845 reusable_buffers = reusable_buffers_est;
3848 while (num_to_scan > 0 && reusable_buffers < upcoming_alloc_est)
3876 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",
3877 recent_alloc, smoothed_alloc, strategy_delta, bufs_ahead,
3878 smoothed_density, reusable_buffers_est, upcoming_alloc_est,
3879 bufs_to_lap - num_to_scan,
3881 reusable_buffers - reusable_buffers_est);
3892 new_strategy_delta = bufs_to_lap - num_to_scan;
3893 new_recent_alloc = reusable_buffers - reusable_buffers_est;
3894 if (new_strategy_delta > 0 && new_recent_alloc > 0)
3896 scans_per_alloc = (float) new_strategy_delta / (
float) new_recent_alloc;
3897 smoothed_density += (scans_per_alloc - smoothed_density) /
3901 elog(
DEBUG2,
"bgwriter: cleaner density alloc=%u scan=%ld density=%.2f new smoothed=%.2f",
3902 new_recent_alloc, new_strategy_delta,
3903 scans_per_alloc, smoothed_density);
3908 return (bufs_to_lap == 0 && recent_alloc == 0);
3953 else if (skip_recently_used)
4067#ifdef USE_ASSERT_CHECKING
4068 int RefCountErrors = 0;
4103 Assert(RefCountErrors == 0);
4107#ifdef USE_ASSERT_CHECKING
4126AssertBufferLocksPermitCatalogRead(
void)
4133 void *unused_context)
4147 ((
char *) lock - offsetof(
BufferDesc, content_lock));
4197 result =
psprintf(
"[%03d] (rel=%s, blockNum=%u, flags=0x%x, refcount=%u %d)",
4332 buf_state &= ~BM_JUST_DIRTIED;
4444 if (RELKIND_HAS_TABLE_AM(relation->
rd_rel->relkind))
4456 return (szbytes + (BLCKSZ - 1)) / BLCKSZ;
4458 else if (RELKIND_HAS_STORAGE(relation->
rd_rel->relkind))
4558 uint64 nBlocksToInvalidate = 0;
4594 for (
i = 0;
i < nforks;
i++)
4606 nBlocksToInvalidate += (nForkBlock[
i] - firstDelBlock[
i]);
4616 for (
j = 0;
j < nforks;
j++)
4618 nForkBlock[
j], firstDelBlock[
j]);
4648 for (
j = 0;
j < nforks;
j++)
4678 uint64 nBlocksToInvalidate = 0;
4689 for (
i = 0;
i < nlocators;
i++)
4697 rels[n++] = smgr_reln[
i];
4721 for (
i = 0;
i < n && cached;
i++)
4738 nBlocksToInvalidate += block[
i][
j];
4748 for (
i = 0;
i < n;
i++)
4769 for (
i = 0;
i < n;
i++)
4770 locators[
i] = rels[
i]->smgr_rlocator.locator;
4799 for (
j = 0;
j < n;
j++)
4803 rlocator = &locators[
j];
4813 rlocator = bsearch(&locator,
4819 if (rlocator == NULL)
4849 for (curBlock = firstDelBlock; curBlock < nForkBlock; curBlock++)
4853 LWLock *bufPartitionLock;
4973 errcallback.
arg = bufHdr;
5052 for (
i = 0;
i < nrels;
i++)
5057 srels[
i].
srel = smgrs[
i];
5085 for (
j = 0;
j < nrels;
j++)
5089 srelent = &srels[
j];
5099 srelent = bsearch(&rlocator,
5105 if (srelent == NULL)
5175 memset(
buf.data, 0, BLCKSZ);
5196 permanent ? RELPERSISTENCE_PERMANENT : RELPERSISTENCE_UNLOGGED,
5203 for (blkno = 0; blkno < nblocks; blkno++)
5221 memcpy(dstPage, srcPage, BLCKSZ);
5255 char relpersistence;
5260 relpersistence = permanent ?
5261 RELPERSISTENCE_PERMANENT : RELPERSISTENCE_UNLOGGED;
5475 bool dirtied =
false;
5476 bool delayChkptFlags =
false;
5528 delayChkptFlags =
true;
5560 if (delayChkptFlags)
5598 buf_state &= ~BM_PIN_COUNT_WAITER;
5662 elog(
ERROR,
"incorrect local pin count: %d",
5668 elog(
ERROR,
"incorrect local pin count: %d",
5695 bool logged_recovery_conflict =
false;
5734 if (logged_recovery_conflict)
5752 elog(
ERROR,
"multiple backends attempting to wait for pincount 1");
5778 if (waitStart != 0 && !logged_recovery_conflict)
5786 waitStart,
now, NULL,
true);
5787 logged_recovery_conflict =
true;
5819 buf_state &= ~BM_PIN_COUNT_WAITER;
6105 bool forget_owner,
bool release_aio)
6112 buf_state &= ~BM_IO_IN_PROGRESS;
6115 buf_state &= ~BM_IO_ERROR;
6128 buf_state |= set_flag_bits;
6187 errmsg(
"could not write block %u of %s",
6191 errdetail(
"Multiple failures --- write error might be permanent.")));
6208 errcontext(
"writing block %u of relation \"%s\"",
6223 errcontext(
"writing block %u of relation \"%s\"",
6352 if (
a->tsId <
b->tsId)
6354 else if (
a->tsId >
b->tsId)
6357 if (
a->relNumber <
b->relNumber)
6359 else if (
a->relNumber >
b->relNumber)
6362 else if (
a->forkNum <
b->forkNum)
6364 else if (
a->forkNum >
b->forkNum)
6367 else if (
a->blockNum <
b->blockNum)
6369 else if (
a->blockNum >
b->blockNum)
6438 pending->
tag = *tag;
6450#define ST_SORT sort_pending_writebacks
6451#define ST_ELEMENT_TYPE PendingWriteback
6452#define ST_COMPARE(a, b) buffertag_comparator(&a->tag, &b->tag)
6453#define ST_SCOPE static
6505 for (ahead = 0;
i + ahead + 1 < wb_context->
nr_pending; ahead++)
6517 if (
cur->tag.blockNum ==
next->tag.blockNum)
6521 if (
cur->tag.blockNum + 1 !=
next->tag.blockNum)
6594 *buffer_flushed =
false;
6618 *buffer_flushed =
true;
6681 int32 *buffers_skipped)
6683 *buffers_evicted = 0;
6684 *buffers_skipped = 0;
6685 *buffers_flushed = 0;
6691 bool buffer_flushed;
6703 (*buffers_evicted)++;
6705 (*buffers_skipped)++;
6708 (*buffers_flushed)++;
6729 int32 *buffers_flushed,
int32 *buffers_skipped)
6733 *buffers_skipped = 0;
6734 *buffers_evicted = 0;
6735 *buffers_flushed = 0;
6741 bool buffer_flushed;
6763 (*buffers_evicted)++;
6765 (*buffers_skipped)++;
6768 (*buffers_flushed)++;
6790 uint8 handle_data_len;
6799 for (
int i = 0;
i < handle_data_len;
i++)
6815 first = buf_hdr->
tag;
6869 if (is_write && !is_temp)
6899 uint8 *zeroed_or_error_count,
6900 uint8 *checkfail_count,
6906#define READV_COUNT_BITS 7
6907#define READV_COUNT_MASK ((1 << READV_COUNT_BITS) - 1)
6909 *zeroed_any = rem_error & 1;
6912 *ignored_any = rem_error & 1;
6944 uint8 checkfail_count,
6945 uint8 first_error_off,
6946 uint8 first_zeroed_off,
6947 uint8 first_ignored_off)
6951 uint8 zeroed_or_error_count =
6952 error_count > 0 ? error_count : zeroed_count;
6956 "PG_IOV_MAX is bigger than reserved space for error data");
6958 "PGAIO_RESULT_ERROR_BITS is insufficient for buffer_readv");
6965 if (error_count > 0)
6966 first_off = first_error_off;
6967 else if (zeroed_count > 0)
6968 first_off = first_zeroed_off;
6970 first_off = first_ignored_off;
6972 Assert(!zeroed_any || error_count == 0);
6994 if (error_count > 0)
7003#ifdef USE_ASSERT_CHECKING
7007 uint8 zeroed_or_error_count_2,
7012 &zeroed_any_2, &ignored_any_2,
7013 &zeroed_or_error_count_2,
7016 Assert(zeroed_any == zeroed_any_2);
7017 Assert(ignored_any == ignored_any_2);
7018 Assert(zeroed_or_error_count == zeroed_or_error_count_2);
7019 Assert(checkfail_count == checkfail_count_2);
7020 Assert(first_off == first_off_2);
7024#undef READV_COUNT_BITS
7025#undef READV_COUNT_MASK
7034 uint8 flags,
bool failed,
bool is_temp,
7035 bool *buffer_invalid,
7036 bool *failed_checksum,
7037 bool *ignored_checksum,
7038 bool *zeroed_buffer)
7049#ifdef USE_ASSERT_CHECKING
7062 *buffer_invalid =
false;
7063 *failed_checksum =
false;
7064 *ignored_checksum =
false;
7065 *zeroed_buffer =
false;
7099 memset(bufdata, 0, BLCKSZ);
7100 *zeroed_buffer =
true;
7104 *buffer_invalid =
true;
7109 else if (*failed_checksum)
7110 *ignored_checksum =
true;
7132 if (*buffer_invalid || *failed_checksum || *zeroed_buffer)
7140 *zeroed_buffer ? 1 : 0,
7141 *failed_checksum ? 1 : 0,
7142 buf_off, buf_off, buf_off);
7161 TRACE_POSTGRESQL_BUFFER_READ_DONE(tag.
forkNum,
7178 uint8 cb_data,
bool is_temp)
7182 uint8 first_error_off = 0;
7183 uint8 first_zeroed_off = 0;
7184 uint8 first_ignored_off = 0;
7185 uint8 error_count = 0;
7186 uint8 zeroed_count = 0;
7187 uint8 ignored_count = 0;
7188 uint8 checkfail_count = 0;
7190 uint8 handle_data_len;
7205 for (
uint8 buf_off = 0; buf_off < handle_data_len; buf_off++)
7209 bool failed_verification =
false;
7210 bool failed_checksum =
false;
7211 bool zeroed_buffer =
false;
7212 bool ignored_checksum =
false;
7223 || prior_result.
result <= buf_off;
7226 &failed_verification,
7236 if (failed_verification && !zeroed_buffer && error_count++ == 0)
7237 first_error_off = buf_off;
7238 if (zeroed_buffer && zeroed_count++ == 0)
7239 first_zeroed_off = buf_off;
7240 if (ignored_checksum && ignored_count++ == 0)
7241 first_ignored_off = buf_off;
7242 if (failed_checksum)
7251 (error_count > 0 || ignored_count > 0 || zeroed_count > 0))
7254 zeroed_count > 0, ignored_count > 0,
7255 error_count, zeroed_count, checkfail_count,
7256 first_error_off, first_zeroed_off,
7265 if (is_temp && checkfail_count > 0)
7292 uint8 zeroed_or_error_count,
7295 uint8 affected_count;
7296 const char *msg_one,
7302 &zeroed_or_error_count,
7311 if (zeroed_any && ignored_any)
7313 Assert(zeroed_any && ignored_any);
7316 affected_count = zeroed_or_error_count;
7320 errmsg(
"zeroing %u page(s) and ignoring %u checksum failure(s) among blocks %u..%u of relation \"%s\"",
7321 affected_count, checkfail_count, first, last, rpath.
str),
7322 affected_count > 1 ?
7323 errdetail(
"Block %u held the first zeroed page.",
7324 first + first_off) : 0,
7325 errhint_plural(
"See server log for details about the other %d invalid block.",
7326 "See server log for details about the other %d invalid blocks.",
7327 affected_count + checkfail_count - 1,
7328 affected_count + checkfail_count - 1));
7340 affected_count = zeroed_or_error_count;
7341 msg_one =
_(
"invalid page in block %u of relation \"%s\"");
7342 msg_mult =
_(
"%u invalid pages among blocks %u..%u of relation \"%s\"");
7343 det_mult =
_(
"Block %u held the first invalid page.");
7344 hint_mult =
_(
"See server log for the other %u invalid block(s).");
7346 else if (zeroed_any && !ignored_any)
7348 affected_count = zeroed_or_error_count;
7349 msg_one =
_(
"invalid page in block %u of relation \"%s\"; zeroing out page");
7350 msg_mult =
_(
"zeroing out %u invalid pages among blocks %u..%u of relation \"%s\"");
7351 det_mult =
_(
"Block %u held the first zeroed page.");
7352 hint_mult =
_(
"See server log for the other %u zeroed block(s).");
7354 else if (!zeroed_any && ignored_any)
7356 affected_count = checkfail_count;
7357 msg_one =
_(
"ignoring checksum failure in block %u of relation \"%s\"");
7358 msg_mult =
_(
"ignoring %u checksum failures among blocks %u..%u of relation \"%s\"");
7359 det_mult =
_(
"Block %u held the first ignored page.");
7360 hint_mult =
_(
"See server log for the other %u ignored block(s).");
7367 affected_count == 1 ?
7400 uint8 zeroed_or_error_count,
7405 return prior_result;
7410 &zeroed_or_error_count,
7414 if (checkfail_count)
7422 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 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_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 void UnlockBufHdr(BufferDesc *desc, uint32 buf_state)
static bool BufferTagsEqual(const BufferTag *tag1, const BufferTag *tag2)
static RelFileNumber BufTagGetRelNumber(const BufferTag *tag)
static LWLock * BufferDescriptorGetContentLock(const BufferDesc *bdesc)
static bool BufTagMatchesRelFileLocator(const BufferTag *tag, const RelFileLocator *rlocator)
#define BM_PIN_COUNT_WAITER
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
@ 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
BlockNumber smgr_cached_nblocks[MAX_FORKNUM+1]
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 XLogRecPtrIsInvalid(r)
#define InvalidXLogRecPtr
XLogRecPtr XLogSaveBufferForHint(Buffer buffer, bool buffer_std)
XLogRecPtr log_newpage_buffer(Buffer buffer, bool page_std)