Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2a8e1ac

Browse files
committed
Set the all-visible flag on heap page before writing WAL record, not after.
If we set the all-visible flag after writing WAL record, and XLogInserttakes a full-page image of the page, the image would not include the flag.We will then proceed to set the VM bit, which would then be set without thecorresponding all-visible flag on the heap page.Found by comparing page images on master and standby, after writing/replayingeach WAL record. (There is still a discrepancy: the all-visible flag won'tbe set after replaying the HEAP_CLEAN record, even though it is set in themaster. However, it will be set when replaying the HEAP2_VISIBLE record andsetting the VM bit, so the all-visible flag and VM bit are always consistenton the standby, even though they are momentarily out-of-sync with master)Backpatch to 9.3 where this code was introduced.
1 parent5f86cbd commit2a8e1ac

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

‎src/backend/commands/vacuumlazy.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1213,6 +1213,13 @@ lazy_vacuum_page(Relation onerel, BlockNumber blkno, Buffer buffer,
12131213

12141214
PageRepairFragmentation(page);
12151215

1216+
/*
1217+
* Now that we have removed the dead tuples from the page, once again
1218+
* check if the page has become all-visible.
1219+
*/
1220+
if (heap_page_is_all_visible(onerel,buffer,&visibility_cutoff_xid))
1221+
PageSetAllVisible(page);
1222+
12161223
/*
12171224
* Mark buffer dirty before we write WAL.
12181225
*/
@@ -1231,14 +1238,13 @@ lazy_vacuum_page(Relation onerel, BlockNumber blkno, Buffer buffer,
12311238
}
12321239

12331240
/*
1234-
*Now that we have removedthedead tuples from the page, once again
1235-
*check if the page has become all-visible.
1241+
*All the changes totheheap page have been done. If the all-visible
1242+
*flag is now set, also set the VM bit.
12361243
*/
1237-
if (!visibilitymap_test(onerel,blkno,vmbuffer)&&
1238-
heap_page_is_all_visible(onerel,buffer,&visibility_cutoff_xid))
1244+
if (PageIsAllVisible(page)&&
1245+
!visibilitymap_test(onerel,blkno,vmbuffer))
12391246
{
12401247
Assert(BufferIsValid(*vmbuffer));
1241-
PageSetAllVisible(page);
12421248
visibilitymap_set(onerel,blkno,buffer,InvalidXLogRecPtr,*vmbuffer,
12431249
visibility_cutoff_xid);
12441250
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp