Re: autovacuum not prioritising for-wraparound tables

From: Andres Freund <andres(at)2ndquadrant(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Christopher Browne <cbbrowne(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: autovacuum not prioritising for-wraparound tables
Date: 2013-02-02 18:49:13
Message-ID: 20130202184913.GB28016@awork2.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2013-02-02 11:25:01 -0500, Robert Haas wrote:
> On Sat, Feb 2, 2013 at 8:41 AM, Andres Freund <andres(at)2ndquadrant(dot)com> wrote:
> >> - It's probably important to have a formula where we can be sure that
> >> the wrap-around term will eventually dominate the dead-tuple term,
> >> with enough time to spare to make sure nothing really bad happens; on
> >> the other hand, it's also desirable to avoid the case where a table
> >> that has just crossed the threshold for wraparound vacuuming doesn't
> >> immediately shoot to the top of the list even if it isn't truly
> >> urgent. It's unclear to me just from looking at this formula how well
> >> the second term meets those goals.
> >
> > I just wanted to mention that if everything goes well, we won't *ever*
> > get to an anti-wraparound-vacuum. Normally the table should cross the
> > vacuum_table_age barrier earlier and promote a normal vacuum to a
> > full-table vacuum which will set relfrozenxid to a new and lower value
> > and thus prevent anti-wraparound vacuums from occurring.
> > So priorizing anti-wraparound vacuums immediately and heavily doesn't
> > seem to be too bad.
>
> IMHO, this is hopelessly optimistic. Yes, it's intended to work that
> way. But INSERT-only or INSERT-mostly tables are far from an uncommon
> use case; and in fact they're probably the most common cause of pain
> in this area. You insert a gajillion tuples, and vacuum never kicks
> off, and then eventually you either update some tuples or hit
> autovacuum_freeze_max_age and suddenly, BAM, you get this gigantic
> vacuum that rewrites the entire table. And then you open a support
> ticket with your preferred PostgreSQL support provider and say
> something like "WTF?".

You're right, this doesn't work superbly well, especially for
insert-only tables... But imo the place to fix it is not the
priorization logic but relation_needs_vacanalyze, since fixing it in
priorization won't prevent the BAM just the timing of it.

I think scheduling a table for a partial vacuum every min_freeze * 2
xids, even if its insert only, would go a long way of reducing the
impact of full-table vacuums. Obviously that would require to retain the
last xid a vacuum was executed in...

Greetings,

Andres Freund

--
Andres Freund http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Simon Riggs 2013-02-02 18:55:31 pgsql: Mark vacuum_defer_cleanup_age as PGC_POSTMASTER.
Previous Message Robert Haas 2013-02-02 18:41:12 Re: Cascading replication: should we detect/prevent cycles?