slave memory has page to replay

Code Source From: Self Code
Description:  【Optional】
Jira:  #【Optional】
市场项目编号(名称):【Optional】
This commit is contained in:
shenzhengntu 2023-03-27 10:15:56 +08:00
parent e24c4f6fc9
commit 24be5c4dcc

View File

@ -8088,6 +8088,31 @@ void pushTikv(int onePageListLen,int pageNum,bool flag)
}
}
static void pageInMemoryFlushBufferToDisk(BufferTag*tag) {
Buffer buffer = XLogReadBufferExtended(tag->rnode, tag->forkNum, tag->blockNum,
RBM_NORMAL);
if (!BufferIsValid(buffer))
{
elog(ERROR,"pageInMemoryFlushBufferToDisk is invalid rel %d,flk %d,blk %d",tag->rnode.relNode,tag->forkNum,tag->blockNum);
return;
}
//slave no need to flush disk
if (push_standby == true) {
BufferDesc *buf;
buf = GetBufferDescriptor(buffer-1);
uint32 buf_state = pg_atomic_read_u32(&buf->state);
if (buf_state & BM_DIRTY) {
LWLockAcquire(BufferDescriptorGetContentLock(buf),
LW_SHARED);
FlushOneBuffer(buffer);
LWLockRelease(BufferDescriptorGetContentLock(buf));
ScheduleBufferTagForWriteback(&BackendWritebackContext,
&buf->tag);
}
}
ReleaseBuffer(buffer);
}
static bool
data_buffer_for_replay(XLogReaderState *record,XLogRecPtr startLsn,XLogRecPtr endLsn)
{
@ -8135,6 +8160,9 @@ data_buffer_for_replay(XLogReaderState *record,XLogRecPtr startLsn,XLogRecPtr en
UnlockBufHdr(buf, buf_state);
}
updateLastReplayLsn();
if (EnableHotStandby == true && push_standby == false) {
pageInMemoryFlushBufferToDisks(&tag);
}
ReleaseBuffer(buffer);
} else {
updateLastReplayLsn();