Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 615299c

Browse files
committed
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.
1 parent b57947a commit 615299c

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

src/backend/commands/vacuumlazy.c

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1185,12 +1185,21 @@ lazy_vacuum_page(Relation onerel, BlockNumber blkno, Buffer buffer,
11851185

11861186
/*
11871187
* Mark buffer dirty before we write WAL.
1188-
*
1189-
* If checksums are enabled, visibilitymap_set() may log the heap page, so
1190-
* we must mark heap buffer dirty before calling visibilitymap_set().
11911188
*/
11921189
MarkBufferDirty(buffer);
11931190

1191+
/* XLOG stuff */
1192+
if (RelationNeedsWAL(onerel))
1193+
{
1194+
XLogRecPtr recptr;
1195+
1196+
recptr = log_heap_clean(onerel, buffer,
1197+
NULL, 0, NULL, 0,
1198+
unused, uncnt,
1199+
vacrelstats->latestRemovedXid);
1200+
PageSetLSN(page, recptr);
1201+
}
1202+
11941203
/*
11951204
* Now that we have removed the dead tuples from the page, once again
11961205
* check if the page has become all-visible.
@@ -1204,18 +1213,6 @@ lazy_vacuum_page(Relation onerel, BlockNumber blkno, Buffer buffer,
12041213
visibility_cutoff_xid);
12051214
}
12061215

1207-
/* XLOG stuff */
1208-
if (RelationNeedsWAL(onerel))
1209-
{
1210-
XLogRecPtr recptr;
1211-
1212-
recptr = log_heap_clean(onerel, buffer,
1213-
NULL, 0, NULL, 0,
1214-
unused, uncnt,
1215-
vacrelstats->latestRemovedXid);
1216-
PageSetLSN(page, recptr);
1217-
}
1218-
12191216
END_CRIT_SECTION();
12201217

12211218
return tupindex;

0 commit comments

Comments
 (0)