mirror of
https://github.com/postgres/postgres.git
synced 2025-05-02 11:44:50 +03:00
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).
This commit is contained in:
parent
b89cedeffb
commit
4da24f12e6
@ -650,6 +650,11 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats,
|
|||||||
/* empty pages are always all-visible */
|
/* empty pages are always all-visible */
|
||||||
if (!PageIsAllVisible(page))
|
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,
|
* It's possible that another backend has extended the heap,
|
||||||
* initialized the page, and then failed to WAL-log the page
|
* 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);
|
log_newpage_buffer(buf);
|
||||||
|
|
||||||
PageSetAllVisible(page);
|
PageSetAllVisible(page);
|
||||||
MarkBufferDirty(buf);
|
|
||||||
visibilitymap_set(onerel, blkno, InvalidXLogRecPtr, vmbuffer,
|
visibilitymap_set(onerel, blkno, InvalidXLogRecPtr, vmbuffer,
|
||||||
InvalidTransactionId);
|
InvalidTransactionId);
|
||||||
|
END_CRIT_SECTION();
|
||||||
}
|
}
|
||||||
|
|
||||||
UnlockReleaseBuffer(buf);
|
UnlockReleaseBuffer(buf);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user