PostgreSQL Source Code git master
|
#include "postgres.h"
#include <unistd.h>
#include "access/timeline.h"
#include "access/xlogrecovery.h"
#include "access/xlog_internal.h"
#include "access/xlogutils.h"
#include "miscadmin.h"
#include "storage/fd.h"
#include "storage/smgr.h"
#include "utils/hsearch.h"
#include "utils/rel.h"
Go to the source code of this file.
Data Structures | |
struct | xl_invalid_page_key |
struct | xl_invalid_page |
struct | FakeRelCacheEntryData |
Typedefs | |
typedef struct xl_invalid_page_key | xl_invalid_page_key |
typedef struct xl_invalid_page | xl_invalid_page |
typedef FakeRelCacheEntryData * | FakeRelCacheEntry |
Variables | |
bool | ignore_invalid_pages = false |
bool | InRecovery = false |
HotStandbyState | standbyState = STANDBY_DISABLED |
static HTAB * | invalid_page_tab = NULL |
typedef FakeRelCacheEntryData* FakeRelCacheEntry |
Definition at line 565 of file xlogutils.c.
typedef struct xl_invalid_page xl_invalid_page |
typedef struct xl_invalid_page_key xl_invalid_page_key |
Relation CreateFakeRelcacheEntry | ( | RelFileLocator | rlocator | ) |
Definition at line 582 of file xlogutils.c.
References LockRelId::dbId, RelFileLocator::dbOid, INVALID_PROC_NUMBER, LockInfoData::lockRelId, palloc0(), FakeRelCacheEntryData::pgc, RelationData::rd_backend, RelationData::rd_locator, RelationData::rd_lockInfo, RelationData::rd_rel, RelationData::rd_smgr, RelationGetRelationName, LockRelId::relId, RelFileLocator::relNumber, smgropen(), and sprintf.
Referenced by heap_xlog_delete(), heap_xlog_insert(), heap_xlog_lock(), heap_xlog_lock_updated(), heap_xlog_multi_insert(), heap_xlog_update(), heap_xlog_visible(), smgr_redo(), and smgrDoPendingSyncs().
|
static |
Definition at line 166 of file xlogutils.c.
References xl_invalid_page_key::blkno, DEBUG2, elog, ERROR, xl_invalid_page_key::forkno, HASH_REMOVE, hash_search(), hash_seq_init(), hash_seq_search(), invalid_page_tab, xl_invalid_page::key, xl_invalid_page_key::locator, message_level_is_interesting(), pfree(), RelFileLocatorEquals, and relpathperm.
Referenced by XLogDropRelation(), and XLogTruncateRelation().
|
static |
Definition at line 202 of file xlogutils.c.
References xl_invalid_page_key::blkno, RelFileLocator::dbOid, DEBUG2, elog, ERROR, xl_invalid_page_key::forkno, HASH_REMOVE, hash_search(), hash_seq_init(), hash_seq_search(), invalid_page_tab, xl_invalid_page::key, xl_invalid_page_key::locator, message_level_is_interesting(), pfree(), and relpathperm.
Referenced by XLogDropDatabase().
void FreeFakeRelcacheEntry | ( | Relation | fakerel | ) |
Definition at line 629 of file xlogutils.c.
References pfree().
Referenced by heap_xlog_delete(), heap_xlog_insert(), heap_xlog_lock(), heap_xlog_lock_updated(), heap_xlog_multi_insert(), heap_xlog_update(), heap_xlog_visible(), smgr_redo(), and smgrDoPendingSyncs().
|
static |
Definition at line 102 of file xlogutils.c.
References ctl, DEBUG1, elog, HASH_BLOBS, hash_create(), HASH_ELEM, HASH_ENTER, hash_search(), ignore_invalid_pages, invalid_page_tab, sort-test::key, message_level_is_interesting(), PANIC, xl_invalid_page::present, reachedConsistency, report_invalid_page(), and WARNING.
Referenced by XLogReadBufferExtended().
int read_local_xlog_page | ( | XLogReaderState * | state, |
XLogRecPtr | targetPagePtr, | ||
int | reqLen, | ||
XLogRecPtr | targetRecPtr, | ||
char * | cur_page | ||
) |
Definition at line 861 of file xlogutils.c.
References read_local_xlog_page_guts().
Referenced by create_logical_replication_slot(), LogicalReplicationSlotHasPendingWal(), LogicalSlotAdvanceAndCheckSnapState(), pg_logical_slot_get_changes_guts(), and XlogReadTwoPhaseData().
|
static |
Definition at line 885 of file xlogutils.c.
References CHECK_FOR_INTERRUPTS, ReadLocalXLogPageNoWaitPrivate::end_of_wal, GetFlushRecPtr(), GetXLogReplayRecPtr(), pg_usleep(), RecoveryInProgress(), WALRead(), WALReadRaiseError(), and XLogReadDetermineTimeline().
Referenced by read_local_xlog_page(), and read_local_xlog_page_no_wait().
int read_local_xlog_page_no_wait | ( | XLogReaderState * | state, |
XLogRecPtr | targetPagePtr, | ||
int | reqLen, | ||
XLogRecPtr | targetRecPtr, | ||
char * | cur_page | ||
) |
Definition at line 873 of file xlogutils.c.
References read_local_xlog_page_guts().
Referenced by InitXLogReaderState().
|
static |
Definition at line 86 of file xlogutils.c.
References elog, pfree(), and relpathperm.
Referenced by log_invalid_page(), and XLogCheckInvalidPages().
void wal_segment_close | ( | XLogReaderState * | state | ) |
Definition at line 842 of file xlogutils.c.
References close.
Referenced by create_logical_replication_slot(), CreateReplicationSlot(), InitWalRecovery(), InitXLogReaderState(), LogicalReplicationSlotHasPendingWal(), LogicalSlotAdvanceAndCheckSnapState(), pg_logical_slot_get_changes_guts(), StartLogicalReplication(), StartReplication(), SummarizeWAL(), WalSndErrorCleanup(), XlogReadTwoPhaseData(), and XLogSendPhysical().
void wal_segment_open | ( | XLogReaderState * | state, |
XLogSegNo | nextSegNo, | ||
TimeLineID * | tli_p | ||
) |
Definition at line 817 of file xlogutils.c.
References BasicOpenFile(), ereport, errcode_for_file_access(), errmsg(), ERROR, MAXPGPATH, PG_BINARY, and XLogFilePath().
Referenced by create_logical_replication_slot(), InitXLogReaderState(), LogicalReplicationSlotHasPendingWal(), LogicalSlotAdvanceAndCheckSnapState(), pg_logical_slot_get_changes_guts(), SummarizeWAL(), and XlogReadTwoPhaseData().
void WALReadRaiseError | ( | WALReadError * | errinfo | ) |
Definition at line 1020 of file xlogutils.c.
References ereport, errcode(), ERRCODE_DATA_CORRUPTED, errcode_for_file_access(), errmsg(), ERROR, MAXFNAMELEN, wal_segment_size, WALReadError::wre_errno, WALReadError::wre_off, WALReadError::wre_read, WALReadError::wre_req, WALReadError::wre_seg, WALOpenSegment::ws_segno, WALOpenSegment::ws_tli, and XLogFileName().
Referenced by logical_read_xlog_page(), read_local_xlog_page_guts(), summarizer_read_local_xlog_page(), and XLogSendPhysical().
void XLogCheckInvalidPages | ( | void | ) |
Definition at line 245 of file xlogutils.c.
References xl_invalid_page_key::blkno, elog, xl_invalid_page_key::forkno, hash_destroy(), hash_seq_init(), hash_seq_search(), ignore_invalid_pages, invalid_page_tab, xl_invalid_page::key, xl_invalid_page_key::locator, PANIC, xl_invalid_page::present, report_invalid_page(), and WARNING.
Referenced by CheckRecoveryConsistency().
void XLogDropDatabase | ( | Oid | dbid | ) |
Definition at line 652 of file xlogutils.c.
References forget_invalid_pages_db(), and smgrdestroyall().
Referenced by dbase_redo().
void XLogDropRelation | ( | RelFileLocator | rlocator, |
ForkNumber | forknum | ||
) |
Definition at line 641 of file xlogutils.c.
References forget_invalid_pages().
Referenced by DropRelationFiles().
bool XLogHaveInvalidPages | ( | void | ) |
Definition at line 235 of file xlogutils.c.
References hash_get_num_entries(), and invalid_page_tab.
Referenced by RecoveryRestartPoint().
Buffer XLogInitBufferForRedo | ( | XLogReaderState * | record, |
uint8 | block_id | ||
) |
Definition at line 326 of file xlogutils.c.
References buf, RBM_ZERO_AND_LOCK, and XLogReadBufferForRedoExtended().
Referenced by _bt_restore_meta(), brin_xlog_createidx(), brin_xlog_insert_update(), brin_xlog_revmap_extend(), btree_xlog_mark_page_halfdead(), btree_xlog_newroot(), btree_xlog_split(), btree_xlog_unlink_page(), ginRedoCreatePTree(), ginRedoDeleteListPages(), ginRedoInsertListPage(), ginRedoUpdateMetapage(), gistRedoPageSplitRecord(), hash_xlog_add_ovfl_page(), hash_xlog_init_bitmap_page(), hash_xlog_init_meta_page(), heap_xlog_insert(), heap_xlog_multi_insert(), heap_xlog_update(), seq_redo(), spgRedoAddLeaf(), spgRedoAddNode(), spgRedoMoveLeafs(), spgRedoPickSplit(), and spgRedoSplitTuple().
Buffer XLogReadBufferExtended | ( | RelFileLocator | rlocator, |
ForkNumber | forknum, | ||
BlockNumber | blkno, | ||
ReadBufferMode | mode, | ||
Buffer | recent_buffer | ||
) |
Definition at line 471 of file xlogutils.c.
References Assert, BMR_SMGR, BufferGetPage(), BufferIsValid(), EB_PERFORMING_RECOVERY, EB_SKIP_EXTENSION_LOCK, ExtendBufferedRelTo(), InRecovery, INVALID_PROC_NUMBER, InvalidBuffer, log_invalid_page(), mode, P_NEW, PageIsNew(), RBM_NORMAL, RBM_NORMAL_NO_LOG, ReadBufferWithoutRelcache(), ReadRecentBuffer(), ReleaseBuffer(), smgrcreate(), smgrnblocks(), and smgropen().
Referenced by verifyBackupPageConsistency(), XLogReadBufferForRedoExtended(), and XLogRecordPageWithFreeSpace().
XLogRedoAction XLogReadBufferForRedo | ( | XLogReaderState * | record, |
uint8 | block_id, | ||
Buffer * | buf | ||
) |
Definition at line 314 of file xlogutils.c.
References buf, RBM_NORMAL, and XLogReadBufferForRedoExtended().
Referenced by _bt_clear_incomplete_split(), brin_xlog_desummarize_page(), brin_xlog_insert_update(), brin_xlog_revmap_extend(), brin_xlog_samepage_update(), brin_xlog_update(), btree_xlog_dedup(), btree_xlog_delete(), btree_xlog_insert(), btree_xlog_mark_page_halfdead(), btree_xlog_split(), btree_xlog_unlink_page(), generic_redo(), ginRedoClearIncompleteSplit(), ginRedoDeletePage(), ginRedoInsert(), ginRedoSplit(), ginRedoUpdateMetapage(), ginRedoVacuumDataLeafPage(), ginRedoVacuumPage(), gistRedoClearFollowRight(), gistRedoDeleteRecord(), gistRedoPageDelete(), gistRedoPageUpdateRecord(), hash_xlog_add_ovfl_page(), hash_xlog_delete(), hash_xlog_init_bitmap_page(), hash_xlog_insert(), hash_xlog_move_page_contents(), hash_xlog_split_allocate_page(), hash_xlog_split_cleanup(), hash_xlog_split_complete(), hash_xlog_split_page(), hash_xlog_squeeze_page(), hash_xlog_update_meta_page(), hash_xlog_vacuum_one_page(), heap_xlog_confirm(), heap_xlog_delete(), heap_xlog_inplace(), heap_xlog_insert(), heap_xlog_lock(), heap_xlog_lock_updated(), heap_xlog_multi_insert(), heap_xlog_update(), heap_xlog_visible(), spgRedoAddLeaf(), spgRedoAddNode(), spgRedoMoveLeafs(), spgRedoPickSplit(), spgRedoSplitTuple(), spgRedoVacuumLeaf(), spgRedoVacuumRedirect(), spgRedoVacuumRoot(), and xlog_redo().
XLogRedoAction XLogReadBufferForRedoExtended | ( | XLogReaderState * | record, |
uint8 | block_id, | ||
ReadBufferMode | mode, | ||
bool | get_cleanup_lock, | ||
Buffer * | buf | ||
) |
Definition at line 351 of file xlogutils.c.
References Assert, BKPBLOCK_WILL_INIT, BLK_DONE, BLK_NEEDS_REDO, BLK_NOTFOUND, BLK_RESTORED, buf, BUFFER_LOCK_EXCLUSIVE, BufferGetPage(), BufferIsValid(), elog, XLogReaderState::EndRecPtr, ereport, errcode(), errmsg_internal(), ERROR, XLogReaderState::errormsg_buf, FlushOneBuffer(), INIT_FORKNUM, LockBuffer(), LockBufferForCleanup(), MarkBufferDirty(), mode, PageGetLSN(), PageIsNew(), PageSetLSN(), PANIC, RBM_ZERO_AND_CLEANUP_LOCK, RBM_ZERO_AND_LOCK, RestoreBlockImage(), XLogReadBufferExtended(), XLogRecBlockImageApply, XLogRecGetBlock, XLogRecGetBlockTagExtended(), and XLogRecHasBlockImage.
Referenced by btree_xlog_vacuum(), hash_xlog_delete(), hash_xlog_move_page_contents(), hash_xlog_split_allocate_page(), hash_xlog_squeeze_page(), hash_xlog_vacuum_one_page(), heap_xlog_prune_freeze(), heap_xlog_visible(), XLogInitBufferForRedo(), and XLogReadBufferForRedo().
void XLogReadDetermineTimeline | ( | XLogReaderState * | state, |
XLogRecPtr | wantPage, | ||
uint32 | wantLength, | ||
TimeLineID | currTLI | ||
) |
Definition at line 718 of file xlogutils.c.
References Assert, DEBUG3, elog, InvalidXLogRecPtr, list_free_deep(), LSN_FORMAT_ARGS, Min, readTimeLineHistory(), tliOfPointInHistory(), and tliSwitchPoint().
Referenced by logical_read_xlog_page(), and read_local_xlog_page_guts().
void XLogTruncateRelation | ( | RelFileLocator | rlocator, |
ForkNumber | forkNum, | ||
BlockNumber | nblocks | ||
) |
Definition at line 671 of file xlogutils.c.
References forget_invalid_pages().
Referenced by smgr_redo().
bool ignore_invalid_pages = false |
Definition at line 34 of file xlogutils.c.
Referenced by log_invalid_page(), and XLogCheckInvalidPages().
bool InRecovery = false |
Definition at line 50 of file xlogutils.c.
Referenced by _mdfd_getseg(), CheckRecoveryConflictDeadlock(), create_tablespace_directories(), ExtendCommitTs(), FinishWalRecovery(), FreeSpaceMapPrepareTruncateRel(), GetXLogReceiptTime(), InitWalRecovery(), LockAcquireExtended(), mdexists(), mdprefetch(), mdreadv(), mdtruncate(), MultiXactAdvanceOldest(), ProcSleep(), SetMultiXactIdLimit(), SetTransactionIdLimit(), SlruPhysicalReadPage(), smgrnblocks_cached(), StartupXLOG(), TransactionIdSetStatusBit(), UpdateMinRecoveryPoint(), visibilitymap_prepare_truncate(), visibilitymap_set(), xlog_redo(), XLogNeedsFlush(), and XLogReadBufferExtended().
|
static |
Definition at line 78 of file xlogutils.c.
Referenced by forget_invalid_pages(), forget_invalid_pages_db(), log_invalid_page(), XLogCheckInvalidPages(), and XLogHaveInvalidPages().
HotStandbyState standbyState = STANDBY_DISABLED |
Definition at line 53 of file xlogutils.c.
Referenced by ApplyWalRecord(), CheckRecoveryConsistency(), ExpireTreeKnownAssignedTransactionIds(), InitRecoveryTransactionEnvironment(), ProcArrayApplyRecoveryInfo(), ProcArrayApplyXidAssignment(), ProcArrayInitRecovery(), RecordKnownAssignedTransactionIds(), standby_redo(), StartupProcExit(), StartupXLOG(), xact_redo(), xact_redo_abort(), xact_redo_commit(), and xlog_redo().