diff options
author | Alvaro Herrera <alvherre@alvh.no-ip.org> | 2022-08-05 18:00:17 +0200 |
---|---|---|
committer | Alvaro Herrera <alvherre@alvh.no-ip.org> | 2022-08-05 18:00:17 +0200 |
commit | 541f41d4fa783ce213f15d4f5faaca5bb7a50559 (patch) | |
tree | 9959b5ba24c5512edc9ec31258bf2c102638436c /src/backend | |
parent | 8ad6c5dbbe5a234c55c6663020db297251756006 (diff) | |
download | postgresql-541f41d4fa783ce213f15d4f5faaca5bb7a50559.tar.gz postgresql-541f41d4fa783ce213f15d4f5faaca5bb7a50559.zip |
BRIN: mask BRIN_EVACUATE_PAGE for WAL consistency checking
That bit is unlogged and therefore it's wrong to consider it in WAL page
comparison.
Add a test that tickles the case, as branch testing technology allows.
This has been a problem ever since wal consistency checking was
introduced (commit a507b86900f6 for pg10), so backpatch to all supported
branches.
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
Diffstat (limited to 'src/backend')
-rw-r--r-- | src/backend/access/brin/brin_pageops.c | 7 | ||||
-rw-r--r-- | src/backend/access/brin/brin_xlog.c | 6 |
2 files changed, 12 insertions, 1 deletions
diff --git a/src/backend/access/brin/brin_pageops.c b/src/backend/access/brin/brin_pageops.c index df9ffc2fb86..992b33a8964 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 39dc130e162..3519038b709 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; } |