@ -402,6 +402,7 @@ static void knl_t_xlog_init(knl_t_xlog_context* xlog_cxt)
|
||||
xlog_cxt->LocalXLogInsertAllowed = -1;
|
||||
xlog_cxt->ArchiveRecoveryRequested = false;
|
||||
xlog_cxt->InArchiveRecovery = false;
|
||||
xlog_cxt->inRedoExtendSegment = false;
|
||||
xlog_cxt->ArchiveRestoreRequested = false;
|
||||
xlog_cxt->restoredFromArchive = false;
|
||||
xlog_cxt->recoveryRestoreCommand = NULL;
|
||||
|
||||
@ -1166,7 +1166,12 @@ static bool DispatchRepOriginRecord(XLogReaderState *record, List *expectedTLIs,
|
||||
/* Run from the dispatcher thread. */
|
||||
static bool DispatchCLogRecord(XLogReaderState *record, List *expectedTLIs, TimestampTz recordXTime)
|
||||
{
|
||||
DispatchTxnRecord(record, expectedTLIs, recordXTime, false);
|
||||
uint8 info = XLogRecGetInfo(record) & (~XLR_INFO_MASK);
|
||||
if (info == CLOG_ZEROPAGE) {
|
||||
DispatchRecordWithoutPage(record, expectedTLIs);
|
||||
} else {
|
||||
DispatchTxnRecord(record, expectedTLIs, recordXTime, false);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@ -2568,7 +2568,7 @@ Buffer ReadBuffer_common(SMgrRelation smgr, char relpersistence, ForkNumber fork
|
||||
* head may be re-used, i.e., the relfilenode may be reused. Thus the
|
||||
* smgrnblocks interface can not be used on standby. Just skip this check.
|
||||
*/
|
||||
} else if (RecoveryInProgress() && !IsSegmentFileNode(smgr->smgr_rnode.node)) {
|
||||
} else if (RecoveryInProgress()) {
|
||||
BlockNumber totalBlkNum = smgrnblocks_cached(smgr, forkNum);
|
||||
|
||||
/* Update cached blocks */
|
||||
@ -2576,7 +2576,8 @@ Buffer ReadBuffer_common(SMgrRelation smgr, char relpersistence, ForkNumber fork
|
||||
totalBlkNum = smgrnblocks(smgr, forkNum);
|
||||
}
|
||||
|
||||
if (blockNum >= totalBlkNum) {
|
||||
if ((blockNum >= totalBlkNum || totalBlkNum == InvalidBlockNumber) &&
|
||||
!t_thrd.xlog_cxt.inRedoExtendSegment) {
|
||||
return InvalidBuffer;
|
||||
}
|
||||
}
|
||||
|
||||
@ -643,6 +643,16 @@ static void redo_atomic_xlog(XLogReaderState *record)
|
||||
static void redo_seghead_extend(XLogReaderState *record)
|
||||
{
|
||||
RedoBufferInfo redo_buf;
|
||||
t_thrd.xlog_cxt.inRedoExtendSegment = true;
|
||||
XLogInitBufferForRedo(record, 1, &redo_buf);
|
||||
t_thrd.xlog_cxt.inRedoExtendSegment = false;
|
||||
if (BufferIsValid(redo_buf.buf)) {
|
||||
memset_s(redo_buf.pageinfo.page, BLCKSZ, 0, BLCKSZ);
|
||||
PageSetLSN(redo_buf.pageinfo.page, redo_buf.lsn);
|
||||
MarkBufferDirty(redo_buf.buf);
|
||||
UnlockReleaseBuffer(redo_buf.buf);
|
||||
}
|
||||
|
||||
XLogRedoAction redo_action = XLogReadBufferForRedo(record, 0, &redo_buf);
|
||||
if (redo_action == BLK_NEEDS_REDO) {
|
||||
char *data = XLogRecGetBlockData(record, 0, NULL);
|
||||
@ -667,13 +677,6 @@ static void redo_seghead_extend(XLogReaderState *record)
|
||||
if (SSCheckInitPageXLogSimple(record, 1, &redo_buf) == BLK_DONE) {
|
||||
return;
|
||||
}
|
||||
XLogInitBufferForRedo(record, 1, &redo_buf);
|
||||
if (BufferIsValid(redo_buf.buf)) {
|
||||
memset_s(redo_buf.pageinfo.page, BLCKSZ, 0, BLCKSZ);
|
||||
PageSetLSN(redo_buf.pageinfo.page, redo_buf.lsn);
|
||||
MarkBufferDirty(redo_buf.buf);
|
||||
UnlockReleaseBuffer(redo_buf.buf);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@ -516,6 +516,7 @@ typedef struct knl_t_xlog_context {
|
||||
*/
|
||||
bool ArchiveRecoveryRequested;
|
||||
bool InArchiveRecovery;
|
||||
bool inRedoExtendSegment;
|
||||
bool ArchiveRestoreRequested;
|
||||
|
||||
/* Was the last xlog file restored from archive, or local? */
|
||||
|
||||
Reference in New Issue
Block a user