diff options
author | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2013-12-13 13:52:47 +0200 |
---|---|---|
committer | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2013-12-13 14:15:04 +0200 |
commit | a49633d8dc6c66f6b2e92c8598d3dfa2cc72a259 (patch) | |
tree | 8495d6722e5c384d4fb128ef9ef3ce1d5c286f68 /src | |
parent | 46328916eefc5f9eaf249518e96f68afcd35923b (diff) | |
download | postgresql-a49633d8dc6c66f6b2e92c8598d3dfa2cc72a259.tar.gz postgresql-a49633d8dc6c66f6b2e92c8598d3dfa2cc72a259.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.c | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/src/backend/commands/vacuumlazy.c b/src/backend/commands/vacuumlazy.c index 7b9837f4f42..28e98e8b481 100644 --- a/src/backend/commands/vacuumlazy.c +++ b/src/backend/commands/vacuumlazy.c @@ -1182,12 +1182,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. @@ -1201,18 +1210,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; |