aboutsummaryrefslogtreecommitdiff
path: root/src/backend
diff options
context:
space:
mode:
authorSimon Riggs <simon@2ndQuadrant.com>2012-12-03 18:54:52 +0000
committerSimon Riggs <simon@2ndQuadrant.com>2012-12-03 18:54:52 +0000
commit17ee02ea1c87b96a4d687d3319f6f4602450d6cb (patch)
tree041772537369d906227ccfd65ec02b617af2ae22 /src/backend
parent6a8b9987c63bc88b3a4fd56a644d250e7113dd7f (diff)
downloadpostgresql-17ee02ea1c87b96a4d687d3319f6f4602450d6cb.tar.gz
postgresql-17ee02ea1c87b96a4d687d3319f6f4602450d6cb.zip
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
Diffstat (limited to 'src/backend')
-rw-r--r--src/backend/commands/vacuumlazy.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/backend/commands/vacuumlazy.c b/src/backend/commands/vacuumlazy.c
index 5e902211649..219a613ac3e 100644
--- a/src/backend/commands/vacuumlazy.c
+++ b/src/backend/commands/vacuumlazy.c
@@ -947,6 +947,15 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats,
vacrelstats->scanned_pages,
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 */
/* XXX put a threshold on min number of tuples here? */
if (vacrelstats->num_dead_tuples > 0)
@@ -964,13 +973,6 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats,
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 */
for (i = 0; i < nindexes; i++)
lazy_cleanup_index(Irel[i], indstats[i], vacrelstats);