pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alvaro Herrera <alvherre@alvh.no-ip.org>
Subject: [PATCH v3 2/2] BRIN: mask BRIN_EVACUATE_PAGE for WAL consistency checking
Date: Fri, 5 Aug 2022 13:38:06 +0200

That bit is unlogged and therefore it's wrong to consider it in WAL page
comparison.

Add a test that tickles the case.

Author: 王海洋 (Haiyang Wang) <wanghaiyang.001@bytedance.com>
Reviewed-by: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Discussion: https://postgr.es/m/CACciXAD2UvLMOhc4jX9VvOKt7DtYLr3OYRBhvOZ-jRxtzc_7Jg@mail.gmail.com
Discussion: https://postgr.es/m/CACciXADOfErX9Bx0nzE_SkdfXr6Bbpo5R=v_B6MUTEYW4ya+cg@mail.gmail.com
---
 src/backend/access/brin/brin_pageops.c | 7 ++++++-
 src/backend/access/brin/brin_xlog.c    | 6 ++++++
 2 files changed, 12 insertions(+), 1 deletion(-)

inline patch 1: src/backend/access/brin/brin_pageops.c, src/backend/access/brin/brin_xlog.c (+12/-1 lines) download inline-1.patchdiff --git a/src/backend/access/brin/brin_pageops.c b/src/backend/access/brin/brin_pageops.c index 17257919db..f17aad51b6 100644 --- a/src/backend/access/brin/brin_pageops.c +++ b/src/backend/access/brin/brin_pageops.c @@ -541,7 +541,12 @@ brin_start_evacuating_page(Relation idxRel, Buffer buf) lp = PageGetItemId(page, off); if (ItemIdIsUsed(lp)) { - /* prevent other backends from adding more stuff to this page */ + /* + * Prevent other backends from adding more stuff to this page: + * BRIN_EVACUATE_PAGE informs br_page_get_freespace that this page + * can no longer be used to add new tuples. Note that this flag + * is not WAL-logged, except accidentally. + */ BrinPageFlags(page) |= BRIN_EVACUATE_PAGE; MarkBufferDirtyHint(buf, true); diff --git a/src/backend/access/brin/brin_xlog.c b/src/backend/access/brin/brin_xlog.c index d6fcea24d2..af6949882a 100644 --- a/src/backend/access/brin/brin_xlog.c +++ b/src/backend/access/brin/brin_xlog.c @@ -358,4 +358,10 @@ brin_mask(char *pagedata, BlockNumber blkno) { mask_unused_space(page); } + + /* + * BRIN_EVACUATE_PAGE is not WAL-logged, since it's of no use in recovery. + * Mask it. See brin_start_evacuating_page() for details. + */ + BrinPageFlags(page) &= ~BRIN_EVACUATE_PAGE; } -- 2.30.2
--ns56zz23hhgviqbt--

Message-ID: <no-message-id-29260@localhost>
Permalink:  ../no-message-id-29260@localhost/
Also on:    postgresql.org/message-id/no-message-id-29260@localhost

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: alvherre@alvh.no-ip.org
  Subject: Re: [PATCH v3 2/2] BRIN: mask BRIN_EVACUATE_PAGE for WAL consistency checking
  In-Reply-To: <no-message-id-29260@localhost>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox