when vacuuming, handle uninitialized index pages without barfing
authorRobert Haas <[email protected]>
Thu, 9 Dec 2021 23:15:56 +0000 (18:15 -0500)
committerRobert Haas <[email protected]>
Thu, 9 Dec 2021 23:16:31 +0000 (18:16 -0500)
src/backend/access/conveyor/conveyor.c

index cb6adab6ce8edd1c9301c5fe19c52b9b3b6b5990..431a01c9f844e29363589316c10ee0b92f6bcd34 100644 (file)
@@ -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