Fujii Masao wrote: > I got the following PANIC error in the standby server when I set up > the replication servers and ran "make installcheck". Note that I was > repeating the manual CHECKPOINT every second while "installcheck" > was running. Without the checkpoints, I could not reproduce the > problem. I'm not sure if CHECKPOINT really triggers this problem, though. > Anyway BRIN seems to have a problem around its WAL replay.
Hm, I think I see what's happening. The xl_brin_update record references two buffers, one which is target for the updated tuple and another which is the revmap buffer. When the update target buffer is being first used we set the INIT bit which removes the buffer reference from the xlog record; in that case, if the revmap buffer is first being modified after the prior checkpoint, that revmap buffer receives backup block number 0; but the code hardcodes it as 1 on the expectation that the buffer that's target for the update will receive 0. The attached patch should fix this. I cannot reproduce the issue after applying this patch, can you please confirm that it fixes the issue for you as well? -- Álvaro Herrera http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services
diff --git a/src/backend/access/brin/brin_xlog.c b/src/backend/access/brin/brin_xlog.c index ebef984..2937068 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) {
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers