168#define REL_TRUNCATE_MINIMUM 1000
169#define REL_TRUNCATE_FRACTION 16
178#define VACUUM_TRUNCATE_LOCK_CHECK_INTERVAL 20
179#define VACUUM_TRUNCATE_LOCK_WAIT_INTERVAL 50
180#define VACUUM_TRUNCATE_LOCK_TIMEOUT 5000
186#define BYPASS_THRESHOLD_PAGES 0.02
192#define FAILSAFE_EVERY_PAGES \
193 ((BlockNumber) (((uint64) 4 * 1024 * 1024 * 1024) / BLCKSZ))
201#define VACUUM_FSM_EVERY_PAGES \
202 ((BlockNumber) (((uint64) 8 * 1024 * 1024 * 1024) / BLCKSZ))
208#define SKIP_PAGES_THRESHOLD ((BlockNumber) 32)
214#define PREFETCH_SIZE ((BlockNumber) 32)
220#define ParallelVacuumIsActive(vacrel) ((vacrel)->pvs != NULL)
240#define MAX_EAGER_FREEZE_SUCCESS_RATE 0.2
249#define EAGER_SCAN_REGION_SIZE 4096
255#define VAC_BLK_WAS_EAGER_SCANNED (1 << 0)
256#define VAC_BLK_ALL_VISIBLE_ACCORDING_TO_VM (1 << 1)
427 void *callback_private_data,
428 void *per_buffer_data);
432 bool sharelock,
Buffer vmbuffer);
435 Buffer vmbuffer,
bool all_visible_according_to_vm,
436 bool *has_lpdead_items,
bool *vm_page_frozen);
439 bool *has_lpdead_items);
445 int num_offsets,
Buffer vmbuffer);
455 bool estimated_count,
460 bool *lock_waiter_detected);
467#ifdef USE_ASSERT_CHECKING
505 float first_region_ratio;
506 bool oldest_unfrozen_before_cutoff =
false;
558 oldest_unfrozen_before_cutoff =
true;
560 if (!oldest_unfrozen_before_cutoff &&
564 oldest_unfrozen_before_cutoff =
true;
566 if (!oldest_unfrozen_before_cutoff)
579 (allvisible - allfrozen));
647 char **indnames = NULL;
688 errcallback.
arg = vacrel;
697 if (instrument && vacrel->
nindexes > 0)
827 (
errmsg(
"aggressively vacuuming \"%s.%s.%s\"",
832 (
errmsg(
"vacuuming \"%s.%s.%s\"",
916 if (new_rel_allvisible > new_rel_pages)
917 new_rel_allvisible = new_rel_pages;
924 if (new_rel_allfrozen > new_rel_allvisible)
925 new_rel_allfrozen = new_rel_allvisible;
935 new_rel_allvisible, new_rel_allfrozen,
938 &frozenxid_updated, &minmulti_updated,
false);
973 double read_rate = 0,
975 int64 total_blks_hit;
976 int64 total_blks_read;
977 int64 total_blks_dirtied;
980 memset(&walusage, 0,
sizeof(
WalUsage));
1000 msgfmt =
_(
"finished vacuuming \"%s.%s.%s\": index scans: %d\n");
1011 msgfmt =
_(
"automatic aggressive vacuum to prevent wraparound of table \"%s.%s.%s\": index scans: %d\n");
1013 msgfmt =
_(
"automatic vacuum to prevent wraparound of table \"%s.%s.%s\": index scans: %d\n");
1018 msgfmt =
_(
"automatic aggressive vacuum of table \"%s.%s.%s\": index scans: %d\n");
1020 msgfmt =
_(
"automatic vacuum of table \"%s.%s.%s\": index scans: %d\n");
1027 appendStringInfo(&
buf,
_(
"pages: %u removed, %u remain, %u scanned (%.2f%% of total), %u eagerly scanned\n"),
1031 orig_rel_pages == 0 ? 100.0 :
1036 _(
"tuples: %" PRId64
" removed, %" PRId64
" remain, %" PRId64
" are dead but not yet removable\n"),
1042 _(
"tuples missed: %" PRId64
" dead from %u pages not removed due to cleanup lock contention\n"),
1048 _(
"removable cutoff: %u, which was %d XIDs old when operation ended\n"),
1050 if (frozenxid_updated)
1055 _(
"new relfrozenxid: %u, which is %d XIDs ahead of previous value\n"),
1058 if (minmulti_updated)
1063 _(
"new relminmxid: %u, which is %d MXIDs ahead of previous value\n"),
1066 appendStringInfo(&
buf,
_(
"frozen: %u pages from table (%.2f%% of total) had %" PRId64
" tuples frozen\n"),
1068 orig_rel_pages == 0 ? 100.0 :
1074 _(
"visibility map: %u pages set all-visible, %u pages set all-frozen (%u were all-visible)\n"),
1086 msgfmt =
_(
"%u pages from table (%.2f%% of total) had %" PRId64
" dead item identifiers removed\n");
1095 msgfmt =
_(
"%u pages from table (%.2f%% of total) have %" PRId64
" dead item identifiers\n");
1099 orig_rel_pages == 0 ? 100.0 :
1110 _(
"index \"%s\": pages: %u in total, %u newly deleted, %u currently deleted, %u reusable\n"),
1136 if (secs_dur > 0 || usecs_dur > 0)
1138 read_rate = (double) BLCKSZ * total_blks_read /
1139 (1024 * 1024) / (secs_dur + usecs_dur / 1000000.0);
1140 write_rate = (double) BLCKSZ * total_blks_dirtied /
1141 (1024 * 1024) / (secs_dur + usecs_dur / 1000000.0);
1144 read_rate, write_rate);
1146 _(
"buffer usage: %" PRId64
" hits, %" PRId64
" reads, %" PRId64
" dirtied\n"),
1149 total_blks_dirtied);
1151 _(
"WAL usage: %" PRId64
" records, %" PRId64
" full page images, %" PRIu64
" bytes, %" PRIu64
" full page image bytes, %" PRId64
" buffers full\n"),
1218 next_fsm_block_to_vacuum = 0;
1222 const int initprog_index[] = {
1227 int64 initprog_val[3];
1231 initprog_val[1] = rel_pages;
1262 bool has_lpdead_items;
1263 void *per_buffer_data = NULL;
1264 bool vm_page_frozen =
false;
1265 bool got_cleanup_lock =
false;
1316 next_fsm_block_to_vacuum = blkno;
1329 blk_info = *((
uint8 *) per_buffer_data);
1358 if (!got_cleanup_lock)
1377 if (!got_cleanup_lock &&
1387 got_cleanup_lock =
true;
1403 if (got_cleanup_lock)
1407 &has_lpdead_items, &vm_page_frozen);
1423 if (got_cleanup_lock &&
1445 (
errmsg(
"disabling eager scanning after freezing %u eagerly scanned blocks of relation \"%s.%s.%s\"",
1446 orig_eager_scan_success_limit,
1485 || !has_lpdead_items)
1498 if (got_cleanup_lock && vacrel->
nindexes == 0 && ndeleted > 0 &&
1503 next_fsm_block_to_vacuum = blkno;
1549 if (rel_pages > next_fsm_block_to_vacuum)
1586 void *callback_private_data,
1587 void *per_buffer_data)
1646 if (next_block < vacrel->next_unskippable_block)
1655 *((
uint8 *) per_buffer_data) = blk_info;
1671 *((
uint8 *) per_buffer_data) = blk_info;
1695 bool next_unskippable_eager_scanned =
false;
1696 bool next_unskippable_allvis;
1698 *skipsallvis =
false;
1700 for (;; next_unskippable_block++)
1703 next_unskippable_block,
1704 &next_unskippable_vmbuffer);
1725 if (!next_unskippable_allvis)
1741 if (next_unskippable_block == rel_pages - 1)
1769 next_unskippable_eager_scanned =
true;
1777 *skipsallvis =
true;
1962 bool all_visible_according_to_vm,
1963 bool *has_lpdead_items,
1964 bool *vm_page_frozen)
2023#ifdef USE_ASSERT_CHECKING
2027 bool debug_all_frozen;
2031 if (!heap_page_is_all_visible(vacrel->
rel,
buf,
2033 &debug_cutoff, &vacrel->
offnum))
2084 if (!all_visible_according_to_vm && presult.
all_visible)
2125 *vm_page_frozen =
true;
2132 *vm_page_frozen =
true;
2147 errmsg(
"page is not marked all-visible but visibility map bit is set in relation \"%s\" page %u",
2172 errmsg(
"page containing LP_DEAD items is marked as all-visible in relation \"%s\" page %u",
2185 else if (all_visible_according_to_vm && presult.
all_frozen &&
2226 *vm_page_frozen =
true;
2236 *vm_page_frozen =
true;
2268 bool *has_lpdead_items)
2274 recently_dead_tuples,
2288 recently_dead_tuples = 0;
2289 missed_dead_tuples = 0;
2317 deadoffsets[lpdead_items++] = offnum;
2324 &NoFreezePageRelfrozenXid,
2325 &NoFreezePageRelminMxid))
2378 missed_dead_tuples++;
2385 recently_dead_tuples++;
2394 elog(
ERROR,
"unexpected HeapTupleSatisfiesVacuum result");
2413 if (lpdead_items > 0)
2424 missed_dead_tuples += lpdead_items;
2427 else if (lpdead_items > 0)
2447 if (missed_dead_tuples > 0)
2455 *has_lpdead_items = (lpdead_items > 0);
2602 bool allindexes =
true;
2603 double old_live_tuples = vacrel->
rel->
rd_rel->reltuples;
2604 const int progress_start_index[] = {
2608 const int progress_end_index[] = {
2613 int64 progress_start_val[2];
2614 int64 progress_end_val[3];
2632 progress_start_val[1] = vacrel->
nindexes;
2691 progress_end_val[0] = 0;
2692 progress_end_val[1] = 0;
2708 void *callback_private_data,
2709 void *per_buffer_data)
2715 if (iter_result == NULL)
2722 memcpy(per_buffer_data, iter_result,
sizeof(*iter_result));
2724 return iter_result->
blkno;
2819 num_offsets, vmbuffer);
2846 (
errmsg(
"table \"%s\": removed %" PRId64
" dead item identifiers in %u pages",
2895 deadoffsets, num_offsets,
2896 &all_frozen, &visibility_cutoff_xid,
2916 for (
int i = 0;
i < num_offsets;
i++)
2925 unused[nunused++] = toff;
2943 conflict_xid = visibility_cutoff_xid;
3002 const int progress_index[] = {
3006 int64 progress_val[2] = {0, 0};
3026 (
errmsg(
"bypassing nonessential maintenance of table \"%s.%s.%s\" as a failsafe after %d index scans",
3029 errdetail(
"The table's relfrozenxid or relminmxid is too far in the past."),
3030 errhint(
"Consider increasing configuration parameter \"maintenance_work_mem\" or \"autovacuum_work_mem\".\n"
3031 "You might also need to consider other ways for VACUUM to keep up with the allocation of transaction IDs.")));
3051 const int progress_start_index[] = {
3055 const int progress_end_index[] = {
3059 int64 progress_start_val[2];
3060 int64 progress_end_val[2] = {0, 0};
3070 progress_start_val[1] = vacrel->
nindexes;
3082 estimated_count, vacrel);
3121 ivinfo.
index = indrel;
3165 double reltuples,
bool estimated_count,
3171 ivinfo.
index = indrel;
3232 if (possibly_freeable > 0 &&
3248 bool lock_waiter_detected;
3271 lock_waiter_detected =
false;
3292 (
errmsg(
"\"%s\": stopping truncate due to conflicting lock request",
3300 WAIT_EVENT_VACUUM_TRUNCATE);
3310 if (new_rel_pages != orig_rel_pages)
3330 vacrel->
blkno = new_rel_pages;
3332 if (new_rel_pages >= orig_rel_pages)
3362 (
errmsg(
"table \"%s\": truncated %u to %u pages",
3364 orig_rel_pages, new_rel_pages)));
3365 orig_rel_pages = new_rel_pages;
3366 }
while (new_rel_pages > vacrel->
nonempty_pages && lock_waiter_detected);
3392 "prefetch size must be power of 2");
3410 if ((blkno % 32) == 0)
3416 elapsed = currenttime;
3424 (
errmsg(
"table \"%s\": suspending truncate due to conflicting lock request",
3427 *lock_waiter_detected =
true;
3430 starttime = currenttime;
3444 if (prefetchedUntil > blkno)
3450 for (pblkno = prefetchStart; pblkno <= blkno; pblkno++)
3455 prefetchedUntil = prefetchStart;
3543 (
errmsg(
"disabling parallel option of vacuum on \"%s\" --- cannot vacuum temporary tables in parallel",
3585 const int prog_index[2] = {
3639#ifdef USE_ASSERT_CHECKING
3658 visibility_cutoff_xid,
3706 bool all_visible =
true;
3707 int matched_dead_count = 0;
3712 Assert(ndeadoffsets == 0 || deadoffsets);
3714#ifdef USE_ASSERT_CHECKING
3716 if (ndeadoffsets > 1)
3718 for (
int i = 1;
i < ndeadoffsets;
i++)
3719 Assert(deadoffsets[
i - 1] < deadoffsets[
i]);
3725 offnum <= maxoff && all_visible;
3735 *logging_offnum = offnum;
3751 matched_dead_count >= ndeadoffsets ||
3752 deadoffsets[matched_dead_count] != offnum)
3754 *all_frozen = all_visible =
false;
3757 matched_dead_count++;
3778 all_visible =
false;
3779 *all_frozen =
false;
3790 all_visible =
false;
3791 *all_frozen =
false;
3798 *visibility_cutoff_xid = xmin;
3801 if (all_visible && *all_frozen &&
3803 *all_frozen =
false;
3812 all_visible =
false;
3813 *all_frozen =
false;
3817 elog(
ERROR,
"unexpected HeapTupleSatisfiesVacuum result");
3840 for (
int idx = 0;
idx < nindexes;
idx++)
3871 switch (errinfo->
phase)
3877 errcontext(
"while scanning block %u offset %u of relation \"%s.%s\"",
3880 errcontext(
"while scanning block %u of relation \"%s.%s\"",
3884 errcontext(
"while scanning relation \"%s.%s\"",
3892 errcontext(
"while vacuuming block %u offset %u of relation \"%s.%s\"",
3895 errcontext(
"while vacuuming block %u of relation \"%s.%s\"",
3899 errcontext(
"while vacuuming relation \"%s.%s\"",
3904 errcontext(
"while vacuuming index \"%s\" of relation \"%s.%s\"",
3909 errcontext(
"while cleaning up index \"%s\" of relation \"%s.%s\"",
3915 errcontext(
"while truncating relation \"%s.%s\" to %u blocks",
3941 vacrel->
blkno = blkno;
3943 vacrel->
phase = phase;
Datum idx(PG_FUNCTION_ARGS)
void TimestampDifference(TimestampTz start_time, TimestampTz stop_time, long *secs, int *microsecs)
bool TimestampDifferenceExceeds(TimestampTz start_time, TimestampTz stop_time, int msec)
TimestampTz GetCurrentTimestamp(void)
void pgstat_progress_start_command(ProgressCommandType cmdtype, Oid relid)
void pgstat_progress_update_param(int index, int64 val)
void pgstat_progress_update_multi_param(int nparam, const int *index, const int64 *val)
void pgstat_progress_end_command(void)
@ PROGRESS_COMMAND_VACUUM
PgBackendStatus * MyBEEntry
#define InvalidBlockNumber
static bool BlockNumberIsValid(BlockNumber blockNumber)
void CheckBufferIsPinnedOnce(Buffer buffer)
BlockNumber BufferGetBlockNumber(Buffer buffer)
PrefetchBufferResult PrefetchBuffer(Relation reln, ForkNumber forkNum, BlockNumber blockNum)
void ReleaseBuffer(Buffer buffer)
void UnlockReleaseBuffer(Buffer buffer)
void MarkBufferDirty(Buffer buffer)
void LockBufferForCleanup(Buffer buffer)
void LockBuffer(Buffer buffer, int mode)
Buffer ReadBufferExtended(Relation reln, ForkNumber forkNum, BlockNumber blockNum, ReadBufferMode mode, BufferAccessStrategy strategy)
bool ConditionalLockBufferForCleanup(Buffer buffer)
#define BUFFER_LOCK_UNLOCK
#define BUFFER_LOCK_SHARE
#define RelationGetNumberOfBlocks(reln)
static Page BufferGetPage(Buffer buffer)
#define BUFFER_LOCK_EXCLUSIVE
static bool BufferIsValid(Buffer bufnum)
Size PageGetHeapFreeSpace(const PageData *page)
void PageTruncateLinePointerArray(Page page)
static bool PageIsEmpty(const PageData *page)
static bool PageIsAllVisible(const PageData *page)
static void PageClearAllVisible(Page page)
static void * PageGetItem(const PageData *page, const ItemIdData *itemId)
static bool PageIsNew(const PageData *page)
#define SizeOfPageHeaderData
static void PageSetAllVisible(Page page)
static ItemId PageGetItemId(Page page, OffsetNumber offsetNumber)
static XLogRecPtr PageGetLSN(const PageData *page)
static OffsetNumber PageGetMaxOffsetNumber(const PageData *page)
TransactionId MultiXactId
#define StaticAssertStmt(condition, errmessage)
int errmsg_internal(const char *fmt,...)
int errdetail(const char *fmt,...)
ErrorContextCallback * error_context_stack
int errhint(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
void FreeSpaceMapVacuumRange(Relation rel, BlockNumber start, BlockNumber end)
Size GetRecordedFreeSpace(Relation rel, BlockNumber heapBlk)
void RecordPageWithFreeSpace(Relation rel, BlockNumber heapBlk, Size spaceAvail)
volatile uint32 CritSectionCount
Assert(PointerIsAligned(start, uint64))
bool heap_tuple_needs_eventual_freeze(HeapTupleHeader tuple)
bool heap_tuple_should_freeze(HeapTupleHeader tuple, const struct VacuumCutoffs *cutoffs, TransactionId *NoFreezePageRelfrozenXid, MultiXactId *NoFreezePageRelminMxid)
#define HEAP_PAGE_PRUNE_FREEZE
@ HEAPTUPLE_RECENTLY_DEAD
@ HEAPTUPLE_INSERT_IN_PROGRESS
@ HEAPTUPLE_DELETE_IN_PROGRESS
#define HEAP_PAGE_PRUNE_MARK_UNUSED_NOW
HTSV_Result HeapTupleSatisfiesVacuum(HeapTuple htup, TransactionId OldestXmin, Buffer buffer)
HeapTupleHeaderData * HeapTupleHeader
static TransactionId HeapTupleHeaderGetXmin(const HeapTupleHeaderData *tup)
#define MaxHeapTuplesPerPage
static bool HeapTupleHeaderXminCommitted(const HeapTupleHeaderData *tup)
#define INSTR_TIME_SET_CURRENT(t)
#define INSTR_TIME_SUBTRACT(x, y)
#define INSTR_TIME_GET_MICROSEC(t)
void WalUsageAccumDiff(WalUsage *dst, const WalUsage *add, const WalUsage *sub)
BufferUsage pgBufferUsage
void BufferUsageAccumDiff(BufferUsage *dst, const BufferUsage *add, const BufferUsage *sub)
static int pg_cmp_u16(uint16 a, uint16 b)
#define ItemIdGetLength(itemId)
#define ItemIdIsNormal(itemId)
#define ItemIdIsDead(itemId)
#define ItemIdIsUsed(itemId)
#define ItemIdSetUnused(itemId)
#define ItemIdIsRedirected(itemId)
#define ItemIdHasStorage(itemId)
static void ItemPointerSet(ItemPointerData *pointer, BlockNumber blockNumber, OffsetNumber offNum)
void ResetLatch(Latch *latch)
int WaitLatch(Latch *latch, int wakeEvents, long timeout, uint32 wait_event_info)
void UnlockRelation(Relation relation, LOCKMODE lockmode)
bool ConditionalLockRelation(Relation relation, LOCKMODE lockmode)
bool LockHasWaitersRelation(Relation relation, LOCKMODE lockmode)
#define AccessExclusiveLock
char * get_database_name(Oid dbid)
char * get_namespace_name(Oid nspid)
char * pstrdup(const char *in)
void pfree(void *pointer)
void * palloc0(Size size)
#define AmAutoVacuumWorkerProcess()
#define START_CRIT_SECTION()
#define CHECK_FOR_INTERRUPTS()
#define END_CRIT_SECTION()
bool MultiXactIdPrecedes(MultiXactId multi1, MultiXactId multi2)
bool MultiXactIdPrecedesOrEquals(MultiXactId multi1, MultiXactId multi2)
#define MultiXactIdIsValid(multi)
#define InvalidMultiXactId
#define InvalidOffsetNumber
#define OffsetNumberIsValid(offsetNumber)
#define OffsetNumberNext(offsetNumber)
#define FirstOffsetNumber
#define ERRCODE_DATA_CORRUPTED
uint32 pg_prng_uint32(pg_prng_state *state)
pg_prng_state pg_global_prng_state
const char * pg_rusage_show(const PGRUsage *ru0)
void pg_rusage_init(PGRUsage *ru0)
PgStat_Counter pgStatBlockReadTime
PgStat_Counter pgStatBlockWriteTime
void pgstat_report_vacuum(Oid tableoid, bool shared, PgStat_Counter livetuples, PgStat_Counter deadtuples, TimestampTz starttime)
#define qsort(a, b, c, d)
GlobalVisState * GlobalVisTestFor(Relation rel)
#define PROGRESS_VACUUM_PHASE_FINAL_CLEANUP
#define PROGRESS_VACUUM_DEAD_TUPLE_BYTES
#define PROGRESS_VACUUM_PHASE_SCAN_HEAP
#define PROGRESS_VACUUM_TOTAL_HEAP_BLKS
#define PROGRESS_VACUUM_PHASE
#define PROGRESS_VACUUM_DELAY_TIME
#define PROGRESS_VACUUM_NUM_INDEX_VACUUMS
#define PROGRESS_VACUUM_PHASE_VACUUM_HEAP
#define PROGRESS_VACUUM_NUM_DEAD_ITEM_IDS
#define PROGRESS_VACUUM_MAX_DEAD_TUPLE_BYTES
#define PROGRESS_VACUUM_HEAP_BLKS_SCANNED
#define PROGRESS_VACUUM_PHASE_INDEX_CLEANUP
#define PROGRESS_VACUUM_PHASE_VACUUM_INDEX
#define PROGRESS_VACUUM_INDEXES_PROCESSED
#define PROGRESS_VACUUM_INDEXES_TOTAL
#define PROGRESS_VACUUM_HEAP_BLKS_VACUUMED
#define PROGRESS_VACUUM_PHASE_TRUNCATE
void heap_page_prune_and_freeze(PruneFreezeParams *params, PruneFreezeResult *presult, OffsetNumber *off_loc, TransactionId *new_relfrozen_xid, MultiXactId *new_relmin_mxid)
void log_heap_prune_and_freeze(Relation relation, Buffer buffer, Buffer vmbuffer, uint8 vmflags, TransactionId conflict_xid, bool cleanup_lock, PruneReason reason, HeapTupleFreeze *frozen, int nfrozen, OffsetNumber *redirected, int nredirected, OffsetNumber *dead, int ndead, OffsetNumber *unused, int nunused)
Buffer read_stream_next_buffer(ReadStream *stream, void **per_buffer_data)
ReadStream * read_stream_begin_relation(int flags, BufferAccessStrategy strategy, Relation rel, ForkNumber forknum, ReadStreamBlockNumberCB callback, void *callback_private_data, size_t per_buffer_data_size)
void read_stream_end(ReadStream *stream)
#define READ_STREAM_MAINTENANCE
#define READ_STREAM_USE_BATCHING
#define RelationGetRelid(relation)
#define RelationGetRelationName(relation)
#define RelationNeedsWAL(relation)
#define RelationUsesLocalBuffers(relation)
#define RelationGetNamespace(relation)
void RelationTruncate(Relation rel, BlockNumber nblocks)
void appendStringInfo(StringInfo str, const char *fmt,...)
void appendStringInfoString(StringInfo str, const char *s)
void initStringInfo(StringInfo str)
int64 shared_blks_dirtied
struct ErrorContextCallback * previous
void(* callback)(void *arg)
BlockNumber pages_deleted
BlockNumber pages_newly_deleted
BufferAccessStrategy strategy
BlockNumber next_eager_scan_region_start
ParallelVacuumState * pvs
bool next_unskippable_eager_scanned
VacDeadItemsInfo * dead_items_info
BlockNumber vm_new_frozen_pages
Buffer next_unskippable_vmbuffer
BlockNumber nonempty_pages
BlockNumber eager_scan_remaining_fails
BlockNumber scanned_pages
BlockNumber new_frozen_tuple_pages
BlockNumber removed_pages
IndexBulkDeleteResult ** indstats
TransactionId NewRelfrozenXid
bool consider_bypass_optimization
BlockNumber next_unskippable_block
int64 recently_dead_tuples
BlockNumber missed_dead_pages
BlockNumber current_block
BufferAccessStrategy bstrategy
BlockNumber eager_scan_remaining_successes
BlockNumber lpdead_item_pages
BlockNumber eager_scanned_pages
MultiXactId NewRelminMxid
struct VacuumCutoffs cutoffs
bool next_unskippable_allvis
BlockNumber vm_new_visible_pages
BlockNumber eager_scan_max_fails_per_region
BlockNumber vm_new_visible_frozen_pages
int64 st_progress_param[PGSTAT_NUM_PROGRESS_PARAM]
TransactionId vm_conflict_horizon
OffsetNumber deadoffsets[MaxHeapTuplesPerPage]
RelFileLocator rd_locator
TransactionId FreezeLimit
TransactionId relfrozenxid
MultiXactId MultiXactCutoff
int log_vacuum_min_duration
VacOptValue index_cleanup
double max_eager_freeze_failure_rate
TidStoreIter * TidStoreBeginIterate(TidStore *ts)
void TidStoreEndIterate(TidStoreIter *iter)
TidStoreIterResult * TidStoreIterateNext(TidStoreIter *iter)
TidStore * TidStoreCreateLocal(size_t max_bytes, bool insert_only)
void TidStoreDestroy(TidStore *ts)
int TidStoreGetBlockOffsets(TidStoreIterResult *result, OffsetNumber *offsets, int max_offsets)
void TidStoreSetBlockOffsets(TidStore *ts, BlockNumber blkno, OffsetNumber *offsets, int num_offsets)
size_t TidStoreMemoryUsage(TidStore *ts)
static bool TransactionIdFollows(TransactionId id1, TransactionId id2)
static TransactionId ReadNextTransactionId(void)
#define InvalidTransactionId
static bool TransactionIdPrecedesOrEquals(TransactionId id1, TransactionId id2)
#define TransactionIdIsValid(xid)
#define TransactionIdIsNormal(xid)
static bool TransactionIdPrecedes(TransactionId id1, TransactionId id2)
bool track_cost_delay_timing
void vac_open_indexes(Relation relation, LOCKMODE lockmode, int *nindexes, Relation **Irel)
IndexBulkDeleteResult * vac_cleanup_one_index(IndexVacuumInfo *ivinfo, IndexBulkDeleteResult *istat)
void vac_close_indexes(int nindexes, Relation *Irel, LOCKMODE lockmode)
void vacuum_delay_point(bool is_analyze)
bool vacuum_xid_failsafe_check(const struct VacuumCutoffs *cutoffs)
bool VacuumFailsafeActive
double vac_estimate_reltuples(Relation relation, BlockNumber total_pages, BlockNumber scanned_pages, double scanned_tuples)
void vac_update_relstats(Relation relation, BlockNumber num_pages, double num_tuples, BlockNumber num_all_visible_pages, BlockNumber num_all_frozen_pages, bool hasindex, TransactionId frozenxid, MultiXactId minmulti, bool *frozenxid_updated, bool *minmulti_updated, bool in_outer_xact)
bool vacuum_get_cutoffs(Relation rel, const VacuumParams params, struct VacuumCutoffs *cutoffs)
IndexBulkDeleteResult * vac_bulkdel_one_index(IndexVacuumInfo *ivinfo, IndexBulkDeleteResult *istat, TidStore *dead_items, VacDeadItemsInfo *dead_items_info)
@ VACOPTVALUE_UNSPECIFIED
#define VACOPT_DISABLE_PAGE_SKIPPING
static void dead_items_cleanup(LVRelState *vacrel)
#define VAC_BLK_WAS_EAGER_SCANNED
static void update_relstats_all_indexes(LVRelState *vacrel)
static void dead_items_add(LVRelState *vacrel, BlockNumber blkno, OffsetNumber *offsets, int num_offsets)
static int lazy_scan_prune(LVRelState *vacrel, Buffer buf, BlockNumber blkno, Page page, Buffer vmbuffer, bool all_visible_according_to_vm, bool *has_lpdead_items, bool *vm_page_frozen)
void heap_vacuum_rel(Relation rel, const VacuumParams params, BufferAccessStrategy bstrategy)
static BlockNumber heap_vac_scan_next_block(ReadStream *stream, void *callback_private_data, void *per_buffer_data)
static void heap_vacuum_eager_scan_setup(LVRelState *vacrel, const VacuumParams params)
#define VACUUM_TRUNCATE_LOCK_WAIT_INTERVAL
static void vacuum_error_callback(void *arg)
static bool heap_page_would_be_all_visible(Relation rel, Buffer buf, TransactionId OldestXmin, OffsetNumber *deadoffsets, int ndeadoffsets, bool *all_frozen, TransactionId *visibility_cutoff_xid, OffsetNumber *logging_offnum)
#define EAGER_SCAN_REGION_SIZE
static void lazy_truncate_heap(LVRelState *vacrel)
static void lazy_vacuum(LVRelState *vacrel)
static void lazy_cleanup_all_indexes(LVRelState *vacrel)
#define MAX_EAGER_FREEZE_SUCCESS_RATE
static bool lazy_scan_noprune(LVRelState *vacrel, Buffer buf, BlockNumber blkno, Page page, bool *has_lpdead_items)
static BlockNumber vacuum_reap_lp_read_stream_next(ReadStream *stream, void *callback_private_data, void *per_buffer_data)
#define REL_TRUNCATE_MINIMUM
static bool should_attempt_truncation(LVRelState *vacrel)
static bool lazy_scan_new_or_empty(LVRelState *vacrel, Buffer buf, BlockNumber blkno, Page page, bool sharelock, Buffer vmbuffer)
@ VACUUM_ERRCB_PHASE_SCAN_HEAP
@ VACUUM_ERRCB_PHASE_VACUUM_INDEX
@ VACUUM_ERRCB_PHASE_TRUNCATE
@ VACUUM_ERRCB_PHASE_INDEX_CLEANUP
@ VACUUM_ERRCB_PHASE_VACUUM_HEAP
@ VACUUM_ERRCB_PHASE_UNKNOWN
static void lazy_scan_heap(LVRelState *vacrel)
#define ParallelVacuumIsActive(vacrel)
static void restore_vacuum_error_info(LVRelState *vacrel, const LVSavedErrInfo *saved_vacrel)
static IndexBulkDeleteResult * lazy_vacuum_one_index(Relation indrel, IndexBulkDeleteResult *istat, double reltuples, LVRelState *vacrel)
static void find_next_unskippable_block(LVRelState *vacrel, bool *skipsallvis)
static void dead_items_reset(LVRelState *vacrel)
#define REL_TRUNCATE_FRACTION
static bool lazy_check_wraparound_failsafe(LVRelState *vacrel)
struct LVSavedErrInfo LVSavedErrInfo
static IndexBulkDeleteResult * lazy_cleanup_one_index(Relation indrel, IndexBulkDeleteResult *istat, double reltuples, bool estimated_count, LVRelState *vacrel)
static void lazy_vacuum_heap_page(LVRelState *vacrel, BlockNumber blkno, Buffer buffer, OffsetNumber *deadoffsets, int num_offsets, Buffer vmbuffer)
struct LVRelState LVRelState
#define BYPASS_THRESHOLD_PAGES
static void dead_items_alloc(LVRelState *vacrel, int nworkers)
#define VACUUM_TRUNCATE_LOCK_TIMEOUT
static bool lazy_vacuum_all_indexes(LVRelState *vacrel)
static void update_vacuum_error_info(LVRelState *vacrel, LVSavedErrInfo *saved_vacrel, int phase, BlockNumber blkno, OffsetNumber offnum)
static BlockNumber count_nondeletable_pages(LVRelState *vacrel, bool *lock_waiter_detected)
#define VAC_BLK_ALL_VISIBLE_ACCORDING_TO_VM
#define SKIP_PAGES_THRESHOLD
#define FAILSAFE_EVERY_PAGES
#define VACUUM_TRUNCATE_LOCK_CHECK_INTERVAL
static int cmpOffsetNumbers(const void *a, const void *b)
static void lazy_vacuum_heap_rel(LVRelState *vacrel)
#define VACUUM_FSM_EVERY_PAGES
TidStore * parallel_vacuum_get_dead_items(ParallelVacuumState *pvs, VacDeadItemsInfo **dead_items_info_p)
ParallelVacuumState * parallel_vacuum_init(Relation rel, Relation *indrels, int nindexes, int nrequested_workers, int vac_work_mem, int elevel, BufferAccessStrategy bstrategy)
void parallel_vacuum_bulkdel_all_indexes(ParallelVacuumState *pvs, long num_table_tuples, int num_index_scans)
void parallel_vacuum_reset_dead_items(ParallelVacuumState *pvs)
void parallel_vacuum_cleanup_all_indexes(ParallelVacuumState *pvs, long num_table_tuples, int num_index_scans, bool estimated_count)
void parallel_vacuum_end(ParallelVacuumState *pvs, IndexBulkDeleteResult **istats)
bool visibilitymap_clear(Relation rel, BlockNumber heapBlk, Buffer vmbuf, uint8 flags)
void visibilitymap_pin(Relation rel, BlockNumber heapBlk, Buffer *vmbuf)
uint8 visibilitymap_get_status(Relation rel, BlockNumber heapBlk, Buffer *vmbuf)
uint8 visibilitymap_set_vmbits(BlockNumber heapBlk, Buffer vmBuf, uint8 flags, const RelFileLocator rlocator)
void visibilitymap_count(Relation rel, BlockNumber *all_visible, BlockNumber *all_frozen)
uint8 visibilitymap_set(Relation rel, BlockNumber heapBlk, Buffer heapBuf, XLogRecPtr recptr, Buffer vmBuf, TransactionId cutoff_xid, uint8 flags)
#define VM_ALL_FROZEN(r, b, v)
#define VISIBILITYMAP_VALID_BITS
#define VISIBILITYMAP_ALL_FROZEN
#define VISIBILITYMAP_ALL_VISIBLE
#define WL_EXIT_ON_PM_DEATH
bool IsInParallelMode(void)
#define XLogRecPtrIsValid(r)
#define InvalidXLogRecPtr
XLogRecPtr log_newpage_buffer(Buffer buffer, bool page_std)