From cc5f9211d161725f82545a77477c47d13fa5f5f8 Mon Sep 17 00:00:00 2001 From: Greg Burd Date: Tue, 27 Oct 2026 13:17:24 -0400 Subject: [PATCH v1 2/2] [NOT FOR MERGE] Remove REGBUF_NO_CHANGE Preview of the follow-up step, to show the end state after the hash rework: with hash no longer registering clean or pin-only buffers, there are no users of REGBUF_NO_CHANGE left, and XLogRegisterBuffer() can assert unconditionally that every registered buffer is locked and dirty. On a tree that has the REGBUF_NO_CHANGE full-page-image fix applied, this step would also restore the Assert(XLogRecHasBlockImage()) in verifyBackupPageConsistency() and drop the XLogRecordAssemble() special case; on master neither exists yet, so there is nothing to undo here. --- src/backend/access/transam/xloginsert.c | 21 ++++++--------------- src/include/access/xloginsert.h | 1 - 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c index 59b0dfe436d..7212cbb84dc 100644 --- a/src/backend/access/transam/xloginsert.c +++ b/src/backend/access/transam/xloginsert.c @@ -256,22 +256,13 @@ XLogRegisterBuffer(uint8 block_id, Buffer buffer, uint8 flags) Assert(begininsert_called); /* - * Ordinarily, the buffer should be exclusive-locked (or share-exclusive - * in case of hint bits) and marked dirty before we get here, otherwise we - * could end up violating one of the rules in access/transam/README. - * - * Some callers intentionally register a clean page and never update that - * page's LSN; in that case they can pass the flag REGBUF_NO_CHANGE to - * bypass these checks. + * The buffer must be exclusive-locked (or share-exclusive in case of hint + * bits) and marked dirty before we get here, otherwise we could end up + * violating one of the rules in access/transam/README. */ -#ifdef USE_ASSERT_CHECKING - if (!(flags & REGBUF_NO_CHANGE)) - { - Assert(BufferIsDirty(buffer)); - Assert(BufferIsLockedByMeInMode(buffer, BUFFER_LOCK_EXCLUSIVE) || - BufferIsLockedByMeInMode(buffer, BUFFER_LOCK_SHARE_EXCLUSIVE)); - } -#endif + Assert(BufferIsDirty(buffer)); + Assert(BufferIsLockedByMeInMode(buffer, BUFFER_LOCK_EXCLUSIVE) || + BufferIsLockedByMeInMode(buffer, BUFFER_LOCK_SHARE_EXCLUSIVE)); if (block_id >= max_registered_block_id) { diff --git a/src/include/access/xloginsert.h b/src/include/access/xloginsert.h index 91dfbd5627f..ddb1a85db59 100644 --- a/src/include/access/xloginsert.h +++ b/src/include/access/xloginsert.h @@ -38,7 +38,6 @@ * will be skipped) */ #define REGBUF_KEEP_DATA 0x10 /* include data even if a full-page image * is taken */ -#define REGBUF_NO_CHANGE 0x20 /* intentionally register clean buffer */ /* prototypes for public functions in xloginsert.c: */ extern void XLogBeginInsert(void); -- 2.50.1