Skip to content

Commit a590f26

Browse files
committed
BRIN: fix bug in xlog backup block counting
The code that generates the BRIN_XLOG_UPDATE removes the buffer reference when the page that's target for the updated tuple is freshly initialized. This is a pretty usual optimization, but was breaking the case where the revmap buffer, which is referenced in the same WAL record, is getting a backup block: the replay code was using backup block index 1, which is not valid when the update target buffer gets pruned; the revmap buffer gets assigned 0 instead. Make sure to use the correct backup block index for revmap when replaying. Bug reported by Fujii Masao.
1 parent c8df947 commit a590f26

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/backend/access/brin/brin_xlog.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,11 @@ brin_xlog_insert_update(XLogRecPtr lsn, XLogRecord *record,
6060
*/
6161
if (record->xl_info & XLOG_BRIN_INIT_PAGE)
6262
{
63-
XLogReadBufferForRedoExtended(lsn, record, 0,
64-
xlrec->node, MAIN_FORKNUM, blkno,
65-
RBM_ZERO, false, &buffer);
63+
/*
64+
* No full-page image here. Don't try to read it, because there
65+
* might be one for the revmap buffer, below.
66+
*/
67+
buffer = XLogReadBuffer(xlrec->node, blkno, true);
6668
page = BufferGetPage(buffer);
6769
brin_page_init(page, BRIN_PAGETYPE_REGULAR);
6870
action = BLK_NEEDS_REDO;
@@ -97,7 +99,9 @@ brin_xlog_insert_update(XLogRecPtr lsn, XLogRecord *record,
9799
UnlockReleaseBuffer(buffer);
98100

99101
/* update the revmap */
100-
action = XLogReadBufferForRedo(lsn, record, 1, xlrec->node,
102+
action = XLogReadBufferForRedo(lsn, record,
103+
record->xl_info & XLOG_BRIN_INIT_PAGE ? 0 : 1,
104+
xlrec->node,
101105
xlrec->revmapBlk, &buffer);
102106
if (action == BLK_NEEDS_REDO)
103107
{

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy