Skip to content

Commit 83eb540

Browse files
committed
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 (a6370fd).
1 parent 5f1ab46 commit 83eb540

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/backend/commands/vacuumlazy.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -663,6 +663,11 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats,
663663
/* empty pages are always all-visible */
664664
if (!PageIsAllVisible(page))
665665
{
666+
START_CRIT_SECTION();
667+
668+
/* mark buffer dirty before writing a WAL record */
669+
MarkBufferDirty(buf);
670+
666671
/*
667672
* It's possible that another backend has extended the heap,
668673
* initialized the page, and then failed to WAL-log the page
@@ -682,9 +687,9 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats,
682687
log_newpage_buffer(buf);
683688

684689
PageSetAllVisible(page);
685-
MarkBufferDirty(buf);
686690
visibilitymap_set(onerel, blkno, buf, InvalidXLogRecPtr,
687691
vmbuffer, InvalidTransactionId);
692+
END_CRIT_SECTION();
688693
}
689694

690695
UnlockReleaseBuffer(buf);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy