pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: jayknowsunix@gmail.com
To: Alvaro Herrera <alvherre@2ndquadrant.com>
Cc: jesper@krogh.cc <jesper@krogh.cc>
Cc: pgsql-admin@postgresql.org <pgsql-admin@postgresql.org>
Subject: Re: Autovacuum not keeping up. (PG 9.2.9)
Date: Thu, 31 Jul 2014 09:56:53 -0400
Message-ID: <5A546F03-0769-4D4A-B29F-C06CF235F42A@gmail.com> (raw)
In-Reply-To: <20140731134025.GB5475@eldon.alvh.no-ip.org>
References: <26e211945432a41a56dd900440f27e6d.squirrel@shrek.krogh.cc>
	<20140731134025.GB5475@eldon.alvh.no-ip.org>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-admin>



Sent from my iPad

> On Jul 31, 2014, at 9:40 AM, Alvaro Herrera <alvherre@2ndquadrant.com> wrote:
> 
> jesper@krogh.cc wrote:
>> Hi.
>> 
>> I have a large  database with a message queue table, that has high
>> activity. The database supports 1-300 client connection concurrently,
>> having transactions open in up to 30 minutes each.
>> 
>> Recently I am seeing autuvacuum being issued, but it takes
>> ages to get through the message queue table, with strace showing waiting
>> for semop's for 10's to 100's of seconds.
> 
> Do you have data on how relfrozenxid advances for that table?
> 
> Vacuuming needs to grab a "cleanup lock" on each page it's going to
> vacuum, which is a special kind of lock that requires that no other
> process is even looking at the page at that moment (we call this "to
> have the page pinned"), which is even weaker than having a shared lock
> on the page.  If traffic to some pages is high, it might be difficult
> for vacuum to acquire this.
> 
> Normally, vacuum doesn't break much sweat about this: if it cannot
> acquire the cleanup lock, it ignores the page, keeps calm and carries
> on.  But if it's a for-wraparound vacuuming, it will need to wait until
> it is able to acquire cleanup lock.
> 
> I think one idea might be to try to manually vacuum the table once in a
> while with a reduced value of min_freeze_table_age.  This will cause a
> full table scan (i.e. cleanup lock for all pages is waited for), which
> decreases the "frozen xid age", which moves the need to do this again
> further in the future; so the autovacuum-invoked vacuums will be able to
> skip the pages on which it cannot get cleanup lock.
> 
> Another idea is to increase min_freeze_table_age for the queue table
> through ALTER TABLE, the idea being that you can delay forced vacuuming
> of hot pages for long enough that they can wait until they have cooled
> off.  Default value is 150 million transactions, which you can raise
> tenfold and even higher.
> 
> See
> http://www.postgresql.org/docs/9.2/static/runtime-config-client.html#GUC-VACUUM-FREEZE-TABLE-AGE
> 
> 
> The other idea is that heap truncation is what's causing the problem,
> but AFAICS that uses conditional lock acquisition so you shouldn't be
> seeing stalls in semop().
> 
> -- 
> Álvaro Herrera                http://www.2ndQuadrant.com/
> PostgreSQL Development, 24x7 Support, Training & Services
> 
> 
> -- 
> Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-admin

You should probably consider, if you haven't done already, to partition this table. Without knowing what's adding new transactions, it sounds like you could break up the table with a timestamp rule. That would permit autovacuum to do parts of the table much quicker, and only once.
-/
Jay

-- 
Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin



view thread (6+ messages)  latest in thread

Message-ID: <5A546F03-0769-4D4A-B29F-C06CF235F42A@gmail.com>
Permalink:  ../5A546F03-0769-4D4A-B29F-C06CF235F42A@gmail.com/
Also on:    postgresql.org/message-id/5A546F03-0769-4D4A-B29F-C06CF235F42A@gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-admin@postgresql.org
  Cc: jayknowsunix@gmail.com, alvherre@2ndquadrant.com, jesper@krogh.cc
  Subject: Re: Autovacuum not keeping up. (PG 9.2.9)
  In-Reply-To: <5A546F03-0769-4D4A-B29F-C06CF235F42A@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox