From e7f6ce3bc5f3415fd9630b53009b33d1257ab9df Mon Sep 17 00:00:00 2001 From: Matthias van de Meent Date: Thu, 26 Feb 2026 15:42:36 +0100 Subject: [PATCH v1] Remove XLP_BKP_REMOVABLE There are no known users of this flag (the last supposed user was lesslog), and there was a known race condition making the reliance on this flag impractical. --- src/backend/access/transam/xlog.c | 22 ---------------------- src/include/access/xlog_internal.h | 5 ++--- 2 files changed, 2 insertions(+), 25 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 13cce9b49f1..2ee1abb80fa 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -2114,22 +2114,6 @@ AdvanceXLInsertBuffer(XLogRecPtr upto, TimeLineID tli, bool opportunistic) /* NewPage->xlp_rem_len = 0; */ /* done by memset */ - /* - * If online backup is not in progress, mark the header to indicate - * that WAL records beginning in this page have removable backup - * blocks. This allows the WAL archiver to know whether it is safe to - * compress archived WAL data by transforming full-block records into - * the non-full-block format. It is sufficient to record this at the - * page level because we force a page switch (in fact a segment - * switch) when starting a backup, so the flag will be off before any - * records can be written during the backup. At the end of a backup, - * the last page will be marked as all unsafe when perhaps only part - * is unsafe, but at worst the archiver would miss the opportunity to - * compress a few records. - */ - if (Insert->runningBackups == 0) - NewPage->xlp_info |= XLP_BKP_REMOVABLE; - /* * If first page of an XLOG segment file, make it a long header. */ @@ -9037,12 +9021,6 @@ do_pg_backup_start(const char *backupidstr, bool fast, List **tablespaces, * pg_wal directory was not included in the base backup and the WAL * archive was cleared too before starting the backup. * - * This also ensures that we have emitted a WAL page header that has - * XLP_BKP_REMOVABLE off before we emit the checkpoint record. - * Therefore, if a WAL archiver (such as pglesslog) is trying to - * compress out removable backup blocks, it won't remove any that - * occur after this point. - * * During recovery, we skip forcing XLOG file switch, which means that * the backup taken during recovery is not available for the special * recovery case described above. diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h index fbc5d77ab39..62e4310e92d 100644 --- a/src/include/access/xlog_internal.h +++ b/src/include/access/xlog_internal.h @@ -74,12 +74,11 @@ typedef XLogLongPageHeaderData *XLogLongPageHeader; #define XLP_FIRST_IS_CONTRECORD 0x0001 /* This flag indicates a "long" page header */ #define XLP_LONG_HEADER 0x0002 -/* This flag indicates backup blocks starting in this page are optional */ -#define XLP_BKP_REMOVABLE 0x0004 +/* 0x0004 is unused */ /* Replaces a missing contrecord; see CreateOverwriteContrecordRecord */ #define XLP_FIRST_IS_OVERWRITE_CONTRECORD 0x0008 /* All defined flag bits in xlp_info (used for validity checking of header) */ -#define XLP_ALL_FLAGS 0x000F +#define XLP_ALL_FLAGS 0x000B #define XLogPageHeaderSize(hdr) \ (((hdr)->xlp_info & XLP_LONG_HEADER) ? SizeOfXLogLongPHD : SizeOfXLogShortPHD) -- 2.50.1 (Apple Git-155)