PostgreSQL Source Code git master
|
#include "postgres.h"
#include "access/timeline.h"
#include "access/xlog.h"
#include "access/xlog_internal.h"
#include "access/xlogrecovery.h"
#include "access/xlogutils.h"
#include "backup/walsummary.h"
#include "catalog/storage_xlog.h"
#include "commands/dbcommands_xlog.h"
#include "common/blkreftable.h"
#include "libpq/pqsignal.h"
#include "miscadmin.h"
#include "postmaster/auxprocess.h"
#include "postmaster/interrupt.h"
#include "postmaster/walsummarizer.h"
#include "replication/walreceiver.h"
#include "storage/fd.h"
#include "storage/ipc.h"
#include "storage/latch.h"
#include "storage/lwlock.h"
#include "storage/proc.h"
#include "storage/procsignal.h"
#include "storage/shmem.h"
#include "utils/guc.h"
#include "utils/memutils.h"
#include "utils/wait_event.h"
Go to the source code of this file.
Data Structures | |
struct | WalSummarizerData |
struct | SummarizerReadLocalXLogPrivate |
Macros | |
#define | MAX_SLEEP_QUANTA 150 |
#define | MS_PER_SLEEP_QUANTUM 200 |
Variables | |
static WalSummarizerData * | WalSummarizerCtl |
static long | sleep_quanta = 1 |
static long | pages_read_since_last_sleep = 0 |
static XLogRecPtr | redo_pointer_at_last_summary_removal = InvalidXLogRecPtr |
bool | summarize_wal = false |
int | wal_summary_keep_time = 10 * HOURS_PER_DAY * MINS_PER_HOUR |
#define MAX_SLEEP_QUANTA 150 |
Definition at line 125 of file walsummarizer.c.
#define MS_PER_SLEEP_QUANTUM 200 |
Definition at line 126 of file walsummarizer.c.
|
static |
Definition at line 800 of file walsummarizer.c.
References GetFlushRecPtr(), GetWALInsertionTimeLineIfSet(), GetWalRcvFlushRecPtr(), GetXLogReplayRecPtr(), and RecoveryInProgress().
Referenced by GetOldestUnsummarizedLSN(), summarizer_read_local_xlog_page(), and WalSummarizerMain().
XLogRecPtr GetOldestUnsummarizedLSN | ( | TimeLineID * | tli, |
bool * | lsn_is_exact | ||
) |
Definition at line 505 of file walsummarizer.c.
References AmWalSummarizerProcess, WalSummaryFile::end_lsn, ereport, errcode(), errmsg_internal(), ERROR, GetLatestLSN(), GetWalSummaries(), WalSummarizerData::initialized, InvalidXLogRecPtr, lfirst, list_length(), list_nth(), WalSummarizerData::lsn_is_exact, LW_EXCLUSIVE, LW_SHARED, LWLockAcquire(), LWLockRelease(), WalSummarizerData::pending_lsn, readTimeLineHistory(), summarize_wal, WalSummarizerData::summarized_lsn, WalSummarizerData::summarized_tli, TimeLineHistoryEntry::tli, wal_segment_size, WalSummarizerCtl, XLogGetOldestSegno(), and XLogSegNoOffsetToRecPtr.
Referenced by KeepLogSeg(), and WalSummarizerMain().
void GetWalSummarizerState | ( | TimeLineID * | summarized_tli, |
XLogRecPtr * | summarized_lsn, | ||
XLogRecPtr * | pending_lsn, | ||
int * | summarizer_pid | ||
) |
Definition at line 447 of file walsummarizer.c.
References GetPGProcByNumber, WalSummarizerData::initialized, INVALID_PROC_NUMBER, InvalidXLogRecPtr, LW_SHARED, LWLockAcquire(), LWLockRelease(), WalSummarizerData::pending_lsn, WalSummarizerData::summarized_lsn, WalSummarizerData::summarized_tli, WalSummarizerData::summarizer_pgprocno, and WalSummarizerCtl.
Referenced by pg_get_wal_summarizer_state().
|
static |
Definition at line 858 of file walsummarizer.c.
References ConfigReloadPending, DEBUG1, ereport, errmsg_internal(), LogMemoryContextPending, PGC_SIGHUP, proc_exit(), ProcessConfigFile(), ProcessLogMemoryContextInterrupt(), ProcessProcSignalBarrier(), ProcSignalBarrierPending, ShutdownRequestPending, and summarize_wal.
Referenced by MaybeRemoveOldWalSummaries(), summarizer_read_local_xlog_page(), SummarizeWAL(), and WalSummarizerMain().
|
static |
Definition at line 1654 of file walsummarizer.c.
References WalSummaryFile::end_lsn, foreach_delete_current, GetRedoRecPtr(), GetWalSummaries(), HandleWalSummarizerInterrupts(), InvalidXLogRecPtr, lfirst, linitial, NIL, pfree(), redo_pointer_at_last_summary_removal, RemoveWalSummaryIfOlderThan(), SECS_PER_MINUTE, WalSummaryFile::tli, wal_segment_size, wal_summary_keep_time, XLogGetOldestSegno(), XLogRecPtrIsInvalid, and XLogSegNoOffsetToRecPtr.
Referenced by WalSummarizerMain().
|
static |
Definition at line 1246 of file walsummarizer.c.
References BlockRefTableSetLimitBlock(), xl_dbase_create_file_copy_rec::db_id, xl_dbase_create_wal_log_rec::db_id, xl_dbase_drop_rec::db_id, RelFileLocator::dbOid, i, MAIN_FORKNUM, xl_dbase_drop_rec::ntablespaces, RelFileLocator::relNumber, RelFileLocator::spcOid, xl_dbase_create_file_copy_rec::tablespace_id, xl_dbase_create_wal_log_rec::tablespace_id, xl_dbase_drop_rec::tablespace_ids, XLOG_DBASE_CREATE_FILE_COPY, XLOG_DBASE_CREATE_WAL_LOG, XLOG_DBASE_DROP, xlogreader, XLogRecGetData, and XLogRecGetInfo.
Referenced by SummarizeWAL().
|
static |
Definition at line 1497 of file walsummarizer.c.
References Assert, DEBUG1, SummarizerReadLocalXLogPrivate::end_of_wal, ereport, errmsg_internal(), GetLatestLSN(), HandleWalSummarizerInterrupts(), SummarizerReadLocalXLogPrivate::historic, LSN_FORMAT_ARGS, pages_read_since_last_sleep, SummarizerReadLocalXLogPrivate::read_upto, readTimeLineHistory(), summarizer_wait_for_wal(), SummarizerReadLocalXLogPrivate::tli, tliSwitchPoint(), WALRead(), WALReadRaiseError(), and while().
Referenced by SummarizeWAL().
|
static |
Definition at line 1611 of file walsummarizer.c.
References MAX_SLEEP_QUANTA, Min, MS_PER_SLEEP_QUANTUM, MyLatch, pages_read_since_last_sleep, ResetLatch(), sleep_quanta, WaitLatch(), WL_EXIT_ON_PM_DEATH, WL_LATCH_SET, and WL_TIMEOUT.
Referenced by summarizer_read_local_xlog_page().
|
static |
Definition at line 1315 of file walsummarizer.c.
References xl_smgr_truncate::blkno, BlockRefTableSetLimitBlock(), xl_smgr_truncate::flags, xl_smgr_create::forkNum, FSM_FORKNUM, MAIN_FORKNUM, xl_smgr_create::rlocator, xl_smgr_truncate::rlocator, SMGR_TRUNCATE_HEAP, SMGR_TRUNCATE_VM, VISIBILITYMAP_FORKNUM, XLOG_SMGR_CREATE, XLOG_SMGR_TRUNCATE, xlogreader, XLogRecGetData, and XLogRecGetInfo.
Referenced by SummarizeWAL().
|
static |
Definition at line 906 of file walsummarizer.c.
References Assert, BlockRefTableMarkBlockModified(), DEBUG1, durable_rename(), SummarizerReadLocalXLogPrivate::end_of_wal, XLogReaderState::EndRecPtr, ereport, errcode(), errcode_for_file_access(), errdetail(), errmsg(), errmsg_internal(), ERROR, WalSummaryIO::file, FileClose(), WalSummaryIO::filepos, FSM_FORKNUM, HandleWalSummarizerInterrupts(), SummarizerReadLocalXLogPrivate::historic, LSN_FORMAT_ARGS, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), MAXPGPATH, palloc0(), PathNameOpenFile(), WalSummarizerData::pending_lsn, pfree(), XLogReaderState::private_data, SummarizerReadLocalXLogPrivate::read_upto, XLogReaderState::ReadRecPtr, snprintf, WalSummarizerData::summarized_lsn, SummarizeDbaseRecord(), summarizer_read_local_xlog_page(), SummarizeSmgrRecord(), SummarizeXactRecord(), SummarizeXlogRecord(), SummarizerReadLocalXLogPrivate::tli, wal_segment_close(), wal_segment_open(), wal_segment_size, WalSummarizerCtl, WriteBlockRefTable(), WriteWalSummary(), XL_ROUTINE, XLogBeginRead(), XLOGDIR, XLogFindNextRecord(), xlogreader, XLogReaderAllocate(), XLogReaderFree(), XLogReadRecord(), XLogRecGetBlockTagExtended(), XLogRecGetRmid, XLogRecMaxBlockId, and XLogRecPtrIsInvalid.
Referenced by WalSummarizerMain().
|
static |
Definition at line 1364 of file walsummarizer.c.
References BlockRefTableSetLimitBlock(), FSM_FORKNUM, i, MAX_FORKNUM, xl_xact_parsed_commit::nrels, xl_xact_parsed_abort::nrels, ParseAbortRecord(), ParseCommitRecord(), xl_xact_parsed_commit::xlocators, xl_xact_parsed_abort::xlocators, XLOG_XACT_ABORT, XLOG_XACT_ABORT_PREPARED, XLOG_XACT_COMMIT, XLOG_XACT_COMMIT_PREPARED, XLOG_XACT_OPMASK, xlogreader, XLogRecGetData, and XLogRecGetInfo.
Referenced by SummarizeWAL().
|
static |
Definition at line 1424 of file walsummarizer.c.
References xl_parameter_change::wal_level, xl_end_of_recovery::wal_level, CheckPoint::wal_level, WAL_LEVEL_MINIMAL, XLOG_CHECKPOINT_REDO, XLOG_CHECKPOINT_SHUTDOWN, XLOG_END_OF_RECOVERY, XLOG_PARAMETER_CHANGE, xlogreader, XLogRecGetData, and XLogRecGetInfo.
Referenced by SummarizeWAL().
void WaitForWalSummarization | ( | XLogRecPtr | lsn | ) |
Definition at line 660 of file walsummarizer.c.
References CHECK_FOR_INTERRUPTS, ConditionVariableCancelSleep(), ConditionVariableTimedSleep(), ereport, errcode(), errdetail(), errmsg(), errmsg_plural(), ERROR, GetCurrentTimestamp(), InvalidXLogRecPtr, LSN_FORMAT_ARGS, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), WalSummarizerData::pending_lsn, summarize_wal, WalSummarizerData::summarized_lsn, WalSummarizerData::summary_file_cv, TimestampDifferenceMilliseconds(), TimestampTzPlusMilliseconds, WalSummarizerCtl, and WARNING.
Referenced by CleanupAfterArchiveRecovery(), and PrepareForIncrementalBackup().
void WakeupWalSummarizer | ( | void | ) |
Definition at line 637 of file walsummarizer.c.
References PROC_HDR::allProcs, INVALID_PROC_NUMBER, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), ProcGlobal, PGPROC::procLatch, SetLatch(), WalSummarizerData::summarizer_pgprocno, and WalSummarizerCtl.
Referenced by CreateCheckPoint().
void WalSummarizerMain | ( | char * | startup_data, |
size_t | startup_data_len | ||
) |
Definition at line 211 of file walsummarizer.c.
References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, Assert, AtEOXact_Files(), AtEOXact_HashTables(), AuxiliaryProcessMainCommon(), B_WAL_SUMMARIZER, ConditionVariableBroadcast(), ConditionVariableCancelSleep(), DEBUG1, EmitErrorReport(), ereport, errmsg_internal(), error_context_stack, FlushErrorState(), GetLatestLSN(), GetOldestUnsummarizedLSN(), HandleWalSummarizerInterrupts(), HOLD_INTERRUPTS, InvalidXLogRecPtr, LSN_FORMAT_ARGS, WalSummarizerData::lsn_is_exact, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), LWLockReleaseAll(), MaybeRemoveOldWalSummaries(), MemoryContextReset(), MemoryContextSwitchTo(), MyBackendType, MyProcNumber, on_shmem_exit(), WalSummarizerData::pending_lsn, PG_exception_stack, pgstat_report_wait_end(), pqsignal, proc_exit(), procsignal_sigusr1_handler(), readTimeLineHistory(), ReleaseAuxProcessResources(), RESUME_INTERRUPTS, SIGALRM, SIGCHLD, SIGHUP, SignalHandlerForConfigReload(), SignalHandlerForShutdownRequest(), SIGPIPE, SIGUSR1, SIGUSR2, WalSummarizerData::summarized_lsn, WalSummarizerData::summarized_tli, WalSummarizerData::summarizer_pgprocno, SummarizeWAL(), WalSummarizerData::summary_file_cv, tliSwitchPoint(), TopMemoryContext, UnBlockSig, WaitLatch(), WalSummarizerCtl, WalSummarizerShutdown(), WL_EXIT_ON_PM_DEATH, WL_TIMEOUT, and XLogRecPtrIsInvalid.
void WalSummarizerShmemInit | ( | void | ) |
Definition at line 180 of file walsummarizer.c.
References ConditionVariableInit(), WalSummarizerData::initialized, INVALID_PROC_NUMBER, InvalidXLogRecPtr, WalSummarizerData::lsn_is_exact, WalSummarizerData::pending_lsn, ShmemInitStruct(), WalSummarizerData::summarized_lsn, WalSummarizerData::summarized_tli, WalSummarizerData::summarizer_pgprocno, WalSummarizerData::summary_file_cv, WalSummarizerCtl, and WalSummarizerShmemSize().
Referenced by CreateOrAttachShmemStructs().
Size WalSummarizerShmemSize | ( | void | ) |
Definition at line 171 of file walsummarizer.c.
Referenced by CalculateShmemSize(), and WalSummarizerShmemInit().
|
static |
Definition at line 788 of file walsummarizer.c.
References INVALID_PROC_NUMBER, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), WalSummarizerData::summarizer_pgprocno, and WalSummarizerCtl.
Referenced by WalSummarizerMain().
|
static |
Definition at line 132 of file walsummarizer.c.
Referenced by summarizer_read_local_xlog_page(), and summarizer_wait_for_wal().
|
static |
Definition at line 137 of file walsummarizer.c.
Referenced by MaybeRemoveOldWalSummaries().
|
static |
Definition at line 115 of file walsummarizer.c.
Referenced by summarizer_wait_for_wal().
bool summarize_wal = false |
Definition at line 142 of file walsummarizer.c.
Referenced by CleanupAfterArchiveRecovery(), GetOldestUnsummarizedLSN(), HandleWalSummarizerInterrupts(), LaunchMissingBackgroundProcesses(), parse_basebackup_options(), PostmasterMain(), and WaitForWalSummarization().
int wal_summary_keep_time = 10 * HOURS_PER_DAY * MINS_PER_HOUR |
Definition at line 143 of file walsummarizer.c.
Referenced by MaybeRemoveOldWalSummaries().
|
static |
Definition at line 107 of file walsummarizer.c.
Referenced by GetOldestUnsummarizedLSN(), GetWalSummarizerState(), SummarizeWAL(), WaitForWalSummarization(), WakeupWalSummarizer(), WalSummarizerMain(), WalSummarizerShmemInit(), and WalSummarizerShutdown().