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

Commit2aa6e33

Browse files
committed
Skip redundant anti-wraparound vacuums
An anti-wraparound vacuum has to be by definition aggressive as it needsto work on all the pages of a relation. However it can happen that dueto some concurrent activity an anti-wraparound vacuum is marked asnon-aggressive, which makes it redundant with a previous run, andit is actually useless as an anti-wraparound vacuum should process allthe pages of a relation. This commit makes such vacuums to be skipped.An anti-wraparound vacuum not aggressive can be found easily by mixinglow values of autovacuum_freeze_max_age (to control anti-wraparound) andautovacuum_freeze_table_age (to control the aggressiveness).28a8fa9 has added some extra logging printing all the possiblecombinations of anti-wraparound and aggressive vacuums, which now getssimplified as an anti-wraparound vacuum also non-aggressive getsskipped.Per discussion mainly between Andrew Dunstan, Robert Haas, ÁlvaroHerrera, Kyotaro Horiguchi, Masahiko Sawada, and myself.Author: Kyotaro Horiguchi, Michael PaquierReviewed-by: Andrew Dunstan, Álvaro HerreraDiscussion:https://postgr.es/m/20180914153554.562muwr3uwujno75@alvherre.pgsql
1 parent47b3c26 commit2aa6e33

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

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

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,23 @@ heap_vacuum_rel(Relation onerel, VacuumParams *params,
248248
if (params->options&VACOPT_DISABLE_PAGE_SKIPPING)
249249
aggressive= true;
250250

251+
/*
252+
* Normally the relfrozenxid for an anti-wraparound vacuum will be old
253+
* enough to force an aggressive vacuum. However, a concurrent vacuum
254+
* might have already done this work that the relfrozenxid in relcache has
255+
* been updated. If that happens this vacuum is redundant, so skip it.
256+
*/
257+
if (params->is_wraparound&& !aggressive)
258+
{
259+
ereport(DEBUG1,
260+
(errmsg("skipping redundant vacuum to prevent wraparound of table \"%s.%s.%s\"",
261+
get_database_name(MyDatabaseId),
262+
get_namespace_name(RelationGetNamespace(onerel)),
263+
RelationGetRelationName(onerel))));
264+
pgstat_progress_end_command();
265+
return;
266+
}
267+
251268
vacrelstats= (LVRelStats*)palloc0(sizeof(LVRelStats));
252269

253270
vacrelstats->old_rel_pages=onerel->rd_rel->relpages;
@@ -375,10 +392,9 @@ heap_vacuum_rel(Relation onerel, VacuumParams *params,
375392
initStringInfo(&buf);
376393
if (params->is_wraparound)
377394
{
378-
if (aggressive)
379-
msgfmt=_("automatic aggressive vacuum to prevent wraparound of table \"%s.%s.%s\": index scans: %d\n");
380-
else
381-
msgfmt=_("automatic vacuum to prevent wraparound of table \"%s.%s.%s\": index scans: %d\n");
395+
/* an anti-wraparound vacuum has to be aggressive */
396+
Assert(aggressive);
397+
msgfmt=_("automatic aggressive vacuum to prevent wraparound of table \"%s.%s.%s\": index scans: %d\n");
382398
}
383399
else
384400
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp