71 elog(elevel,
"page %u of relation %s is uninitialized",
74 elog(elevel,
"page %u of relation %s does not exist",
100 "WAL contains references to invalid pages");
111 if (invalid_page_tab == NULL)
119 invalid_page_tab =
hash_create(
"XLOG invalid-page table",
150 if (invalid_page_tab == NULL)
165 elog(
DEBUG2,
"page %u of relation %s has been dropped",
171 (
void *) &hentry->
key,
185 if (invalid_page_tab == NULL)
198 elog(
DEBUG2,
"page %u of relation %s has been dropped",
204 (
void *) &hentry->
key,
215 if (invalid_page_tab != NULL &&
227 bool foundone =
false;
229 if (invalid_page_tab == NULL)
247 "WAL contains references to invalid pages");
250 invalid_page_tab = NULL;
345 elog(
PANIC,
"failed to locate backup block with ID %d", block_id);
354 if (willinit && !zeromode)
355 elog(
PANIC,
"block with WILL_INIT flag in WAL record must be zeroed by redo routine");
356 if (!willinit && zeromode)
357 elog(
PANIC,
"block to be initialized in redo routine must be marked with WILL_INIT flag in the WAL record");
367 elog(
ERROR,
"failed to restore block image");
398 if (get_cleanup_lock)
463 if (blkno < lastblock)
573 rel->
rd_rel->relpersistence = RELPERSISTENCE_PERMANENT;
693 Assert(wantLength <= XLOG_BLCKSZ);
704 if (lastReadPage == wantPage &&
706 lastReadPage + state->
readLen >= wantPage +
Min(wantLength, XLOG_BLCKSZ - 1))
772 wantPage + wantLength < state->currTLIValidUntil);
776 elog(
DEBUG3,
"switched to timeline %u valid until %X/%X",
798 errmsg(
"requested WAL segment %s has already been removed",
803 errmsg(
"could not open file \"%s\": %m",
829 int reqLen,
XLogRecPtr targetRecPtr,
char *cur_page)
837 loc = targetPagePtr + reqLen;
885 if (loc <= read_upto)
918 if (targetPagePtr + XLOG_BLCKSZ <= read_upto)
926 else if (targetPagePtr + reqLen > read_upto)
934 count = read_upto - targetPagePtr;
942 if (!
WALRead(state, cur_page, targetPagePtr, XLOG_BLCKSZ, tli,
967 errmsg(
"could not read from log segment %s, offset %u: %m",
974 errmsg(
"could not read from log segment %s, offset %u: read %d of %zu",
bool XLogHaveInvalidPages(void)
void XLogTruncateRelation(RelFileNode rnode, ForkNumber forkNum, BlockNumber nblocks)
static PgChecksumMode mode
#define BUFFER_LOCK_UNLOCK
void hash_destroy(HTAB *hashp)
void LockBufferForCleanup(Buffer buffer)
#define relpathperm(rnode, forknum)
#define InvalidXLogRecPtr
TimeLineID tliOfPointInHistory(XLogRecPtr ptr, List *history)
void smgrcreate(SMgrRelation reln, ForkNumber forknum, bool isRedo)
void wal_segment_close(XLogReaderState *state)
void smgrclearowner(SMgrRelation *owner, SMgrRelation reln)
struct xl_invalid_page xl_invalid_page
#define XLogRecHasBlockImage(decoder, block_id)
void MarkBufferDirty(Buffer buffer)
static void forget_invalid_pages_db(Oid dbid)
struct SMgrRelationData * rd_smgr
void XLogCheckInvalidPages(void)
void WALReadRaiseError(WALReadError *errinfo)
List * readTimeLineHistory(TimeLineID targetTLI)
Buffer XLogReadBufferExtended(RelFileNode rnode, ForkNumber forknum, BlockNumber blkno, ReadBufferMode mode)
Buffer ReadBufferWithoutRelcache(RelFileNode rnode, ForkNumber forkNum, BlockNumber blockNum, ReadBufferMode mode, BufferAccessStrategy strategy)
void wal_segment_open(XLogReaderState *state, XLogSegNo nextSegNo, TimeLineID *tli_p)
int errcode(int sqlerrcode)
struct xl_invalid_page_key xl_invalid_page_key
long hash_get_num_entries(HTAB *hashp)
XLogRecPtr GetFlushRecPtr(void)
void ReleaseBuffer(Buffer buffer)
void * hash_search(HTAB *hashp, const void *keyPtr, HASHACTION action, bool *foundPtr)
#define BUFFER_LOCK_EXCLUSIVE
bool RecoveryInProgress(void)
void list_free_deep(List *list)
void XLogReadDetermineTimeline(XLogReaderState *state, XLogRecPtr wantPage, uint32 wantLength)
void pg_usleep(long microsec)
#define LSN_FORMAT_ARGS(lsn)
struct RelationData * Relation
void pfree(void *pointer)
static void report_invalid_page(int elevel, RelFileNode node, ForkNumber forkno, BlockNumber blkno, bool present)
Buffer XLogInitBufferForRedo(XLogReaderState *record, uint8 block_id)
static void log_invalid_page(RelFileNode node, ForkNumber forkno, BlockNumber blkno, bool present)
XLogRecPtr GetXLogReplayRecPtr(TimeLineID *replayTLI)
bool message_level_is_interesting(int elevel)
Relation CreateFakeRelcacheEntry(RelFileNode rnode)
static void forget_invalid_pages(RelFileNode node, ForkNumber forkno, BlockNumber minblkno)
int errcode_for_file_access(void)
XLogRecPtr currTLIValidUntil
#define RelationGetRelationName(relation)
HTAB * hash_create(const char *tabname, long nelem, const HASHCTL *info, int flags)
#define BufferGetPage(buffer)
#define BKPBLOCK_WILL_INIT
bool ignore_invalid_pages
SMgrRelation smgropen(RelFileNode rnode, BackendId backend)
#define ERRCODE_DATA_CORRUPTED
void FreeFakeRelcacheEntry(Relation fakerel)
bool XLogRecGetBlockTag(XLogReaderState *record, uint8 block_id, RelFileNode *rnode, ForkNumber *forknum, BlockNumber *blknum)
void * palloc0(Size size)
void LockBuffer(Buffer buffer, int mode)
XLogRecPtr tliSwitchPoint(TimeLineID tli, List *history, TimeLineID *nextTLI)
TimeLineID ThisTimeLineID
#define ereport(elevel,...)
XLogRedoAction XLogReadBufferForRedo(XLogReaderState *record, uint8 block_id, Buffer *buf)
BlockNumber smgrnblocks(SMgrRelation reln, ForkNumber forknum)
FakeRelCacheEntryData * FakeRelCacheEntry
#define Assert(condition)
#define XLogFileName(fname, tli, logSegNo, wal_segsz_bytes)
#define BufferIsValid(bufnum)
void * hash_seq_search(HASH_SEQ_STATUS *status)
void hash_seq_init(HASH_SEQ_STATUS *status, HTAB *hashp)
void FlushOneBuffer(Buffer buffer)
bool RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page)
int BasicOpenFile(const char *fileName, int fileFlags)
#define XLogFilePath(path, tli, logSegNo, wal_segsz_bytes)
BlockNumber BufferGetBlockNumber(Buffer buffer)
void XLogDropRelation(RelFileNode rnode, ForkNumber forknum)
int errmsg(const char *fmt,...)
XLogRedoAction XLogReadBufferForRedoExtended(XLogReaderState *record, uint8 block_id, ReadBufferMode mode, bool get_cleanup_lock, Buffer *buf)
void XLogDropDatabase(Oid dbid)
static HTAB * invalid_page_tab
bool WALRead(XLogReaderState *state, char *buf, XLogRecPtr startptr, Size count, TimeLineID tli, WALReadError *errinfo)
#define CHECK_FOR_INTERRUPTS()
#define XLogRecBlockImageApply(decoder, block_id)
static void static void status(const char *fmt,...) pg_attribute_printf(1
int read_local_xlog_page(XLogReaderState *state, XLogRecPtr targetPagePtr, int reqLen, XLogRecPtr targetRecPtr, char *cur_page)
#define PageSetLSN(page, lsn)
#define RelFileNodeEquals(node1, node2)
DecodedBkpBlock blocks[XLR_MAX_BLOCK_ID+1]