Skip to content
Snippets Groups Projects
Commit 9f3558af authored by Simon Riggs's avatar Simon Riggs
Browse files

Avoid holding vmbuffer pin after VACUUM.

During VACUUM if we pause to perform a cycle
of index cleanup we drop the vmbuffer pin,
so we should do the same thing when heap
scan completes. This avoids holding vmbuffer
pin across the main index cleanup in VACUUM,
which could be minutes or hours longer than
necessary for correctness.

Bug report and suggested fix from Pavan Deolasee
parent 1d48cecc
No related branches found
No related tags found
No related merge requests found
...@@ -800,6 +800,15 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats, ...@@ -800,6 +800,15 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats,
vacrelstats->scanned_pages, vacrelstats->scanned_pages,
num_tuples); num_tuples);
/*
* Release any remaining pin on visibility map page.
*/
if (BufferIsValid(vmbuffer))
{
ReleaseBuffer(vmbuffer);
vmbuffer = InvalidBuffer;
}
/* If any tuples need to be deleted, perform final vacuum cycle */ /* If any tuples need to be deleted, perform final vacuum cycle */
/* XXX put a threshold on min number of tuples here? */ /* XXX put a threshold on min number of tuples here? */
if (vacrelstats->num_dead_tuples > 0) if (vacrelstats->num_dead_tuples > 0)
...@@ -814,13 +823,6 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats, ...@@ -814,13 +823,6 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats,
vacrelstats->num_index_scans++; vacrelstats->num_index_scans++;
} }
/* Release the pin on the visibility map page */
if (BufferIsValid(vmbuffer))
{
ReleaseBuffer(vmbuffer);
vmbuffer = InvalidBuffer;
}
/* Do post-vacuum cleanup and statistics update for each index */ /* Do post-vacuum cleanup and statistics update for each index */
for (i = 0; i < nindexes; i++) for (i = 0; i < nindexes; i++)
lazy_cleanup_index(Irel[i], indstats[i], vacrelstats); lazy_cleanup_index(Irel[i], indstats[i], vacrelstats);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment