PostgreSQL Source Code
git master
|
#include "postgres.h"
#include <math.h>
#include "access/amapi.h"
#include "access/genam.h"
#include "access/heapam.h"
#include "access/heapam_xlog.h"
#include "access/htup_details.h"
#include "access/multixact.h"
#include "access/parallel.h"
#include "access/transam.h"
#include "access/visibilitymap.h"
#include "access/xact.h"
#include "access/xlog.h"
#include "catalog/storage.h"
#include "commands/dbcommands.h"
#include "commands/progress.h"
#include "commands/vacuum.h"
#include "executor/instrument.h"
#include "miscadmin.h"
#include "optimizer/paths.h"
#include "pgstat.h"
#include "portability/instr_time.h"
#include "postmaster/autovacuum.h"
#include "storage/bufmgr.h"
#include "storage/freespace.h"
#include "storage/lmgr.h"
#include "tcop/tcopprot.h"
#include "utils/lsyscache.h"
#include "utils/memutils.h"
#include "utils/pg_rusage.h"
#include "utils/timestamp.h"
Go to the source code of this file.
Data Structures | |
struct | LVDeadTuples |
struct | LVShared |
struct | LVSharedIndStats |
struct | LVParallelState |
struct | LVRelStats |
struct | LVSavedErrInfo |
Typedefs | |
typedef struct LVDeadTuples | LVDeadTuples |
typedef struct LVShared | LVShared |
typedef struct LVSharedIndStats | LVSharedIndStats |
typedef struct LVParallelState | LVParallelState |
typedef struct LVRelStats | LVRelStats |
typedef struct LVSavedErrInfo | LVSavedErrInfo |
Functions | |
static void | lazy_scan_heap (Relation onerel, VacuumParams *params, LVRelStats *vacrelstats, Relation *Irel, int nindexes, bool aggressive) |
static void | lazy_vacuum_heap (Relation onerel, LVRelStats *vacrelstats) |
static bool | lazy_check_needs_freeze (Buffer buf, bool *hastup, LVRelStats *vacrelstats) |
static void | lazy_vacuum_all_indexes (Relation onerel, Relation *Irel, IndexBulkDeleteResult **stats, LVRelStats *vacrelstats, LVParallelState *lps, int nindexes) |
static void | lazy_vacuum_index (Relation indrel, IndexBulkDeleteResult **stats, LVDeadTuples *dead_tuples, double reltuples, LVRelStats *vacrelstats) |
static void | lazy_cleanup_index (Relation indrel, IndexBulkDeleteResult **stats, double reltuples, bool estimated_count, LVRelStats *vacrelstats) |
static int | lazy_vacuum_page (Relation onerel, BlockNumber blkno, Buffer buffer, int tupindex, LVRelStats *vacrelstats, Buffer *vmbuffer) |
static bool | should_attempt_truncation (VacuumParams *params, LVRelStats *vacrelstats) |
static void | lazy_truncate_heap (Relation onerel, LVRelStats *vacrelstats) |
static BlockNumber | count_nondeletable_pages (Relation onerel, LVRelStats *vacrelstats) |
static void | lazy_space_alloc (LVRelStats *vacrelstats, BlockNumber relblocks) |
static void | lazy_record_dead_tuple (LVDeadTuples *dead_tuples, ItemPointer itemptr) |
static bool | lazy_tid_reaped (ItemPointer itemptr, void *state) |
static int | vac_cmp_itemptr (const void *left, const void *right) |
static bool | heap_page_is_all_visible (Relation rel, Buffer buf, LVRelStats *vacrelstats, TransactionId *visibility_cutoff_xid, bool *all_frozen) |
static void | lazy_parallel_vacuum_indexes (Relation *Irel, IndexBulkDeleteResult **stats, LVRelStats *vacrelstats, LVParallelState *lps, int nindexes) |
static void | parallel_vacuum_index (Relation *Irel, IndexBulkDeleteResult **stats, LVShared *lvshared, LVDeadTuples *dead_tuples, int nindexes, LVRelStats *vacrelstats) |
static void | vacuum_indexes_leader (Relation *Irel, IndexBulkDeleteResult **stats, LVRelStats *vacrelstats, LVParallelState *lps, int nindexes) |
static void | vacuum_one_index (Relation indrel, IndexBulkDeleteResult **stats, LVShared *lvshared, LVSharedIndStats *shared_indstats, LVDeadTuples *dead_tuples, LVRelStats *vacrelstats) |
static void | lazy_cleanup_all_indexes (Relation *Irel, IndexBulkDeleteResult **stats, LVRelStats *vacrelstats, LVParallelState *lps, int nindexes) |
static long | compute_max_dead_tuples (BlockNumber relblocks, bool hasindex) |
static int | compute_parallel_vacuum_workers (Relation *Irel, int nindexes, int nrequested, bool *can_parallel_vacuum) |
static void | prepare_index_statistics (LVShared *lvshared, bool *can_parallel_vacuum, int nindexes) |
static void | update_index_statistics (Relation *Irel, IndexBulkDeleteResult **stats, int nindexes) |
static LVParallelState * | begin_parallel_vacuum (Oid relid, Relation *Irel, LVRelStats *vacrelstats, BlockNumber nblocks, int nindexes, int nrequested) |
static void | end_parallel_vacuum (IndexBulkDeleteResult **stats, LVParallelState *lps, int nindexes) |
static LVSharedIndStats * | get_indstats (LVShared *lvshared, int n) |
static bool | skip_parallel_vacuum_index (Relation indrel, LVShared *lvshared) |
static void | vacuum_error_callback (void *arg) |
static void | update_vacuum_error_info (LVRelStats *errinfo, LVSavedErrInfo *saved_err_info, int phase, BlockNumber blkno, OffsetNumber offnum) |
static void | restore_vacuum_error_info (LVRelStats *errinfo, const LVSavedErrInfo *saved_err_info) |
void | heap_vacuum_rel (Relation onerel, VacuumParams *params, BufferAccessStrategy bstrategy) |
static void | vacuum_log_cleanup_info (Relation rel, LVRelStats *vacrelstats) |
void | parallel_vacuum_main (dsm_segment *seg, shm_toc *toc) |
Variables | |
static int | elevel = -1 |
static TransactionId | OldestXmin |
static TransactionId | FreezeLimit |
static MultiXactId | MultiXactCutoff |
static BufferAccessStrategy | vac_strategy |
#define FORCE_CHECK_PAGE | ( | ) | (blkno == nblocks - 1 && should_attempt_truncation(params, vacrelstats)) |
Referenced by lazy_scan_heap().
#define GetSharedIndStats | ( | s | ) | ((LVSharedIndStats *)((char *)(s) + ((LVShared *)(s))->offset)) |
Definition at line 254 of file vacuumlazy.c.
Referenced by get_indstats().
Definition at line 256 of file vacuumlazy.c.
Referenced by get_indstats().
#define LAZY_ALLOC_TUPLES MaxHeapTuplesPerPage |
Definition at line 119 of file vacuumlazy.c.
Referenced by compute_max_dead_tuples().
#define MAXDEADTUPLES | ( | max_size | ) | (((max_size) - offsetof(LVDeadTuples, itemptrs)) / sizeof(ItemPointerData)) |
Definition at line 180 of file vacuumlazy.c.
Referenced by compute_max_dead_tuples().
#define PARALLEL_VACUUM_KEY_BUFFER_USAGE 4 |
Definition at line 141 of file vacuumlazy.c.
Referenced by begin_parallel_vacuum(), and parallel_vacuum_main().
#define PARALLEL_VACUUM_KEY_DEAD_TUPLES 2 |
Definition at line 139 of file vacuumlazy.c.
Referenced by begin_parallel_vacuum(), and parallel_vacuum_main().
#define PARALLEL_VACUUM_KEY_QUERY_TEXT 3 |
Definition at line 140 of file vacuumlazy.c.
Referenced by begin_parallel_vacuum(), and parallel_vacuum_main().
#define PARALLEL_VACUUM_KEY_SHARED 1 |
Definition at line 138 of file vacuumlazy.c.
Referenced by begin_parallel_vacuum(), and parallel_vacuum_main().
#define PARALLEL_VACUUM_KEY_WAL_USAGE 5 |
Definition at line 142 of file vacuumlazy.c.
Referenced by begin_parallel_vacuum(), and parallel_vacuum_main().
#define ParallelVacuumIsActive | ( | lps | ) | PointerIsValid(lps) |
Definition at line 148 of file vacuumlazy.c.
Referenced by lazy_cleanup_all_indexes(), lazy_parallel_vacuum_indexes(), lazy_scan_heap(), and lazy_vacuum_all_indexes().
#define PREFETCH_SIZE ((BlockNumber) 32) |
Definition at line 131 of file vacuumlazy.c.
Referenced by count_nondeletable_pages().
#define REL_TRUNCATE_FRACTION 16 |
Definition at line 92 of file vacuumlazy.c.
Referenced by should_attempt_truncation().
#define REL_TRUNCATE_MINIMUM 1000 |
Definition at line 91 of file vacuumlazy.c.
Referenced by should_attempt_truncation().
#define SizeOfDeadTuples | ( | cnt | ) |
Definition at line 177 of file vacuumlazy.c.
Referenced by begin_parallel_vacuum(), and lazy_space_alloc().
Definition at line 253 of file vacuumlazy.c.
Referenced by begin_parallel_vacuum().
#define SKIP_PAGES_THRESHOLD ((BlockNumber) 32) |
Definition at line 125 of file vacuumlazy.c.
Referenced by lazy_scan_heap().
#define VACUUM_FSM_EVERY_PAGES ((BlockNumber) (((uint64) 8 * 1024 * 1024 * 1024) / BLCKSZ)) |
Definition at line 111 of file vacuumlazy.c.
Referenced by lazy_scan_heap().
#define VACUUM_TRUNCATE_LOCK_CHECK_INTERVAL 20 /* ms */ |
Definition at line 101 of file vacuumlazy.c.
Referenced by count_nondeletable_pages().
#define VACUUM_TRUNCATE_LOCK_TIMEOUT 5000 /* ms */ |
Definition at line 103 of file vacuumlazy.c.
Referenced by lazy_truncate_heap().
#define VACUUM_TRUNCATE_LOCK_WAIT_INTERVAL 50 /* ms */ |
Definition at line 102 of file vacuumlazy.c.
Referenced by lazy_truncate_heap().
typedef struct LVDeadTuples LVDeadTuples |
typedef struct LVParallelState LVParallelState |
typedef struct LVRelStats LVRelStats |
typedef struct LVSavedErrInfo LVSavedErrInfo |
typedef struct LVSharedIndStats LVSharedIndStats |
enum VacErrPhase |
Enumerator | |
---|---|
VACUUM_ERRCB_PHASE_UNKNOWN | |
VACUUM_ERRCB_PHASE_SCAN_HEAP | |
VACUUM_ERRCB_PHASE_VACUUM_INDEX | |
VACUUM_ERRCB_PHASE_VACUUM_HEAP | |
VACUUM_ERRCB_PHASE_INDEX_CLEANUP | |
VACUUM_ERRCB_PHASE_TRUNCATE |
Definition at line 151 of file vacuumlazy.c.
|
static |
Definition at line 3219 of file vacuumlazy.c.
References LVShared::active_nworkers, add_size(), IndexAmRoutine::amparallelvacuumoptions, Assert, BITMAPLEN, LVParallelState::buffer_usage, compute_max_dead_tuples(), compute_parallel_vacuum_workers(), LVShared::cost_balance, CreateParallelContext(), LVRelStats::dead_tuples, debug_query_string, LVShared::elevel, elevel, EnterParallelMode(), ParallelContext::estimator, i, LVShared::idx, InitializeParallelDSM(), LVDeadTuples::itemptrs, LVParallelState::lvshared, maintenance_work_mem, LVShared::maintenance_work_mem_worker, LVDeadTuples::max_tuples, MAXALIGN, MemSet, Min, mul_size(), LVParallelState::nindexes_parallel_bulkdel, LVParallelState::nindexes_parallel_cleanup, LVParallelState::nindexes_parallel_condcleanup, LVDeadTuples::num_tuples, ParallelContext::nworkers, LVShared::offset, palloc0(), PARALLEL_VACUUM_KEY_BUFFER_USAGE, PARALLEL_VACUUM_KEY_DEAD_TUPLES, PARALLEL_VACUUM_KEY_QUERY_TEXT, PARALLEL_VACUUM_KEY_SHARED, PARALLEL_VACUUM_KEY_WAL_USAGE, LVParallelState::pcxt, pfree(), pg_atomic_init_u32(), prepare_index_statistics(), RelationData::rd_indam, LVShared::relid, shm_toc_allocate(), shm_toc_estimate_chunk, shm_toc_estimate_keys, shm_toc_insert(), SizeOfDeadTuples, SizeOfLVShared, ParallelContext::toc, VACUUM_OPTION_MAX_VALID_VALUE, VACUUM_OPTION_PARALLEL_BULKDEL, VACUUM_OPTION_PARALLEL_CLEANUP, VACUUM_OPTION_PARALLEL_COND_CLEANUP, and LVParallelState::wal_usage.
Referenced by lazy_scan_heap().
|
static |
Definition at line 2849 of file vacuumlazy.c.
References autovacuum_work_mem, IsAutoVacuumWorkerProcess(), LAZY_ALLOC_TUPLES, maintenance_work_mem, Max, MaxAllocSize, MAXDEADTUPLES, MaxHeapTuplesPerPage, and Min.
Referenced by begin_parallel_vacuum(), and lazy_space_alloc().
|
static |
Definition at line 3102 of file vacuumlazy.c.
References IndexAmRoutine::amparallelvacuumoptions, i, IsUnderPostmaster, Max, max_parallel_maintenance_workers, Min, min_parallel_index_scan_size, RelationData::rd_indam, RelationGetNumberOfBlocks, VACUUM_OPTION_NO_PARALLEL, VACUUM_OPTION_PARALLEL_BULKDEL, VACUUM_OPTION_PARALLEL_CLEANUP, and VACUUM_OPTION_PARALLEL_COND_CLEANUP.
Referenced by begin_parallel_vacuum().
|
static |
Definition at line 2710 of file vacuumlazy.c.
References AccessExclusiveLock, buf, BUFFER_LOCK_SHARE, BufferGetPage, CHECK_FOR_INTERRUPTS, elevel, ereport, errmsg(), FirstOffsetNumber, INSTR_TIME_GET_MICROSEC, INSTR_TIME_SET_CURRENT, INSTR_TIME_SUBTRACT, InvalidBlockNumber, ItemIdIsUsed, LVRelStats::lock_waiter_detected, LockBuffer(), LockHasWaitersRelation(), MAIN_FORKNUM, LVRelStats::nonempty_pages, OffsetNumberNext, PageGetItemId, PageGetMaxOffsetNumber, PageIsEmpty, PageIsNew, PREFETCH_SIZE, PrefetchBuffer(), RBM_NORMAL, ReadBufferExtended(), LVRelStats::rel_pages, LVRelStats::relname, StaticAssertStmt, UnlockReleaseBuffer(), and VACUUM_TRUNCATE_LOCK_CHECK_INTERVAL.
Referenced by lazy_truncate_heap().
|
static |
Definition at line 3403 of file vacuumlazy.c.
References Assert, DestroyParallelContext(), ExitParallelMode(), get_indstats(), i, IsParallelWorker, LVParallelState::lvshared, palloc0(), LVParallelState::pcxt, pfree(), LVSharedIndStats::stats, and LVSharedIndStats::updated.
Referenced by lazy_scan_heap().
|
static |
Definition at line 3441 of file vacuumlazy.c.
References GetSharedIndStats, i, and IndStatsIsNull.
Referenced by end_parallel_vacuum(), parallel_vacuum_index(), and vacuum_indexes_leader().
|
static |
Definition at line 2974 of file vacuumlazy.c.
References Assert, BufferGetBlockNumber(), BufferGetPage, elog, ERROR, FirstOffsetNumber, heap_tuple_needs_eventual_freeze(), HEAPTUPLE_DEAD, HEAPTUPLE_DELETE_IN_PROGRESS, HEAPTUPLE_INSERT_IN_PROGRESS, HEAPTUPLE_LIVE, HEAPTUPLE_RECENTLY_DEAD, HeapTupleHeaderGetXmin, HeapTupleHeaderXminCommitted, HeapTupleSatisfiesVacuum(), InvalidOffsetNumber, InvalidTransactionId, ItemIdGetLength, ItemIdIsDead, ItemIdIsNormal, ItemIdIsRedirected, ItemIdIsUsed, ItemPointerSet, LVRelStats::offnum, OffsetNumberNext, OldestXmin, PageGetItem, PageGetItemId, PageGetMaxOffsetNumber, RelationGetRelid, HeapTupleData::t_data, HeapTupleData::t_len, HeapTupleData::t_self, HeapTupleData::t_tableOid, TransactionIdFollows(), and TransactionIdPrecedes().
Referenced by lazy_vacuum_page().
void heap_vacuum_rel | ( | Relation | onerel, |
VacuumParams * | params, | ||
BufferAccessStrategy | bstrategy | ||
) |
Definition at line 419 of file vacuumlazy.c.
References _, appendStringInfo(), ErrorContextCallback::arg, Assert, buf, ErrorContextCallback::callback, StringInfoData::data, DEBUG2, elevel, ereport, errmsg_internal(), error_context_stack, VacuumParams::freeze_min_age, VacuumParams::freeze_table_age, FreezeLimit, LVRelStats::frozenskipped_pages, get_database_name(), get_namespace_name(), GetCurrentTimestamp(), VacuumParams::index_cleanup, LVRelStats::indname, INFO, initStringInfo(), InvalidMultiXactId, InvalidOffsetNumber, InvalidTransactionId, VacuumParams::is_wraparound, IsAutoVacuumWorkerProcess(), lazy_scan_heap(), lazy_truncate_heap(), LVRelStats::lock_waiter_detected, LOG, VacuumParams::log_min_duration, Max, VacuumParams::multixact_freeze_min_age, VacuumParams::multixact_freeze_table_age, MultiXactCutoff, MultiXactIdIsValid, MultiXactIdPrecedesOrEquals(), MyDatabaseId, LVRelStats::new_dead_tuples, LVRelStats::new_live_tuples, LVRelStats::new_rel_tuples, NoLock, LVRelStats::nonempty_pages, LVRelStats::num_index_scans, LVRelStats::old_live_tuples, LVRelStats::old_rel_pages, OldestXmin, VacuumParams::options, LVRelStats::pages_removed, palloc0(), pfree(), pg_rusage_init(), pg_rusage_show(), pgstat_progress_end_command(), pgstat_progress_start_command(), pgstat_progress_update_param(), pgstat_report_vacuum(), pgWalUsage, LVRelStats::phase, LVRelStats::pinskipped_pages, ErrorContextCallback::previous, PROGRESS_COMMAND_VACUUM, PROGRESS_VACUUM_PHASE, PROGRESS_VACUUM_PHASE_FINAL_CLEANUP, pstrdup(), RelationData::rd_rel, LVRelStats::rel_pages, RelationGetNamespace, RelationGetRelationName, RelationGetRelid, LVRelStats::relname, LVRelStats::relnamespace, RowExclusiveLock, LVRelStats::scanned_pages, should_attempt_truncation(), TimestampDifference(), TimestampDifferenceExceeds(), TransactionIdIsNormal, TransactionIdPrecedesOrEquals(), VacuumParams::truncate, LVRelStats::tuples_deleted, update_vacuum_error_info(), LVRelStats::useindex, vac_close_indexes(), vac_open_indexes(), vac_update_relstats(), VACOPT_DISABLE_PAGE_SKIPPING, VACOPT_TERNARY_DEFAULT, VACOPT_TERNARY_ENABLED, VACOPT_VERBOSE, VACUUM_ERRCB_PHASE_TRUNCATE, VACUUM_ERRCB_PHASE_UNKNOWN, vacuum_error_callback(), vacuum_set_xid_limits(), VacuumPageDirty, VacuumPageHit, VacuumPageMiss, visibilitymap_count(), WalUsage::wal_bytes, WalUsage::wal_fpi, WalUsage::wal_records, and WalUsageAccumDiff().
Referenced by SampleHeapTupleVisible().
|
static |
Definition at line 2031 of file vacuumlazy.c.
References BufferGetPage, FirstOffsetNumber, FreezeLimit, heap_tuple_needs_freeze(), InvalidOffsetNumber, ItemIdIsNormal, ItemIdIsUsed, MultiXactCutoff, LVRelStats::offnum, OffsetNumberNext, PageGetItem, PageGetItemId, PageGetMaxOffsetNumber, PageIsEmpty, and PageIsNew.
Referenced by lazy_scan_heap().
|
static |
Definition at line 2376 of file vacuumlazy.c.
References Assert, LVShared::estimated_count, LVShared::first_time, LVShared::for_cleanup, idx(), IsParallelWorker, lazy_cleanup_index(), lazy_parallel_vacuum_indexes(), LVParallelState::lvshared, LVRelStats::new_rel_tuples, LVRelStats::num_index_scans, ParallelVacuumIsActive, pgstat_progress_update_param(), PROGRESS_VACUUM_PHASE, PROGRESS_VACUUM_PHASE_INDEX_CLEANUP, LVRelStats::rel_pages, LVShared::reltuples, and LVRelStats::tupcount_pages.
Referenced by lazy_scan_heap().
|
static |
Definition at line 2483 of file vacuumlazy.c.
References IndexVacuumInfo::analyze_only, Assert, elevel, ereport, errdetail(), errmsg(), IndexVacuumInfo::estimated_count, IndexVacuumInfo::index, index_vacuum_cleanup(), LVRelStats::indname, InvalidBlockNumber, InvalidOffsetNumber, IndexVacuumInfo::message_level, IndexVacuumInfo::num_heap_tuples, pfree(), pg_rusage_init(), pg_rusage_show(), pstrdup(), RelationGetRelationName, IndexVacuumInfo::report_progress, restore_vacuum_error_info(), IndexVacuumInfo::strategy, update_vacuum_error_info(), vac_strategy, and VACUUM_ERRCB_PHASE_INDEX_CLEANUP.
Referenced by lazy_cleanup_all_indexes(), and vacuum_one_index().
|
static |
Definition at line 2091 of file vacuumlazy.c.
References LVShared::active_nworkers, Assert, LVParallelState::buffer_usage, LVShared::cost_balance, LVRelStats::dead_tuples, elevel, ereport, errmsg(), LVShared::first_time, LVShared::for_cleanup, i, LVShared::idx, InstrAccumParallelQuery(), IsParallelWorker, LaunchParallelWorkers(), LVParallelState::lvshared, Min, ngettext, LVParallelState::nindexes_parallel_bulkdel, LVParallelState::nindexes_parallel_cleanup, LVParallelState::nindexes_parallel_condcleanup, LVRelStats::num_index_scans, ParallelContext::nworkers, ParallelContext::nworkers_launched, parallel_vacuum_index(), ParallelVacuumIsActive, LVParallelState::pcxt, pg_atomic_read_u32(), pg_atomic_write_u32(), ReinitializeParallelDSM(), ReinitializeParallelWorkers(), vacuum_indexes_leader(), VacuumActiveNWorkers, VacuumCostBalance, VacuumCostBalanceLocal, VacuumSharedCostBalance, WaitForParallelWorkersToFinish(), and LVParallelState::wal_usage.
Referenced by lazy_cleanup_all_indexes(), and lazy_vacuum_all_indexes().
|
static |
Definition at line 2899 of file vacuumlazy.c.
References LVDeadTuples::itemptrs, LVDeadTuples::max_tuples, LVDeadTuples::num_tuples, pgstat_progress_update_param(), and PROGRESS_VACUUM_NUM_DEAD_TUPLES.
Referenced by lazy_scan_heap().
|
static |
Definition at line 753 of file vacuumlazy.c.
References _, appendStringInfo(), Assert, begin_parallel_vacuum(), LVRelStats::blkno, buf, BUFFER_LOCK_SHARE, BUFFER_LOCK_UNLOCK, BufferGetPage, BufferGetPageSize, BufferIsValid, ConditionalLockBufferForCleanup(), StringInfoData::data, LVRelStats::dead_tuples, elevel, elog, END_CRIT_SECTION, end_parallel_vacuum(), ereport, errdetail_internal(), errmsg(), ERROR, FirstOffsetNumber, FORCE_CHECK_PAGE, FreeSpaceMapVacuumRange(), FreezeLimit, LVRelStats::frozenskipped_pages, GetRecordedFreeSpace(), GlobalVisTestFor(), heap_execute_freeze_tuple(), heap_page_prune(), heap_prepare_freeze_tuple(), HEAPTUPLE_DEAD, HEAPTUPLE_DELETE_IN_PROGRESS, HEAPTUPLE_INSERT_IN_PROGRESS, HEAPTUPLE_LIVE, HEAPTUPLE_RECENTLY_DEAD, HeapTupleHeaderAdvanceLatestRemovedXid(), HeapTupleHeaderGetXmin, HeapTupleHeaderXminCommitted, HeapTupleIsHeapOnly, HeapTupleIsHotUpdated, HeapTupleSatisfiesVacuum(), i, VacuumParams::index_cleanup, initStringInfo(), InvalidBlockNumber, InvalidBuffer, InvalidOffsetNumber, InvalidTransactionId, InvalidXLogRecPtr, ItemIdGetLength, ItemIdIsDead, ItemIdIsNormal, ItemIdIsRedirected, ItemIdIsUsed, ItemPointerSet, LVRelStats::latestRemovedXid, lazy_check_needs_freeze(), lazy_cleanup_all_indexes(), lazy_record_dead_tuple(), lazy_space_alloc(), lazy_vacuum_all_indexes(), lazy_vacuum_heap(), lazy_vacuum_page(), LockBuffer(), LockBufferForCleanup(), log_heap_freeze(), log_newpage_buffer(), MAIN_FORKNUM, MarkBufferDirty(), Max, LVDeadTuples::max_tuples, MaxHeapTuplesPerPage, MultiXactCutoff, LVRelStats::new_dead_tuples, LVRelStats::new_live_tuples, LVRelStats::new_rel_tuples, ngettext, LVRelStats::nonempty_pages, LVDeadTuples::num_tuples, VacuumParams::nworkers, LVRelStats::offnum, xl_heap_freeze_tuple::offset, OffsetNumberNext, OldestXmin, VacuumParams::options, PageClearAllVisible, PageGetHeapFreeSpace(), PageGetItem, PageGetItemId, PageGetLSN, PageGetMaxOffsetNumber, PageIsAllVisible, PageIsEmpty, PageIsNew, PageSetAllVisible, PageSetLSN, palloc(), palloc0(), ParallelVacuumIsActive, pfree(), pg_rusage_init(), pg_rusage_show(), pgstat_progress_update_multi_param(), pgstat_progress_update_param(), LVRelStats::pinskipped_pages, PROGRESS_VACUUM_HEAP_BLKS_SCANNED, PROGRESS_VACUUM_HEAP_BLKS_VACUUMED, PROGRESS_VACUUM_MAX_DEAD_TUPLES, PROGRESS_VACUUM_PHASE, PROGRESS_VACUUM_PHASE_SCAN_HEAP, PROGRESS_VACUUM_TOTAL_HEAP_BLKS, RBM_NORMAL, RelationData::rd_rel, ReadBufferExtended(), RecordPageWithFreeSpace(), LVRelStats::rel_pages, RelationGetNumberOfBlocks, RelationGetRelid, RelationNeedsWAL, RelationUsesLocalBuffers, ReleaseBuffer(), LVRelStats::relname, LVRelStats::relnamespace, LVRelStats::scanned_pages, SizeOfPageHeaderData, SKIP_PAGES_THRESHOLD, START_CRIT_SECTION, HeapTupleData::t_data, HeapTupleData::t_len, HeapTupleData::t_self, HeapTupleData::t_tableOid, TransactionIdFollows(), TransactionIdPrecedes(), LVRelStats::tupcount_pages, LVRelStats::tuples_deleted, UnlockReleaseBuffer(), update_index_statistics(), update_vacuum_error_info(), LVRelStats::useindex, vac_estimate_reltuples(), VACOPT_DISABLE_PAGE_SKIPPING, VACOPT_TERNARY_DISABLED, vacuum_delay_point(), VACUUM_ERRCB_PHASE_SCAN_HEAP, VACUUM_FSM_EVERY_PAGES, VISIBILITYMAP_ALL_FROZEN, VISIBILITYMAP_ALL_VISIBLE, visibilitymap_clear(), visibilitymap_get_status(), visibilitymap_pin(), visibilitymap_set(), VISIBILITYMAP_VALID_BITS, VM_ALL_FROZEN, VM_ALL_VISIBLE, and WARNING.
Referenced by heap_vacuum_rel().
|
static |
Definition at line 2881 of file vacuumlazy.c.
References compute_max_dead_tuples(), LVRelStats::dead_tuples, LVDeadTuples::max_tuples, LVDeadTuples::num_tuples, palloc(), SizeOfDeadTuples, and LVRelStats::useindex.
Referenced by lazy_scan_heap().
|
static |
Definition at line 2923 of file vacuumlazy.c.
References LVDeadTuples::itemptrs, LVDeadTuples::num_tuples, and vac_cmp_itemptr().
Referenced by lazy_vacuum_index().
|
static |
Definition at line 2580 of file vacuumlazy.c.
References AccessExclusiveLock, LVRelStats::blkno, CHECK_FOR_INTERRUPTS, ConditionalLockRelation(), count_nondeletable_pages(), elevel, ereport, errdetail_internal(), errmsg(), LVRelStats::lock_waiter_detected, LVRelStats::nonempty_pages, LVRelStats::pages_removed, pg_rusage_init(), pg_rusage_show(), pg_usleep(), pgstat_progress_update_param(), PROGRESS_VACUUM_PHASE, PROGRESS_VACUUM_PHASE_TRUNCATE, LVRelStats::rel_pages, RelationGetNumberOfBlocks, RelationTruncate(), LVRelStats::relname, UnlockRelation(), VACUUM_TRUNCATE_LOCK_TIMEOUT, and VACUUM_TRUNCATE_LOCK_WAIT_INTERVAL.
Referenced by heap_vacuum_rel().
|
static |
Definition at line 1784 of file vacuumlazy.c.
References Assert, LVRelStats::dead_tuples, LVShared::estimated_count, LVShared::first_time, LVShared::for_cleanup, idx(), IsParallelWorker, lazy_parallel_vacuum_indexes(), lazy_vacuum_index(), LVParallelState::lvshared, LVRelStats::num_index_scans, LVRelStats::old_live_tuples, ParallelVacuumIsActive, pgstat_progress_update_param(), PROGRESS_VACUUM_NUM_INDEX_VACUUMS, PROGRESS_VACUUM_PHASE, PROGRESS_VACUUM_PHASE_VACUUM_INDEX, LVShared::reltuples, and vacuum_log_cleanup_info().
Referenced by lazy_scan_heap().
|
static |
Definition at line 1843 of file vacuumlazy.c.
References LVRelStats::blkno, buf, BufferGetPage, BufferIsValid, ConditionalLockBufferForCleanup(), LVRelStats::dead_tuples, elevel, ereport, errdetail_internal(), errmsg(), InvalidBlockNumber, InvalidBuffer, InvalidOffsetNumber, ItemPointerGetBlockNumber, LVDeadTuples::itemptrs, lazy_vacuum_page(), MAIN_FORKNUM, PageGetHeapFreeSpace(), pg_rusage_init(), pg_rusage_show(), pgstat_progress_update_param(), PROGRESS_VACUUM_PHASE, PROGRESS_VACUUM_PHASE_VACUUM_HEAP, RBM_NORMAL, ReadBufferExtended(), RecordPageWithFreeSpace(), ReleaseBuffer(), LVRelStats::relname, restore_vacuum_error_info(), UnlockReleaseBuffer(), update_vacuum_error_info(), vacuum_delay_point(), and VACUUM_ERRCB_PHASE_VACUUM_HEAP.
Referenced by lazy_scan_heap().
|
static |
Definition at line 2431 of file vacuumlazy.c.
References IndexVacuumInfo::analyze_only, Assert, elevel, ereport, errdetail_internal(), errmsg(), IndexVacuumInfo::estimated_count, IndexVacuumInfo::index, index_bulk_delete(), LVRelStats::indname, InvalidBlockNumber, InvalidOffsetNumber, lazy_tid_reaped(), IndexVacuumInfo::message_level, IndexVacuumInfo::num_heap_tuples, pfree(), pg_rusage_init(), pg_rusage_show(), pstrdup(), RelationGetRelationName, IndexVacuumInfo::report_progress, restore_vacuum_error_info(), IndexVacuumInfo::strategy, update_vacuum_error_info(), vac_strategy, and VACUUM_ERRCB_PHASE_VACUUM_INDEX.
Referenced by lazy_vacuum_all_indexes(), and vacuum_one_index().
|
static |
Definition at line 1924 of file vacuumlazy.c.
References Assert, BufferGetPage, BufferIsValid, LVRelStats::dead_tuples, END_CRIT_SECTION, heap_page_is_all_visible(), InvalidOffsetNumber, InvalidXLogRecPtr, ItemIdSetUnused, ItemPointerGetBlockNumber, ItemPointerGetOffsetNumber, LVDeadTuples::itemptrs, LVRelStats::latestRemovedXid, log_heap_clean(), MarkBufferDirty(), MaxOffsetNumber, LVDeadTuples::num_tuples, PageGetItemId, PageIsAllVisible, PageRepairFragmentation(), PageSetAllVisible, PageSetLSN, pgstat_progress_update_param(), PROGRESS_VACUUM_HEAP_BLKS_VACUUMED, RelationNeedsWAL, restore_vacuum_error_info(), START_CRIT_SECTION, update_vacuum_error_info(), VACUUM_ERRCB_PHASE_VACUUM_HEAP, VISIBILITYMAP_ALL_FROZEN, VISIBILITYMAP_ALL_VISIBLE, visibilitymap_get_status(), and visibilitymap_set().
Referenced by lazy_scan_heap(), and lazy_vacuum_heap().
|
static |
Definition at line 2221 of file vacuumlazy.c.
References get_indstats(), LVShared::idx, idx(), pg_atomic_add_fetch_u32(), pg_atomic_fetch_add_u32(), pg_atomic_sub_fetch_u32(), skip_parallel_vacuum_index(), vacuum_one_index(), and VacuumActiveNWorkers.
Referenced by lazy_parallel_vacuum_indexes(), and parallel_vacuum_main().
void parallel_vacuum_main | ( | dsm_segment * | seg, |
shm_toc * | toc | ||
) |
Definition at line 3506 of file vacuumlazy.c.
References LVShared::active_nworkers, ErrorContextCallback::arg, Assert, ErrorContextCallback::callback, LVShared::cost_balance, DEBUG1, debug_query_string, LVShared::elevel, elevel, elog, error_context_stack, LVShared::for_cleanup, get_namespace_name(), LVRelStats::indname, InstrEndParallelQuery(), InstrStartParallelQuery(), maintenance_work_mem, LVShared::maintenance_work_mem_worker, palloc0(), parallel_vacuum_index(), PARALLEL_VACUUM_KEY_BUFFER_USAGE, PARALLEL_VACUUM_KEY_DEAD_TUPLES, PARALLEL_VACUUM_KEY_QUERY_TEXT, PARALLEL_VACUUM_KEY_SHARED, PARALLEL_VACUUM_KEY_WAL_USAGE, ParallelWorkerNumber, pfree(), pgstat_report_activity(), LVRelStats::phase, ErrorContextCallback::previous, pstrdup(), RelationGetNamespace, RelationGetRelationName, LVShared::relid, LVRelStats::relname, LVRelStats::relnamespace, RowExclusiveLock, ShareUpdateExclusiveLock, shm_toc_lookup(), STATE_RUNNING, table_close(), table_open(), vac_close_indexes(), vac_open_indexes(), VACUUM_ERRCB_PHASE_UNKNOWN, vacuum_error_callback(), VacuumActiveNWorkers, VacuumCostActive, VacuumCostBalance, VacuumCostBalanceLocal, VacuumCostDelay, VacuumPageDirty, VacuumPageHit, VacuumPageMiss, and VacuumSharedCostBalance.
|
static |
Definition at line 3163 of file vacuumlazy.c.
References Assert, LVShared::bitmap, BITMAPLEN, i, and IsAutoVacuumWorkerProcess().
Referenced by begin_parallel_vacuum().
|
static |
Definition at line 3692 of file vacuumlazy.c.
References LVRelStats::blkno, LVSavedErrInfo::blkno, LVRelStats::offnum, LVSavedErrInfo::offnum, LVRelStats::phase, and LVSavedErrInfo::phase.
Referenced by lazy_cleanup_index(), lazy_vacuum_heap(), lazy_vacuum_index(), and lazy_vacuum_page().
|
static |
Definition at line 2559 of file vacuumlazy.c.
References LVRelStats::nonempty_pages, old_snapshot_threshold, LVRelStats::rel_pages, REL_TRUNCATE_FRACTION, REL_TRUNCATE_MINIMUM, VacuumParams::truncate, and VACOPT_TERNARY_DISABLED.
Referenced by heap_vacuum_rel().
Definition at line 3466 of file vacuumlazy.c.
References IndexAmRoutine::amparallelvacuumoptions, Assert, LVShared::first_time, LVShared::for_cleanup, RelationData::rd_indam, VACUUM_OPTION_PARALLEL_BULKDEL, VACUUM_OPTION_PARALLEL_CLEANUP, and VACUUM_OPTION_PARALLEL_COND_CLEANUP.
Referenced by parallel_vacuum_index(), and vacuum_indexes_leader().
|
static |
Definition at line 3188 of file vacuumlazy.c.
References Assert, i, InvalidMultiXactId, InvalidTransactionId, IsInParallelMode(), pfree(), and vac_update_relstats().
Referenced by lazy_scan_heap().
|
static |
Definition at line 3673 of file vacuumlazy.c.
References LVRelStats::blkno, LVSavedErrInfo::blkno, LVRelStats::offnum, LVSavedErrInfo::offnum, LVRelStats::phase, and LVSavedErrInfo::phase.
Referenced by heap_vacuum_rel(), lazy_cleanup_index(), lazy_scan_heap(), lazy_vacuum_heap(), lazy_vacuum_index(), and lazy_vacuum_page().
|
static |
Definition at line 2941 of file vacuumlazy.c.
References ItemPointerGetBlockNumber, and ItemPointerGetOffsetNumber.
Referenced by lazy_tid_reaped().
|
static |
Definition at line 3609 of file vacuumlazy.c.
References arg, LVRelStats::blkno, BlockNumberIsValid, errcontext, LVRelStats::indname, LVRelStats::offnum, OffsetNumberIsValid, LVRelStats::phase, LVRelStats::relname, LVRelStats::relnamespace, VACUUM_ERRCB_PHASE_INDEX_CLEANUP, VACUUM_ERRCB_PHASE_SCAN_HEAP, VACUUM_ERRCB_PHASE_TRUNCATE, VACUUM_ERRCB_PHASE_UNKNOWN, VACUUM_ERRCB_PHASE_VACUUM_HEAP, and VACUUM_ERRCB_PHASE_VACUUM_INDEX.
Referenced by heap_vacuum_rel(), and parallel_vacuum_main().
|
static |
Definition at line 2273 of file vacuumlazy.c.
References Assert, LVRelStats::dead_tuples, get_indstats(), i, IsParallelWorker, LVParallelState::lvshared, pg_atomic_add_fetch_u32(), pg_atomic_sub_fetch_u32(), skip_parallel_vacuum_index(), vacuum_one_index(), and VacuumActiveNWorkers.
Referenced by lazy_parallel_vacuum_indexes().
|
static |
Definition at line 708 of file vacuumlazy.c.
References LVRelStats::latestRemovedXid, log_heap_cleanup_info(), RelationData::rd_node, RelationNeedsWAL, TransactionIdIsValid, and XLogIsNeeded.
Referenced by lazy_vacuum_all_indexes().
|
static |
Definition at line 2316 of file vacuumlazy.c.
References LVShared::estimated_count, LVShared::for_cleanup, lazy_cleanup_index(), lazy_vacuum_index(), pfree(), LVShared::reltuples, LVSharedIndStats::stats, and LVSharedIndStats::updated.
Referenced by parallel_vacuum_index(), and vacuum_indexes_leader().