aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access/transam/xlog.c
diff options
context:
space:
mode:
authorRobert Haas <rhaas@postgresql.org>2024-07-18 12:09:48 -0400
committerRobert Haas <rhaas@postgresql.org>2024-07-18 12:09:48 -0400
commit402b586d0a9caae9412d25fcf1b91dae45375833 (patch)
tree2c0ebdf24bdf1beefa3c98e5c5d2a9e7965e9eda /src/backend/access/transam/xlog.c
parenta0a5869a8598cdeae1d2f2d632038d26dcc69d19 (diff)
downloadpostgresql-402b586d0a9caae9412d25fcf1b91dae45375833.tar.gz
postgresql-402b586d0a9caae9412d25fcf1b91dae45375833.zip
Do not summarize WAL if generated with wal_level=minimal.
To do this, we must include the wal_level in the first WAL record covered by each summary file; so add wal_level to struct Checkpoint and the payload of XLOG_CHECKPOINT_REDO and XLOG_END_OF_RECOVERY. This, in turn, requires bumping XLOG_PAGE_MAGIC and, since the Checkpoint is also stored in the control file, also PG_CONTROL_VERSION. It's not great to do that so late in the release cycle, but the alternative seems to ship v17 without robust protections against this scenario, which could result in corrupted incremental backups. A side effect of this patch is that, when a server with wal_level=replica is started with summarize_wal=on for the first time, summarization will no longer begin with the oldest WAL that still exists in pg_wal, but rather from the first checkpoint after that. This change should be harmless, because a WAL summary for a partial checkpoint cycle can never make an incremental backup possible when it would otherwise not have been. Report by Fujii Masao. Patch by me. Review and/or testing by Jakub Wartak and Fujii Masao. Discussion: http://postgr.es/m/6e30082e-041b-4e31-9633-95a66de76f5d@oss.nttdata.com
Diffstat (limited to 'src/backend/access/transam/xlog.c')
-rw-r--r--src/backend/access/transam/xlog.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index 33e27a6e72c..636be5ca4da 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -6934,6 +6934,7 @@ CreateCheckPoint(int flags)
WALInsertLockAcquireExclusive();
checkPoint.fullPageWrites = Insert->fullPageWrites;
+ checkPoint.wal_level = wal_level;
if (shutdown)
{
@@ -6987,11 +6988,9 @@ CreateCheckPoint(int flags)
*/
if (!shutdown)
{
- int dummy = 0;
-
- /* Record must have payload to avoid assertion failure. */
+ /* Include WAL level in record for WAL summarizer's benefit. */
XLogBeginInsert();
- XLogRegisterData((char *) &dummy, sizeof(dummy));
+ XLogRegisterData((char *) &wal_level, sizeof(wal_level));
(void) XLogInsert(RM_XLOG_ID, XLOG_CHECKPOINT_REDO);
/*
@@ -7314,6 +7313,7 @@ CreateEndOfRecoveryRecord(void)
elog(ERROR, "can only be used to end recovery");
xlrec.end_time = GetCurrentTimestamp();
+ xlrec.wal_level = wal_level;
WALInsertLockAcquireExclusive();
xlrec.ThisTimeLineID = XLogCtl->InsertTimeLineID;