PostgreSQL Source Code
git master
|
#include "postgres.h"
#include <unistd.h>
#include "access/timeline.h"
#include "access/xlog.h"
#include "access/xlog_internal.h"
#include "access/xlogutils.h"
#include "miscadmin.h"
#include "pgstat.h"
#include "storage/smgr.h"
#include "utils/guc.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 |
static HTAB * | invalid_page_tab = NULL |
typedef FakeRelCacheEntryData* FakeRelCacheEntry |
Definition at line 537 of file xlogutils.c.
typedef struct xl_invalid_page xl_invalid_page |
typedef struct xl_invalid_page_key xl_invalid_page_key |
Relation CreateFakeRelcacheEntry | ( | RelFileNode | rnode | ) |
Definition at line 554 of file xlogutils.c.
References LockRelId::dbId, RelFileNode::dbNode, InvalidBackendId, LockInfoData::lockRelId, palloc0(), FakeRelCacheEntryData::pgc, RelationData::rd_backend, RelationData::rd_lockInfo, RelationData::rd_node, RelationData::rd_rel, RelationData::rd_smgr, RelationGetRelationName, LockRelId::relId, RelFileNode::relNode, 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 145 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(), xl_invalid_page::key, message_level_is_interesting(), xl_invalid_page_key::node, pfree(), RelFileNodeEquals, relpathperm, and status().
Referenced by XLogDropRelation(), and XLogTruncateRelation().
|
static |
Definition at line 180 of file xlogutils.c.
References xl_invalid_page_key::blkno, RelFileNode::dbNode, DEBUG2, elog, ERROR, xl_invalid_page_key::forkno, HASH_REMOVE, hash_search(), hash_seq_init(), hash_seq_search(), xl_invalid_page::key, message_level_is_interesting(), xl_invalid_page_key::node, pfree(), relpathperm, and status().
Referenced by XLogDropDatabase().
void FreeFakeRelcacheEntry | ( | Relation | fakerel | ) |
Definition at line 597 of file xlogutils.c.
References pfree(), RelationData::rd_smgr, and smgrclearowner().
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 81 of file xlogutils.c.
References xl_invalid_page_key::blkno, DEBUG1, elog, HASHCTL::entrysize, xl_invalid_page_key::forkno, HASH_BLOBS, hash_create(), HASH_ELEM, HASH_ENTER, hash_search(), ignore_invalid_pages, sort-test::key, HASHCTL::keysize, message_level_is_interesting(), xl_invalid_page_key::node, 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 828 of file xlogutils.c.
References CHECK_FOR_INTERRUPTS, XLogReaderState::currTLI, XLogReaderState::currTLIValidUntil, GetFlushRecPtr(), GetXLogReplayRecPtr(), pg_usleep(), RecoveryInProgress(), ThisTimeLineID, WALRead(), WALReadRaiseError(), and XLogReadDetermineTimeline().
Referenced by create_logical_replication_slot(), pg_logical_replication_slot_advance(), pg_logical_slot_get_changes_guts(), and XlogReadTwoPhaseData().
|
static |
Definition at line 65 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 809 of file xlogutils.c.
References close, XLogReaderState::seg, and WALOpenSegment::ws_file.
Referenced by create_logical_replication_slot(), CreateReplicationSlot(), pg_logical_replication_slot_advance(), pg_logical_slot_get_changes_guts(), StartLogicalReplication(), StartReplication(), StartupXLOG(), WalSndErrorCleanup(), XlogReadTwoPhaseData(), and XLogSendPhysical().
void wal_segment_open | ( | XLogReaderState * | state, |
XLogSegNo | nextSegNo, | ||
TimeLineID * | tli_p | ||
) |
Definition at line 784 of file xlogutils.c.
References BasicOpenFile(), ereport, errcode_for_file_access(), errmsg(), ERROR, MAXPGPATH, PG_BINARY, XLogReaderState::seg, XLogReaderState::segcxt, WALOpenSegment::ws_file, WALSegmentContext::ws_segsize, and XLogFilePath.
Referenced by create_logical_replication_slot(), pg_logical_replication_slot_advance(), pg_logical_slot_get_changes_guts(), and XlogReadTwoPhaseData().
void WALReadRaiseError | ( | WALReadError * | errinfo | ) |
Definition at line 955 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(), and XLogSendPhysical().
void XLogCheckInvalidPages | ( | void | ) |
Definition at line 223 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, xl_invalid_page::key, xl_invalid_page_key::node, PANIC, xl_invalid_page::present, report_invalid_page(), status(), and WARNING.
Referenced by CheckRecoveryConsistency().
void XLogDropDatabase | ( | Oid | dbid | ) |
Definition at line 623 of file xlogutils.c.
References forget_invalid_pages_db(), and smgrcloseall().
Referenced by dbase_redo().
void XLogDropRelation | ( | RelFileNode | rnode, |
ForkNumber | forknum | ||
) |
Definition at line 612 of file xlogutils.c.
References forget_invalid_pages().
Referenced by DropRelationFiles().
bool XLogHaveInvalidPages | ( | void | ) |
Definition at line 213 of file xlogutils.c.
References hash_get_num_entries().
Referenced by RecoveryRestartPoint().
Buffer XLogInitBufferForRedo | ( | XLogReaderState * | record, |
uint8 | block_id | ||
) |
Definition at line 304 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(), hash_xlog_split_allocate_page(), heap_xlog_insert(), heap_xlog_multi_insert(), heap_xlog_update(), seq_redo(), spgRedoAddLeaf(), spgRedoAddNode(), spgRedoMoveLeafs(), spgRedoPickSplit(), and spgRedoSplitTuple().
Buffer XLogReadBufferExtended | ( | RelFileNode | rnode, |
ForkNumber | forknum, | ||
BlockNumber | blkno, | ||
ReadBufferMode | mode | ||
) |
Definition at line 439 of file xlogutils.c.
References Assert, BUFFER_LOCK_UNLOCK, BufferGetBlockNumber(), BufferGetPage, InRecovery, InvalidBackendId, InvalidBuffer, LockBuffer(), log_invalid_page(), P_NEW, PageIsNew, RBM_NORMAL, RBM_NORMAL_NO_LOG, RBM_ZERO_AND_CLEANUP_LOCK, RBM_ZERO_AND_LOCK, ReadBufferWithoutRelcache(), ReleaseBuffer(), smgrcreate(), smgrnblocks(), and smgropen().
Referenced by checkXLogConsistency(), XLogReadBufferForRedoExtended(), and XLogRecordPageWithFreeSpace().
XLogRedoAction XLogReadBufferForRedo | ( | XLogReaderState * | record, |
uint8 | block_id, | ||
Buffer * | buf | ||
) |
Definition at line 292 of file xlogutils.c.
References 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_freeze_page(), 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 329 of file xlogutils.c.
References Assert, BKPBLOCK_WILL_INIT, BLK_DONE, BLK_NEEDS_REDO, BLK_NOTFOUND, BLK_RESTORED, xl_invalid_page_key::blkno, XLogReaderState::blocks, BUFFER_LOCK_EXCLUSIVE, BufferGetPage, BufferIsValid, elog, XLogReaderState::EndRecPtr, ERROR, DecodedBkpBlock::flags, FlushOneBuffer(), INIT_FORKNUM, LockBuffer(), LockBufferForCleanup(), MarkBufferDirty(), PageGetLSN, PageIsNew, PageSetLSN, PANIC, RBM_ZERO_AND_CLEANUP_LOCK, RBM_ZERO_AND_LOCK, RestoreBlockImage(), XLogReadBufferExtended(), XLogRecBlockImageApply, XLogRecGetBlockTag(), 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_clean(), heap_xlog_visible(), XLogInitBufferForRedo(), and XLogReadBufferForRedo().
void XLogReadDetermineTimeline | ( | XLogReaderState * | state, |
XLogRecPtr | wantPage, | ||
uint32 | wantLength | ||
) |
Definition at line 687 of file xlogutils.c.
References Assert, XLogReaderState::currTLI, XLogReaderState::currTLIValidUntil, DEBUG3, elog, InvalidXLogRecPtr, list_free_deep(), LSN_FORMAT_ARGS, Min, XLogReaderState::nextTLI, XLogReaderState::readLen, readTimeLineHistory(), XLogReaderState::seg, XLogReaderState::segcxt, XLogReaderState::segoff, ThisTimeLineID, tliOfPointInHistory(), tliSwitchPoint(), WALOpenSegment::ws_segno, and WALSegmentContext::ws_segsize.
Referenced by logical_read_xlog_page(), and read_local_xlog_page().
void XLogTruncateRelation | ( | RelFileNode | rnode, |
ForkNumber | forkNum, | ||
BlockNumber | nblocks | ||
) |
Definition at line 642 of file xlogutils.c.
References forget_invalid_pages().
Referenced by smgr_redo().
Definition at line 35 of file xlogutils.c.
Referenced by log_invalid_page(), and XLogCheckInvalidPages().
|
static |
Definition at line 60 of file xlogutils.c.