Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a590f26

Browse filesBrowse 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
Copy full SHA for a590f26

File tree

Expand file treeCollapse file tree

1 file changed

+8
-4
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+8
-4
lines changed

‎src/backend/access/brin/brin_xlog.c

Copy file name to clipboardExpand all lines: src/backend/access/brin/brin_xlog.c
+8-4Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.