]> granicus.if.org Git - postgresql/commitdiff
Fix broken logic in lazy_vacuum_heap.
authorRobert Haas <rhaas@postgresql.org>
Fri, 13 Jan 2012 13:22:31 +0000 (08:22 -0500)
committerRobert Haas <rhaas@postgresql.org>
Fri, 13 Jan 2012 13:22:31 +0000 (08:22 -0500)
As noted by Tom Lane, the previous coding in this area, which I
introduced in commit bbb6e559c4ea0fb4c346beda76736451dc24eb4e, was
poorly tested and caused the vacuum's second heap to go into what would
have been an infinite loop but for the fact that it eventually caused a
memory allocation failure.  This version seems to work better.

src/backend/commands/vacuumlazy.c

index 846d305d1d47ddd73213a48f6f6ad4f2905b5ec1..2fc749e63025ef17fe8d0fd91d311034c9b2c4a5 100644 (file)
@@ -991,7 +991,11 @@ lazy_vacuum_heap(Relation onerel, LVRelStats *vacrelstats)
                buf = ReadBufferExtended(onerel, MAIN_FORKNUM, tblk, RBM_NORMAL,
                                                                 vac_strategy);
                if (!ConditionalLockBufferForCleanup(buf))
+               {
+                       ReleaseBuffer(buf);
+                       ++tupindex;
                        continue;
+               }
                tupindex = lazy_vacuum_page(onerel, tblk, buf, tupindex, vacrelstats);
 
                /* Now that we've compacted the page, record its available space */