summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>2013-10-23 14:03:54 +0300
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>2013-10-23 14:25:50 +0300
commit4da24f12e63313b7dbb6b3e3d0317e04045df636 (patch)
tree8f5cd7cb613cf476376b2856bf94be4dda817870
parentb89cedeffb9e5a4a4c9ac501c245ee92cf85aa5f (diff)
Fix two bugs in setting the vm bit of empty pages.
Use a critical section when setting the all-visible flag on an empty page, and WAL-logging it. log_newpage_buffer() contains an assertion that it must be called inside a critical section, and it's the right thing to do when modifying a buffer anyway. Also, the page should be marked dirty before calling log_newpage_buffer(), per the comment in log_newpage_buffer() and src/backend/access/transam/README. Patch by Andres Freund, in response to my report. Backpatch to 9.2, like the patch that introduced these bugs (a6370fd9).
-rw-r--r--src/backend/commands/vacuumlazy.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/backend/commands/vacuumlazy.c b/src/backend/commands/vacuumlazy.c
index 402e76e72bf..28f169e59c5 100644
--- a/src/backend/commands/vacuumlazy.c
+++ b/src/backend/commands/vacuumlazy.c
@@ -650,6 +650,11 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats,
/* empty pages are always all-visible */
if (!PageIsAllVisible(page))
{
+ START_CRIT_SECTION();
+
+ /* mark buffer dirty before writing a WAL record */
+ MarkBufferDirty(buf);
+
/*
* It's possible that another backend has extended the heap,
* initialized the page, and then failed to WAL-log the page
@@ -669,9 +674,9 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats,
log_newpage_buffer(buf);
PageSetAllVisible(page);
- MarkBufferDirty(buf);
visibilitymap_set(onerel, blkno, InvalidXLogRecPtr, vmbuffer,
InvalidTransactionId);
+ END_CRIT_SECTION();
}
UnlockReleaseBuffer(buf);