Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 57b100f

Browse files
committed
Fix some more bugs in GIN's WAL replay logic.
In commit 4016bde I fixed a bunch of ginxlog.c bugs having to do with not handling XLogReadBuffer failures correctly. However, in ginRedoUpdateMetapage and ginRedoDeleteListPages, I unaccountably thought that failure to read the metapage would be impossible and just put in an elog(PANIC) call. This is of course wrong: failure is exactly what will happen if the index got dropped (or rebuilt) between creation of the WAL record and the crash we're trying to recover from. I believe this explains Nicholas Wilson's recent report of these errors getting reached. Also, fix memory leak in forgetIncompleteSplit. This wasn't of much concern when the code was written, but in a long-running standby server page split records could be expected to accumulate indefinitely. Back-patch to 8.4 --- before that, GIN didn't have a metapage.
1 parent 64c47e4 commit 57b100f

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/backend/access/gin/ginxlog.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,12 @@ forgetIncompleteSplit(RelFileNode node, BlockNumber leftBlkno, BlockNumber updat
5959
{
6060
ginIncompleteSplit *split = (ginIncompleteSplit *) lfirst(l);
6161

62-
if (RelFileNodeEquals(node, split->node) && leftBlkno == split->leftBlkno && updateBlkno == split->rightBlkno)
62+
if (RelFileNodeEquals(node, split->node) &&
63+
leftBlkno == split->leftBlkno &&
64+
updateBlkno == split->rightBlkno)
6365
{
6466
incomplete_splits = list_delete_ptr(incomplete_splits, split);
67+
pfree(split);
6568
break;
6669
}
6770
}
@@ -487,7 +490,7 @@ ginRedoUpdateMetapage(XLogRecPtr lsn, XLogRecord *record)
487490

488491
metabuffer = XLogReadBuffer(data->node, GIN_METAPAGE_BLKNO, false);
489492
if (!BufferIsValid(metabuffer))
490-
elog(PANIC, "GIN metapage disappeared");
493+
return; /* assume index was deleted, nothing to do */
491494
metapage = BufferGetPage(metabuffer);
492495

493496
if (!XLByteLE(lsn, PageGetLSN(metapage)))
@@ -632,7 +635,7 @@ ginRedoDeleteListPages(XLogRecPtr lsn, XLogRecord *record)
632635

633636
metabuffer = XLogReadBuffer(data->node, GIN_METAPAGE_BLKNO, false);
634637
if (!BufferIsValid(metabuffer))
635-
elog(PANIC, "GIN metapage disappeared");
638+
return; /* assume index was deleted, nothing to do */
636639
metapage = BufferGetPage(metabuffer);
637640

638641
if (!XLByteLE(lsn, PageGetLSN(metapage)))

0 commit comments

Comments
 (0)