Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Reuse all-zero pages in GIN.
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Mon, 27 Jul 2015 09:30:26 +0000 (12:30 +0300)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Mon, 27 Jul 2015 09:32:48 +0000 (12:32 +0300)
In GIN, an all-zeros page would be leaked forever, and never reused. Just
add them to the FSM in vacuum, and they will be reinitialized when grabbed
from the FSM. On master and 9.5, attempting to access the page's opaque
struct also caused an assertion failure, although that was otherwise
harmless.

Reported by Jeff Janes. Backpatch to all supported versions.

src/backend/access/gin/ginvacuum.c

index be9c5e9ce4d7c8c5bbfd4e6b565cbac64ad7ef1b..8f58794a20829dfbd51f077769f63423a8811862 100644 (file)
@@ -760,7 +760,7 @@ ginvacuumcleanup(PG_FUNCTION_ARGS)
        LockBuffer(buffer, GIN_SHARE);
        page = (Page) BufferGetPage(buffer);
 
-       if (GinPageIsDeleted(page))
+       if (PageIsNew(page) || GinPageIsDeleted(page))
        {
            Assert(blkno != GIN_ROOT_BLKNO);
            RecordFreeIndexPage(index, blkno);