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

Commitd4b34f6

Browse files
committed
Deduplicate PageIsNew() check in lazy_scan_heap().
The recheck isn't needed anymore, as RelationGetBufferForTuple() nowextends the relation with RBM_ZERO_AND_LOCK. Previously we needed tohandle the fact that relation extension extended the relation and thenseparately acquired a lock on the page - while expecting that the pageis empty.Reported-By: Ranier VilelaDiscussion:https://postgr.es/m/CAEudQArA_=J0D5T258xsCY6Xtf6wiH4b=QDPDgVS+WZUN10WDw@mail.gmail.com
1 parent364bdd0 commitd4b34f6

File tree

1 file changed

+11
-21
lines changed

1 file changed

+11
-21
lines changed

‎src/backend/access/heap/vacuumlazy.c

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1147,45 +1147,35 @@ lazy_scan_heap(Relation onerel, VacuumParams *params, LVRelStats *vacrelstats,
11471147

11481148
if (PageIsNew(page))
11491149
{
1150-
boolstill_new;
1151-
11521150
/*
11531151
* All-zeroes pages can be left over if either a backend extends
11541152
* the relation by a single page, but crashes before the newly
11551153
* initialized page has been written out, or when bulk-extending
11561154
* the relation (which creates a number of empty pages at the tail
11571155
* end of the relation, but enters them into the FSM).
11581156
*
1159-
* Make sure these pages are in the FSM, to ensure they can be
1160-
* reused. Do that by testing if there's any space recorded for
1161-
* the page. If not, enter it.
1162-
*
11631157
* Note we do not enter the page into the visibilitymap. That has
11641158
* the downside that we repeatedly visit this page in subsequent
11651159
* vacuums, but otherwise we'll never not discover the space on a
11661160
* promoted standby. The harm of repeated checking ought to
11671161
* normally not be too bad - the space usually should be used at
11681162
* some point, otherwise there wouldn't be any regular vacuums.
1163+
*
1164+
* Make sure these pages are in the FSM, to ensure they can be
1165+
* reused. Do that by testing if there's any space recorded for
1166+
* the page. If not, enter it. We do so after releasing the lock
1167+
* on the heap page, the FSM is approximate, after all.
11691168
*/
1170-
1171-
/*
1172-
* Perform checking of FSM after releasing lock, the fsm is
1173-
* approximate, after all.
1174-
*/
1175-
still_new=PageIsNew(page);
11761169
UnlockReleaseBuffer(buf);
11771170

1178-
if (still_new)
1179-
{
1180-
empty_pages++;
1171+
empty_pages++;
11811172

1182-
if (GetRecordedFreeSpace(onerel,blkno)==0)
1183-
{
1184-
Sizefreespace;
1173+
if (GetRecordedFreeSpace(onerel,blkno)==0)
1174+
{
1175+
Sizefreespace;
11851176

1186-
freespace=BufferGetPageSize(buf)-SizeOfPageHeaderData;
1187-
RecordPageWithFreeSpace(onerel,blkno,freespace);
1188-
}
1177+
freespace=BufferGetPageSize(buf)-SizeOfPageHeaderData;
1178+
RecordPageWithFreeSpace(onerel,blkno,freespace);
11891179
}
11901180
continue;
11911181
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp