aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>2013-12-13 13:52:47 +0200
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>2013-12-13 14:23:02 +0200
commit615299cf63a730f9e170532c4782cd5a4a06a7ac (patch)
tree7ce98c8f9a01d2c59d78579834d60b5570a5d980 /src
parentb57947aa9cacaac58b4baa7b30306ccf803d6c88 (diff)
downloadpostgresql-615299cf63a730f9e170532c4782cd5a4a06a7ac.tar.gz
postgresql-615299cf63a730f9e170532c4782cd5a4a06a7ac.zip
Fix WAL-logging of setting the visibility map bit.
The operation that removes the remaining dead tuples from the page must be WAL-logged before the setting of the VM bit. Otherwise, if you replay the WAL to between those two records, you end up with the VM bit set, but the dead tuples are still there. Backpatch to 9.3, where this bug was introduced.
Diffstat (limited to 'src')
-rw-r--r--src/backend/commands/vacuumlazy.c27
1 files changed, 12 insertions, 15 deletions
diff --git a/src/backend/commands/vacuumlazy.c b/src/backend/commands/vacuumlazy.c
index ff6bd8e5b06..2433325abb2 100644
--- a/src/backend/commands/vacuumlazy.c
+++ b/src/backend/commands/vacuumlazy.c
@@ -1185,12 +1185,21 @@ lazy_vacuum_page(Relation onerel, BlockNumber blkno, Buffer buffer,
/*
* Mark buffer dirty before we write WAL.
- *
- * If checksums are enabled, visibilitymap_set() may log the heap page, so
- * we must mark heap buffer dirty before calling visibilitymap_set().
*/
MarkBufferDirty(buffer);
+ /* XLOG stuff */
+ if (RelationNeedsWAL(onerel))
+ {
+ XLogRecPtr recptr;
+
+ recptr = log_heap_clean(onerel, buffer,
+ NULL, 0, NULL, 0,
+ unused, uncnt,
+ vacrelstats->latestRemovedXid);
+ PageSetLSN(page, recptr);
+ }
+
/*
* Now that we have removed the dead tuples from the page, once again
* check if the page has become all-visible.
@@ -1204,18 +1213,6 @@ lazy_vacuum_page(Relation onerel, BlockNumber blkno, Buffer buffer,
visibility_cutoff_xid);
}
- /* XLOG stuff */
- if (RelationNeedsWAL(onerel))
- {
- XLogRecPtr recptr;
-
- recptr = log_heap_clean(onerel, buffer,
- NULL, 0, NULL, 0,
- unused, uncnt,
- vacrelstats->latestRemovedXid);
- PageSetLSN(page, recptr);
- }
-
END_CRIT_SECTION();
return tupindex;