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

Commit a49633d

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 4632891 commit a49633d

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

src/backend/commands/vacuumlazy.c

+12-15
Original file line numberDiff line numberDiff line change
@@ -1182,12 +1182,21 @@ lazy_vacuum_page(Relation onerel, BlockNumber blkno, Buffer buffer,
11821182

11831183
/*
11841184
* Mark buffer dirty before we write WAL.
1185-
*
1186-
* If checksums are enabled, visibilitymap_set() may log the heap page, so
1187-
* we must mark heap buffer dirty before calling visibilitymap_set().
11881185
*/
11891186
MarkBufferDirty(buffer);
11901187

1188+
/* XLOG stuff */
1189+
if (RelationNeedsWAL(onerel))
1190+
{
1191+
XLogRecPtr recptr;
1192+
1193+
recptr = log_heap_clean(onerel, buffer,
1194+
NULL, 0, NULL, 0,
1195+
unused, uncnt,
1196+
vacrelstats->latestRemovedXid);
1197+
PageSetLSN(page, recptr);
1198+
}
1199+
11911200
/*
11921201
* Now that we have removed the dead tuples from the page, once again
11931202
* check if the page has become all-visible.
@@ -1201,18 +1210,6 @@ lazy_vacuum_page(Relation onerel, BlockNumber blkno, Buffer buffer,
12011210
visibility_cutoff_xid);
12021211
}
12031212

1204-
/* XLOG stuff */
1205-
if (RelationNeedsWAL(onerel))
1206-
{
1207-
XLogRecPtr recptr;
1208-
1209-
recptr = log_heap_clean(onerel, buffer,
1210-
NULL, 0, NULL, 0,
1211-
unused, uncnt,
1212-
vacrelstats->latestRemovedXid);
1213-
PageSetLSN(page, recptr);
1214-
}
1215-
12161213
END_CRIT_SECTION();
12171214

12181215
return tupindex;

0 commit comments

Comments
 (0)