From e24c4f6fc90b2a1a9d16854a70642b77d51be1bf Mon Sep 17 00:00:00 2001 From: shenzhengntu <503699317@qq.com> Date: Sun, 26 Mar 2023 21:09:19 +0800 Subject: [PATCH] slave replay MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Code Source From: Self Code Description: [Optional] Jira: #[Optional] 市场项目编号(名称):[Optional] --- src/backend/access/transam/pagehashqueue.c | 2 +- src/backend/access/transam/xlog.c | 8 ++++++-- src/backend/access/transam/xlogreader.c | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/backend/access/transam/pagehashqueue.c b/src/backend/access/transam/pagehashqueue.c index e379453..18d363c 100644 --- a/src/backend/access/transam/pagehashqueue.c +++ b/src/backend/access/transam/pagehashqueue.c @@ -396,7 +396,7 @@ CleanLogIndexMain(int argc, char *argv[]) int hasData = 0; pushStandbyPrePoint = pushStandbyPoint; - if (push_standby == true||EnableHotStandby == false) { + if (push_standby == true || EnableHotStandby == false) { pushStandbyPoint = GetXLogPushToDisk(); if (pushStandbyPrePoint < pushStandbyPoint) { hasData++; diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index d57b065..cdeb7dc 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -5965,12 +5965,14 @@ ReadRecord(XLogReaderState *xlogreader, int emode, /* This is the first attempt to read this page. */ lastSourceFailed = false; #ifndef PG_NOREPLAY - if (push_standby == true && PushPtr == InvalidXLogRecPtr) + if ((push_standby == true || EnableHotStandby == false) && + xlogreader->streamStart == true && + PushPtr == InvalidXLogRecPtr) { PushPtr = xlogreader->EndRecPtr; PrePushPtr = xlogreader->EndRecPtr; ApplyLsn = PrePushPtr; - XLogCtl->pushToDisk = ApplyLsn; + //XLogCtl->pushToDisk = ApplyLsn; } #endif for (;;) @@ -12125,6 +12127,8 @@ void xlog_redo(XLogReaderState *record) { CheckPointPtr = record->currRecPtr; memcpy(&GlobalCheckPoint, XLogRecGetData(record), sizeof(CheckPoint)); + // for recover checkpoint must be flush disk,so set GlobalCheckPoint.redo = CheckPointPtr is ok + GlobalCheckPoint.redo = CheckPointPtr; GlobalState = DB_IN_ARCHIVE_RECOVERY; } #endif diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c index b421cb9..46259ff 100644 --- a/src/backend/access/transam/xlogreader.c +++ b/src/backend/access/transam/xlogreader.c @@ -722,7 +722,7 @@ restart: #ifndef PG_NOREPLAY if (IsBootstrapProcessingMode() != true && InitdbSingle!=true) { if (getpid() == startupPid) { - if (push_standby == true||EnableHotStandby == false) { + if (push_standby == true || EnableHotStandby == false) { // Update shared-memory status XLogRecPtr prevPushPoint = PrePushPtr; if (!XLogRecPtrIsInvalid(CheckPointPtr)) {