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

Commit 1b63075

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 b5c077c commit 1b63075

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
@@ -58,9 +58,12 @@ forgetIncompleteSplit(RelFileNode node, BlockNumber leftBlkno, BlockNumber updat
5858
{
5959
ginIncompleteSplit *split = (ginIncompleteSplit *) lfirst(l);
6060

61-
if (RelFileNodeEquals(node, split->node) && leftBlkno == split->leftBlkno && updateBlkno == split->rightBlkno)
61+
if (RelFileNodeEquals(node, split->node) &&
62+
leftBlkno == split->leftBlkno &&
63+
updateBlkno == split->rightBlkno)
6264
{
6365
incomplete_splits = list_delete_ptr(incomplete_splits, split);
66+
pfree(split);
6467
break;
6568
}
6669
}
@@ -486,7 +489,7 @@ ginRedoUpdateMetapage(XLogRecPtr lsn, XLogRecord *record)
486489

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

492495
if (!XLByteLE(lsn, PageGetLSN(metapage)))
@@ -631,7 +634,7 @@ ginRedoDeleteListPages(XLogRecPtr lsn, XLogRecord *record)
631634

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

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

0 commit comments

Comments
 (0)