postgres.git / summary / log / commit / refs
commit a590f266e44c492d2a252ab9dee0cd88dbe06dc5
Author: Alvaro Herrera <alvherre@alvh.no-ip.org>
Date: Mon Nov 10 21:13:49 2014 +0000
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.
src/backend/access/brin/brin_xlog.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/src/backend/access/brin/brin_xlog.c b/src/backend/access/brin/brin_xlog.c
index ebef984e7f1..29370689a70 100644
--- a/src/backend/access/brin/brin_xlog.c
+++ b/src/backend/access/brin/brin_xlog.c
@@ -60,9 +60,11 @@ brin_xlog_insert_update(XLogRecPtr lsn, XLogRecord *record,
*/
if (record->xl_info & XLOG_BRIN_INIT_PAGE)
{
- XLogReadBufferForRedoExtended(lsn, record, 0,
- xlrec->node, MAIN_FORKNUM, blkno,
- RBM_ZERO, false, &buffer);
+ /*
+ * No full-page image here. Don't try to read it, because there
+ * might be one for the revmap buffer, below.
+ */
+ buffer = XLogReadBuffer(xlrec->node, blkno, true);
page = BufferGetPage(buffer);
brin_page_init(page, BRIN_PAGETYPE_REGULAR);
action = BLK_NEEDS_REDO;
@@ -97,7 +99,9 @@ brin_xlog_insert_update(XLogRecPtr lsn, XLogRecord *record,
UnlockReleaseBuffer(buffer);
/* update the revmap */
- action = XLogReadBufferForRedo(lsn, record, 1, xlrec->node,
+ action = XLogReadBufferForRedo(lsn, record,
+ record->xl_info & XLOG_BRIN_INIT_PAGE ? 0 : 1,
+ xlrec->node,
xlrec->revmapBlk, &buffer);
if (action == BLK_NEEDS_REDO)
{
[parent: c8df9477f8ce]