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

Commit95aa823

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 parentaa0a519 commit95aa823

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
@@ -1206,6 +1206,13 @@ lazy_vacuum_page(Relation onerel, BlockNumber blkno, Buffer buffer,
12061206

12071207
PageRepairFragmentation(page);
12081208

1209+
/*
1210+
* Now that we have removed the dead tuples from the page, once again
1211+
* check if the page has become all-visible.
1212+
*/
1213+
if (heap_page_is_all_visible(buffer,&visibility_cutoff_xid))
1214+
PageSetAllVisible(page);
1215+
12091216
/*
12101217
* Mark buffer dirty before we write WAL.
12111218
*/
@@ -1224,14 +1231,13 @@ lazy_vacuum_page(Relation onerel, BlockNumber blkno, Buffer buffer,
12241231
}
12251232

12261233
/*
1227-
*Now that we have removedthedead tuples from the page, once again
1228-
*check if the page has become all-visible.
1234+
*All the changes totheheap page have been done. If the all-visible
1235+
*flag is now set, also set the VM bit.
12291236
*/
1230-
if (!visibilitymap_test(onerel,blkno,vmbuffer)&&
1231-
heap_page_is_all_visible(buffer,&visibility_cutoff_xid))
1237+
if (PageIsAllVisible(page)&&
1238+
!visibilitymap_test(onerel,blkno,vmbuffer))
12321239
{
12331240
Assert(BufferIsValid(*vmbuffer));
1234-
PageSetAllVisible(page);
12351241
visibilitymap_set(onerel,blkno,buffer,InvalidXLogRecPtr,*vmbuffer,
12361242
visibility_cutoff_xid);
12371243
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp