From ddd50d0488db184290700c644e546b217cdcc8c8 Mon Sep 17 00:00:00 2001 From: Robert Haas Date: Thu, 9 Dec 2021 18:15:56 -0500 Subject: [PATCH] when vacuuming, handle uninitialized index pages without barfing --- src/backend/access/conveyor/conveyor.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/backend/access/conveyor/conveyor.c b/src/backend/access/conveyor/conveyor.c index cb6adab6ce..431a01c9f8 100644 --- a/src/backend/access/conveyor/conveyor.c +++ b/src/backend/access/conveyor/conveyor.c @@ -1267,6 +1267,23 @@ ConveyorBeltClearIndexSegmentEntries(ConveyorBelt *cb, Buffer metabuffer, indexbuffer = ConveyorBeltRead(cb, indexblock, BUFFER_LOCK_EXCLUSIVE); indexpage = BufferGetPage(indexbuffer); + /* + * If an index segment page is not initialized, treat it the same + * way as if it is initialized but contains no entries. + */ + if (ConveyorBeltPageIsUnused(indexpage)) + { + if (segoff == 0) + elog(ERROR, + "conveyor belt index page at segno %u offset 0 should be initialied", + index_segment); + if (*next_index_segment != CB_INVALID_SEGMENT) + elog(ERROR, + "non-final index segment page at segno %u offset %u should be initialized", + index_segment, segoff); + return true; + } + /* * If this is the very first time we've locked an index page in this * segment, it should be the first page, and it will tell us where to -- 2.39.5