70 #define REL_TRUNCATE_MINIMUM 1000
71 #define REL_TRUNCATE_FRACTION 16
80 #define VACUUM_TRUNCATE_LOCK_CHECK_INTERVAL 20
81 #define VACUUM_TRUNCATE_LOCK_WAIT_INTERVAL 50
82 #define VACUUM_TRUNCATE_LOCK_TIMEOUT 5000
88 #define BYPASS_THRESHOLD_PAGES 0.02
94 #define FAILSAFE_EVERY_PAGES \
95 ((BlockNumber) (((uint64) 4 * 1024 * 1024 * 1024) / BLCKSZ))
103 #define VACUUM_FSM_EVERY_PAGES \
104 ((BlockNumber) (((uint64) 8 * 1024 * 1024 * 1024) / BLCKSZ))
110 #define SKIP_PAGES_THRESHOLD ((BlockNumber) 32)
116 #define PREFETCH_SIZE ((BlockNumber) 32)
122 #define ParallelVacuumIsActive(vacrel) ((vacrel)->pvs != NULL)
227 bool *all_visible_according_to_vm);
231 bool sharelock,
Buffer vmbuffer);
234 Buffer vmbuffer,
bool all_visible_according_to_vm,
235 bool *has_lpdead_items);
238 bool *has_lpdead_items);
253 bool estimated_count,
258 bool *lock_waiter_detected);
306 char **indnames = NULL;
345 errcallback.
arg = vacrel;
354 if (instrument && vacrel->
nindexes > 0)
464 (
errmsg(
"aggressively vacuuming \"%s.%s.%s\"",
469 (
errmsg(
"vacuuming \"%s.%s.%s\"",
553 if (new_rel_allvisible > new_rel_pages)
554 new_rel_allvisible = new_rel_pages;
564 new_rel_allvisible, vacrel->
nindexes > 0,
566 &frozenxid_updated, &minmulti_updated,
false);
602 double read_rate = 0,
606 memset(&walusage, 0,
sizeof(
WalUsage));
617 msgfmt =
_(
"finished vacuuming \"%s.%s.%s\": index scans: %d\n");
628 msgfmt =
_(
"automatic aggressive vacuum to prevent wraparound of table \"%s.%s.%s\": index scans: %d\n");
630 msgfmt =
_(
"automatic vacuum to prevent wraparound of table \"%s.%s.%s\": index scans: %d\n");
635 msgfmt =
_(
"automatic aggressive vacuum of table \"%s.%s.%s\": index scans: %d\n");
637 msgfmt =
_(
"automatic vacuum of table \"%s.%s.%s\": index scans: %d\n");
648 orig_rel_pages == 0 ? 100.0 :
651 _(
"tuples: %lld removed, %lld remain, %lld are dead but not yet removable\n"),
657 _(
"tuples missed: %lld dead from %u pages not removed due to cleanup lock contention\n"),
663 _(
"removable cutoff: %u, which was %d XIDs old when operation ended\n"),
665 if (frozenxid_updated)
670 _(
"new relfrozenxid: %u, which is %d XIDs ahead of previous value\n"),
673 if (minmulti_updated)
678 _(
"new relminmxid: %u, which is %d MXIDs ahead of previous value\n"),
681 appendStringInfo(&
buf,
_(
"frozen: %u pages from table (%.2f%% of total) had %lld tuples frozen\n"),
683 orig_rel_pages == 0 ? 100.0 :
693 msgfmt =
_(
"%u pages from table (%.2f%% of total) had %lld dead item identifiers removed\n");
702 msgfmt =
_(
"%u pages from table (%.2f%% of total) have %lld dead item identifiers\n");
706 orig_rel_pages == 0 ? 100.0 :
717 _(
"index \"%s\": pages: %u in total, %u newly deleted, %u currently deleted, %u reusable\n"),
732 if (secs_dur > 0 || usecs_dur > 0)
734 read_rate = (double) BLCKSZ * PageMissOp / (1024 * 1024) /
735 (secs_dur + usecs_dur / 1000000.0);
736 write_rate = (double) BLCKSZ * PageDirtyOp / (1024 * 1024) /
737 (secs_dur + usecs_dur / 1000000.0);
740 read_rate, write_rate);
742 _(
"buffer usage: %lld hits, %lld misses, %lld dirtied\n"),
743 (
long long) PageHitOp,
744 (
long long) PageMissOp,
745 (
long long) PageDirtyOp);
747 _(
"WAL usage: %lld records, %lld full page images, %llu bytes\n"),
750 (
unsigned long long) walusage.
wal_bytes);
811 next_fsm_block_to_vacuum = 0;
812 bool all_visible_according_to_vm;
816 const int initprog_index[] = {
821 int64 initprog_val[3];
825 initprog_val[1] = rel_pages;
839 bool has_lpdead_items;
840 bool got_cleanup_lock =
false;
894 next_fsm_block_to_vacuum = blkno;
920 if (!got_cleanup_lock)
939 if (!got_cleanup_lock &&
949 got_cleanup_lock =
true;
965 if (got_cleanup_lock)
967 vmbuffer, all_visible_according_to_vm,
991 || !has_lpdead_items)
1004 if (got_cleanup_lock && vacrel->
nindexes == 0 && has_lpdead_items &&
1009 next_fsm_block_to_vacuum = blkno;
1047 if (blkno > next_fsm_block_to_vacuum)
1078 bool *all_visible_according_to_vm)
1136 if (next_block < vacrel->next_unskippable_block)
1144 *all_visible_according_to_vm =
true;
1180 bool next_unskippable_allvis;
1182 *skipsallvis =
false;
1187 next_unskippable_block,
1188 &next_unskippable_vmbuffer);
1196 if (!next_unskippable_allvis)
1212 if (next_unskippable_block == rel_pages - 1)
1233 *skipsallvis =
true;
1236 next_unskippable_block++;
1411 bool all_visible_according_to_vm,
1412 bool *has_lpdead_items)
1422 recently_dead_tuples;
1424 bool hastup =
false;
1450 recently_dead_tuples = 0;
1465 &presult, &vacrel->
offnum);
1489 bool totally_frozen;
1525 deadoffsets[lpdead_items++] = offnum;
1576 all_visible =
false;
1588 all_visible =
false;
1595 visibility_cutoff_xid = xmin;
1605 recently_dead_tuples++;
1606 all_visible =
false;
1617 all_visible =
false;
1621 all_visible =
false;
1631 elog(
ERROR,
"unexpected HeapTupleSatisfiesVacuum result");
1639 &frozen[tuples_frozen], &totally_frozen))
1642 frozen[tuples_frozen++].
offset = offnum;
1650 if (!totally_frozen)
1669 (all_visible && all_frozen &&
1679 if (tuples_frozen == 0)
1707 if (all_visible && all_frozen)
1710 snapshotConflictHorizon = visibility_cutoff_xid;
1722 snapshotConflictHorizon,
1723 frozen, tuples_frozen);
1745 #ifdef USE_ASSERT_CHECKING
1747 if (all_visible && lpdead_items == 0)
1750 bool debug_all_frozen;
1753 &debug_cutoff, &debug_all_frozen))
1757 debug_cutoff == visibility_cutoff_xid);
1764 if (lpdead_items > 0)
1773 for (
int i = 0;
i < lpdead_items;
i++)
1794 all_visible =
false;
1809 *has_lpdead_items = (lpdead_items > 0);
1811 Assert(!all_visible || !(*has_lpdead_items));
1818 if (!all_visible_according_to_vm && all_visible)
1844 vmbuffer, visibility_cutoff_xid,
1857 elog(
WARNING,
"page is not marked all-visible but visibility map bit is set in relation \"%s\" page %u",
1879 elog(
WARNING,
"page containing LP_DEAD items is marked as all-visible in relation \"%s\" page %u",
1892 else if (all_visible_according_to_vm && all_visible &&
1946 bool *has_lpdead_items)
1952 recently_dead_tuples,
1966 recently_dead_tuples = 0;
1967 missed_dead_tuples = 0;
1995 deadoffsets[lpdead_items++] = offnum;
2002 &NoFreezePageRelfrozenXid,
2003 &NoFreezePageRelminMxid))
2056 missed_dead_tuples++;
2063 recently_dead_tuples++;
2072 elog(
ERROR,
"unexpected HeapTupleSatisfiesVacuum result");
2091 if (lpdead_items > 0)
2102 missed_dead_tuples += lpdead_items;
2105 else if (lpdead_items > 0)
2119 for (
int i = 0;
i < lpdead_items;
i++)
2138 if (missed_dead_tuples > 0)
2146 *has_lpdead_items = (lpdead_items > 0);
2293 bool allindexes =
true;
2294 double old_live_tuples = vacrel->
rel->
rd_rel->reltuples;
2295 const int progress_start_index[] = {
2299 const int progress_end_index[] = {
2304 int64 progress_start_val[2];
2305 int64 progress_end_val[3];
2323 progress_start_val[1] = vacrel->
nindexes;
2382 progress_end_val[0] = 0;
2383 progress_end_val[1] = 0;
2439 vacrel->
blkno = blkno;
2477 (
errmsg(
"table \"%s\": removed %lld dead item identifiers in %u pages",
2533 unused[nunused++] = toff;
2593 vmbuffer, visibility_cutoff_xid, flags);
2622 const int progress_index[] = {
2626 int64 progress_val[2] = {0, 0};
2646 (
errmsg(
"bypassing nonessential maintenance of table \"%s.%s.%s\" as a failsafe after %d index scans",
2649 errdetail(
"The table's relfrozenxid or relminmxid is too far in the past."),
2650 errhint(
"Consider increasing configuration parameter maintenance_work_mem or autovacuum_work_mem.\n"
2651 "You might also need to consider other ways for VACUUM to keep up with the allocation of transaction IDs.")));
2671 const int progress_start_index[] = {
2675 const int progress_end_index[] = {
2679 int64 progress_start_val[2];
2680 int64 progress_end_val[2] = {0, 0};
2690 progress_start_val[1] = vacrel->
nindexes;
2702 estimated_count, vacrel);
2741 ivinfo.
index = indrel;
2784 double reltuples,
bool estimated_count,
2790 ivinfo.
index = indrel;
2851 if (possibly_freeable > 0 &&
2867 bool lock_waiter_detected;
2890 lock_waiter_detected =
false;
2911 (
errmsg(
"\"%s\": stopping truncate due to conflicting lock request",
2919 WAIT_EVENT_VACUUM_TRUNCATE);
2929 if (new_rel_pages != orig_rel_pages)
2949 vacrel->
blkno = new_rel_pages;
2951 if (new_rel_pages >= orig_rel_pages)
2981 (
errmsg(
"table \"%s\": truncated %u to %u pages",
2983 orig_rel_pages, new_rel_pages)));
2984 orig_rel_pages = new_rel_pages;
2985 }
while (new_rel_pages > vacrel->
nonempty_pages && lock_waiter_detected);
3011 "prefetch size must be power of 2");
3029 if ((blkno % 32) == 0)
3035 elapsed = currenttime;
3043 (
errmsg(
"table \"%s\": suspending truncate due to conflicting lock request",
3046 *lock_waiter_detected =
true;
3049 starttime = currenttime;
3063 if (prefetchedUntil > blkno)
3069 for (pblkno = prefetchStart; pblkno <= blkno; pblkno++)
3074 prefetchedUntil = prefetchStart;
3149 max_items =
Min(max_items, INT_MAX);
3165 return (
int) max_items;
3203 (
errmsg(
"disabling parallel option of vacuum on \"%s\" --- cannot vacuum temporary tables in parallel",
3266 bool all_visible =
true;
3273 offnum <= maxoff && all_visible;
3298 all_visible =
false;
3299 *all_frozen =
false;
3319 all_visible =
false;
3320 *all_frozen =
false;
3332 all_visible =
false;
3333 *all_frozen =
false;
3340 *visibility_cutoff_xid = xmin;
3343 if (all_visible && *all_frozen &&
3345 *all_frozen =
false;
3354 all_visible =
false;
3355 *all_frozen =
false;
3359 elog(
ERROR,
"unexpected HeapTupleSatisfiesVacuum result");
3382 for (
int idx = 0;
idx < nindexes;
idx++)
3413 switch (errinfo->
phase)
3419 errcontext(
"while scanning block %u offset %u of relation \"%s.%s\"",
3422 errcontext(
"while scanning block %u of relation \"%s.%s\"",
3426 errcontext(
"while scanning relation \"%s.%s\"",
3434 errcontext(
"while vacuuming block %u offset %u of relation \"%s.%s\"",
3437 errcontext(
"while vacuuming block %u of relation \"%s.%s\"",
3441 errcontext(
"while vacuuming relation \"%s.%s\"",
3446 errcontext(
"while vacuuming index \"%s\" of relation \"%s.%s\"",
3451 errcontext(
"while cleaning up index \"%s\" of relation \"%s.%s\"",
3457 errcontext(
"while truncating relation \"%s.%s\" to %u blocks",
3483 vacrel->
blkno = blkno;
3485 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
#define InvalidBlockNumber
static bool BlockNumberIsValid(BlockNumber blockNumber)
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(Page page)
void PageTruncateLinePointerArray(Page page)
static bool PageIsEmpty(Page page)
static Item PageGetItem(Page page, ItemId itemId)
static void PageClearAllVisible(Page page)
#define SizeOfPageHeaderData
static void PageSetAllVisible(Page page)
static ItemId PageGetItemId(Page page, OffsetNumber offsetNumber)
static bool PageIsNew(Page page)
static bool PageIsAllVisible(Page page)
static void PageSetLSN(Page page, XLogRecPtr lsn)
static XLogRecPtr PageGetLSN(Page page)
static OffsetNumber PageGetMaxOffsetNumber(Page page)
TransactionId MultiXactId
#define StaticAssertStmt(condition, errmessage)
char * get_database_name(Oid dbid)
int errmsg_internal(const char *fmt,...)
int errdetail(const char *fmt,...)
ErrorContextCallback * error_context_stack
int errhint(const char *fmt,...)
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)
bool heap_tuple_needs_eventual_freeze(HeapTupleHeader tuple)
bool heap_tuple_should_freeze(HeapTupleHeader tuple, const struct VacuumCutoffs *cutoffs, TransactionId *NoFreezePageRelfrozenXid, MultiXactId *NoFreezePageRelminMxid)
void heap_freeze_execute_prepared(Relation rel, Buffer buffer, TransactionId snapshotConflictHorizon, HeapTupleFreeze *tuples, int ntuples)
bool heap_prepare_freeze_tuple(HeapTupleHeader tuple, const struct VacuumCutoffs *cutoffs, HeapPageFreeze *pagefrz, HeapTupleFreeze *frz, bool *totally_frozen)
@ HEAPTUPLE_RECENTLY_DEAD
@ HEAPTUPLE_INSERT_IN_PROGRESS
@ HEAPTUPLE_DELETE_IN_PROGRESS
static HTSV_Result htsv_get_valid_status(int status)
HTSV_Result HeapTupleSatisfiesVacuum(HeapTuple htup, TransactionId OldestXmin, Buffer buffer)
#define XLOG_HEAP2_VACUUM
HeapTupleHeaderData * HeapTupleHeader
#define HeapTupleHeaderGetXmin(tup)
#define HeapTupleHeaderXminCommitted(tup)
#define MaxHeapTuplesPerPage
#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)
#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)
static void ItemPointerSetOffsetNumber(ItemPointerData *pointer, OffsetNumber offsetNumber)
static void ItemPointerSetBlockNumber(ItemPointerData *pointer, BlockNumber blockNumber)
static OffsetNumber ItemPointerGetOffsetNumber(const ItemPointerData *pointer)
static BlockNumber ItemPointerGetBlockNumber(const ItemPointerData *pointer)
void ResetLatch(Latch *latch)
int WaitLatch(Latch *latch, int wakeEvents, long timeout, uint32 wait_event_info)
#define WL_EXIT_ON_PM_DEATH
Assert(fmt[strlen(fmt) - 1] !='\n')
void UnlockRelation(Relation relation, LOCKMODE lockmode)
bool ConditionalLockRelation(Relation relation, LOCKMODE lockmode)
bool LockHasWaitersRelation(Relation relation, LOCKMODE lockmode)
#define AccessExclusiveLock
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 MultiXactIdPrecedesOrEquals(MultiXactId multi1, MultiXactId multi2)
#define InvalidMultiXactId
#define InvalidOffsetNumber
#define OffsetNumberIsValid(offsetNumber)
#define OffsetNumberNext(offsetNumber)
#define FirstOffsetNumber
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)
GlobalVisState * GlobalVisTestFor(Relation rel)
#define PROGRESS_VACUUM_PHASE_FINAL_CLEANUP
#define PROGRESS_VACUUM_PHASE_SCAN_HEAP
#define PROGRESS_VACUUM_TOTAL_HEAP_BLKS
#define PROGRESS_VACUUM_PHASE
#define PROGRESS_VACUUM_NUM_DEAD_TUPLES
#define PROGRESS_VACUUM_NUM_INDEX_VACUUMS
#define PROGRESS_VACUUM_PHASE_VACUUM_HEAP
#define PROGRESS_VACUUM_HEAP_BLKS_SCANNED
#define PROGRESS_VACUUM_PHASE_INDEX_CLEANUP
#define PROGRESS_VACUUM_PHASE_VACUUM_INDEX
#define PROGRESS_VACUUM_MAX_DEAD_TUPLES
#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(Relation relation, Buffer buffer, GlobalVisState *vistest, bool mark_unused_now, PruneResult *presult, OffsetNumber *off_loc)
#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)
struct ErrorContextCallback * previous
void(* callback)(void *arg)
MultiXactId NoFreezePageRelminMxid
TransactionId FreezePageRelfrozenXid
MultiXactId FreezePageRelminMxid
TransactionId NoFreezePageRelfrozenXid
BlockNumber pages_deleted
BlockNumber pages_newly_deleted
BufferAccessStrategy strategy
ParallelVacuumState * pvs
Buffer next_unskippable_vmbuffer
BlockNumber nonempty_pages
BlockNumber scanned_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 lpdead_item_pages
MultiXactId NewRelminMxid
struct VacuumCutoffs cutoffs
bool next_unskippable_allvis
VacDeadItems * dead_items
int8 htsv[MaxHeapTuplesPerPage+1]
ItemPointerData items[FLEXIBLE_ARRAY_MEMBER]
TransactionId FreezeLimit
TransactionId relfrozenxid
MultiXactId MultiXactCutoff
VacOptValue index_cleanup
bool TransactionIdPrecedes(TransactionId id1, TransactionId id2)
bool TransactionIdPrecedesOrEquals(TransactionId id1, TransactionId id2)
bool TransactionIdFollows(TransactionId id1, TransactionId id2)
static TransactionId ReadNextTransactionId(void)
#define TransactionIdRetreat(dest)
#define InvalidTransactionId
#define TransactionIdIsValid(xid)
#define TransactionIdIsNormal(xid)
IndexBulkDeleteResult * vac_bulkdel_one_index(IndexVacuumInfo *ivinfo, IndexBulkDeleteResult *istat, VacDeadItems *dead_items)
Size vac_max_items_to_alloc_size(int max_items)
void vac_open_indexes(Relation relation, LOCKMODE lockmode, int *nindexes, Relation **Irel)
void vac_update_relstats(Relation relation, BlockNumber num_pages, double num_tuples, BlockNumber num_all_visible_pages, bool hasindex, TransactionId frozenxid, MultiXactId minmulti, bool *frozenxid_updated, bool *minmulti_updated, bool in_outer_xact)
void vac_close_indexes(int nindexes, Relation *Irel, LOCKMODE lockmode)
void vacuum_delay_point(void)
bool vacuum_get_cutoffs(Relation rel, const VacuumParams *params, struct VacuumCutoffs *cutoffs)
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)
IndexBulkDeleteResult * vac_cleanup_one_index(IndexVacuumInfo *ivinfo, IndexBulkDeleteResult *istat)
#define MAXDEADITEMS(avail_mem)
@ VACOPTVALUE_UNSPECIFIED
#define VACOPT_DISABLE_PAGE_SKIPPING
static void dead_items_cleanup(LVRelState *vacrel)
static bool heap_page_is_all_visible(LVRelState *vacrel, Buffer buf, TransactionId *visibility_cutoff_xid, bool *all_frozen)
static void update_relstats_all_indexes(LVRelState *vacrel)
#define VACUUM_TRUNCATE_LOCK_WAIT_INTERVAL
static void vacuum_error_callback(void *arg)
static void lazy_truncate_heap(LVRelState *vacrel)
static void lazy_vacuum(LVRelState *vacrel)
static void lazy_cleanup_all_indexes(LVRelState *vacrel)
static bool lazy_scan_noprune(LVRelState *vacrel, Buffer buf, BlockNumber blkno, Page page, bool *has_lpdead_items)
static int lazy_vacuum_heap_page(LVRelState *vacrel, BlockNumber blkno, Buffer buffer, int index, Buffer vmbuffer)
#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 bool heap_vac_scan_next_block(LVRelState *vacrel, BlockNumber *blkno, bool *all_visible_according_to_vm)
static void lazy_scan_prune(LVRelState *vacrel, Buffer buf, BlockNumber blkno, Page page, Buffer vmbuffer, bool all_visible_according_to_vm, bool *has_lpdead_items)
void heap_vacuum_rel(Relation rel, VacuumParams *params, BufferAccessStrategy bstrategy)
static IndexBulkDeleteResult * lazy_vacuum_one_index(Relation indrel, IndexBulkDeleteResult *istat, double reltuples, LVRelState *vacrel)
static void find_next_unskippable_block(LVRelState *vacrel, bool *skipsallvis)
#define REL_TRUNCATE_FRACTION
static bool lazy_check_wraparound_failsafe(LVRelState *vacrel)
static int dead_items_max_items(LVRelState *vacrel)
struct LVSavedErrInfo LVSavedErrInfo
static IndexBulkDeleteResult * lazy_cleanup_one_index(Relation indrel, IndexBulkDeleteResult *istat, double reltuples, bool estimated_count, LVRelState *vacrel)
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 SKIP_PAGES_THRESHOLD
#define FAILSAFE_EVERY_PAGES
#define VACUUM_TRUNCATE_LOCK_CHECK_INTERVAL
static void lazy_vacuum_heap_rel(LVRelState *vacrel)
#define VACUUM_FSM_EVERY_PAGES
VacDeadItems * parallel_vacuum_get_dead_items(ParallelVacuumState *pvs)
void parallel_vacuum_bulkdel_all_indexes(ParallelVacuumState *pvs, long num_table_tuples, int num_index_scans)
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)
ParallelVacuumState * parallel_vacuum_init(Relation rel, Relation *indrels, int nindexes, int nrequested_workers, int max_items, int elevel, BufferAccessStrategy bstrategy)
void visibilitymap_set(Relation rel, BlockNumber heapBlk, Buffer heapBuf, XLogRecPtr recptr, Buffer vmBuf, TransactionId cutoff_xid, uint8 flags)
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)
void visibilitymap_count(Relation rel, BlockNumber *all_visible, BlockNumber *all_frozen)
#define VM_ALL_FROZEN(r, b, v)
#define VISIBILITYMAP_VALID_BITS
#define VISIBILITYMAP_ALL_FROZEN
#define VISIBILITYMAP_ALL_VISIBLE
bool IsInParallelMode(void)
#define InvalidXLogRecPtr
void XLogRegisterData(char *data, uint32 len)
XLogRecPtr XLogInsert(RmgrId rmid, uint8 info)
void XLogRegisterBufData(uint8 block_id, char *data, uint32 len)
XLogRecPtr log_newpage_buffer(Buffer buffer, bool page_std)
void XLogRegisterBuffer(uint8 block_id, Buffer buffer, uint8 flags)
void XLogBeginInsert(void)