0003-Create-XLogAcceptWrites-function-with-code-from-Star.patch
application/octet-stream
Filename: 0003-Create-XLogAcceptWrites-function-with-code-from-Star.patch
Type: application/octet-stream
Part: 2
Message:
Re: [Patch] ALTER SYSTEM READ ONLY
Patch
Format: format-patch
Series: patch 0003
Subject: Create XLogAcceptWrites() function with code from StartupXLOG().
| File | + | − |
|---|---|---|
| src/backend/access/transam/xlog.c | 46 | 29 |
From 0f14c0e6534e4d24432dffc6388ef04543ff4fe6 Mon Sep 17 00:00:00 2001
From: Robert Haas <rhaas@postgresql.org>
Date: Fri, 23 Jul 2021 15:37:53 -0400
Subject: [PATCH 3/3] Create XLogAcceptWrites() function with code from
StartupXLOG().
This is just code movement. A future patch will want to defer the
call to XLogAcceptWrites() until a later time, rather than doing
it as soon as we finish applying WAL, but here we're just grouping
related code together into a new function.
---
src/backend/access/transam/xlog.c | 75 +++++++++++++++++++------------
1 file changed, 46 insertions(+), 29 deletions(-)
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index c652a0635d..9707bba1d3 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -973,6 +973,9 @@ static void UpdateMinRecoveryPoint(XLogRecPtr lsn, bool force);
static XLogRecord *ReadRecord(XLogReaderState *xlogreader,
int emode, bool fetching_ckpt);
static void CheckRecoveryConsistency(void);
+static void XLogAcceptWrites(RecoveryXlogAction xlogaction,
+ TimeLineID EndOfLogTLI,
+ XLogRecPtr EndOfLog);
static RecoveryXlogAction DetermineRecoveryXlogAction(XLogReaderState *xlogreader);
static void PerformRecoveryXLogAction(RecoveryXlogAction action);
static XLogRecord *ReadCheckpointRecord(XLogReaderState *xlogreader,
@@ -8056,35 +8059,8 @@ StartupXLOG(void)
}
XLogReaderFree(xlogreader);
- /*
- * Update full_page_writes in shared memory and write an XLOG_FPW_CHANGE
- * record before resource manager writes cleanup WAL records or checkpoint
- * record is written.
- */
- Insert->fullPageWrites = lastFullPageWrites;
- LocalSetXLogInsertAllowed();
- UpdateFullPageWrites();
- LocalXLogInsertAllowed = -1;
-
- /* Emit checkpoint or end-of-recovery record in XLOG, if required. */
- PerformRecoveryXLogAction(xlogaction);
-
- /* If this is archive recovery, perform post-recovery cleanup actions. */
- if (ArchiveRecoveryRequested)
- CleanupAfterArchiveRecovery(EndOfLogTLI, EndOfLog);
-
- /*
- * If any of the critical GUCs have changed, log them before we allow
- * backends to write WAL.
- */
- LocalSetXLogInsertAllowed();
- XLogReportParameters();
-
- /*
- * Local WAL inserts enabled, so it's time to finish initialization of
- * commit timestamp.
- */
- CompleteCommitTsInitialization();
+ /* Prepare to accept WAL writes. */
+ XLogAcceptWrites(xlogaction, EndOfLogTLI, EndOfLog);
/*
* All done with end-of-recovery actions.
@@ -8128,6 +8104,47 @@ StartupXLOG(void)
RequestCheckpoint(CHECKPOINT_FORCE);
}
+/*
+ * Prepare to accept WAL writes.
+ */
+static void
+XLogAcceptWrites(RecoveryXlogAction xlogaction,
+ TimeLineID EndOfLogTLI,
+ XLogRecPtr EndOfLog)
+{
+ XLogCtlInsert *Insert = &XLogCtl->Insert;
+
+ /*
+ * Update full_page_writes in shared memory and write an XLOG_FPW_CHANGE
+ * record before resource manager writes cleanup WAL records or checkpoint
+ * record is written.
+ */
+ Insert->fullPageWrites = lastFullPageWrites;
+ LocalSetXLogInsertAllowed();
+ UpdateFullPageWrites();
+ LocalXLogInsertAllowed = -1;
+
+ /* Emit checkpoint or end-of-recovery record in XLOG, if required. */
+ PerformRecoveryXLogAction(xlogaction);
+
+ /* If this is archive recovery, perform post-recovery cleanup actions. */
+ if (ArchiveRecoveryRequested)
+ CleanupAfterArchiveRecovery(EndOfLogTLI, EndOfLog);
+
+ /*
+ * If any of the critical GUCs have changed, log them before we allow
+ * backends to write WAL.
+ */
+ LocalSetXLogInsertAllowed();
+ XLogReportParameters();
+
+ /*
+ * Local WAL inserts enabled, so it's time to finish initialization of
+ * commit timestamp.
+ */
+ CompleteCommitTsInitialization();
+}
+
/*
* Checks if recovery has reached a consistent state. When consistency is
* reached and we have a valid starting standby snapshot, tell postmaster
--
2.24.3 (Apple Git-128)