From: Heikki Linnakangas Date: Mon, 27 Jul 2015 09:30:26 +0000 (+0300) Subject: Reuse all-zero pages in GIN. X-Git-Tag: REL9_1_19~80 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a471700e3cd3c38529ace909984ef10562888084;p=thirdparty%2Fpostgresql.git Reuse all-zero pages in GIN. 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. --- diff --git a/src/backend/access/gin/ginvacuum.c b/src/backend/access/gin/ginvacuum.c index 3308bb2e629..98535833d2e 100644 --- a/src/backend/access/gin/ginvacuum.c +++ b/src/backend/access/gin/ginvacuum.c @@ -762,7 +762,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);