Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XD8gf-0003jJ-T9 for pgsql-admin@arkaria.postgresql.org; Fri, 01 Aug 2014 08:59:42 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1XD8ge-0003eD-He for pgsql-admin@arkaria.postgresql.org; Fri, 01 Aug 2014 08:59:40 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1XD8gd-0003e7-QY for pgsql-admin@postgresql.org; Fri, 01 Aug 2014 08:59:39 +0000 Received: from port591.ds1-ly.adsl.cybercity.dk ([217.157.234.220] helo=shrek.krogh.cc) by magus.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1XD8ga-0003AF-0y for pgsql-admin@postgresql.org; Fri, 01 Aug 2014 08:59:38 +0000 Received: from localhost (localhost [127.0.0.1]) by shrek.krogh.cc (Postfix) with ESMTP id BC8B41F00745; Fri, 1 Aug 2014 10:59:39 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at shrek.krogh.cc Received: from shrek.krogh.cc ([127.0.0.1]) by localhost (shrek.krogh.cc [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id lTBc0_AUkj66; Fri, 1 Aug 2014 10:59:36 +0200 (CEST) Received: from shrek.krogh.cc (localhost [IPv6:::1]) by shrek.krogh.cc (Postfix) with ESMTP id A24721F000F2; Fri, 1 Aug 2014 10:59:32 +0200 (CEST) Received: from 94.101.220.16 (SquirrelMail authenticated user jesper@krogh.cc) by shrek.krogh.cc with HTTP; Fri, 1 Aug 2014 10:59:36 +0200 Message-ID: <716ad55e559db5d9802de179677d2fb0.squirrel@shrek.krogh.cc> In-Reply-To: <20140731134025.GB5475@eldon.alvh.no-ip.org> References: <26e211945432a41a56dd900440f27e6d.squirrel@shrek.krogh.cc> <20140731134025.GB5475@eldon.alvh.no-ip.org> Date: Fri, 1 Aug 2014 10:59:36 +0200 Subject: Re: Autovacuum not keeping up. (PG 9.2.9) From: jesper@krogh.cc To: "Alvaro Herrera" Cc: pgsql-admin@postgresql.org User-Agent: SquirrelMail/1.4.23 [SVN] MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Priority: 3 (Normal) Importance: Normal X-Pg-Spam-Score: -0.9 (/) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-admin Precedence: bulk Sender: pgsql-admin-owner@postgresql.org > 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? Not really, how would you normally pick that out? 2014-08-01 10:49:39.171 db=# select relname, age(relfrozenxid), relfrozenxid FROM pg_class WHERE relkind = 'r' and relname = 'job'; relname | age | relfrozenxid ---------+-----------+-------------- job | 111893622 | 796259097 (1 row) Time: 1.913 ms This shouldn't qualify for a freeze vacuum, should it? > 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. Based on strace output this looks excactly like whats going on, there are some activity, then it pauses for some time then continues. > 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. Can I force it to tell me if it does the for-wraparound cleanup or normal? > 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 I tried to read through that, but that is a GUC not a storage level parameter. So I (hopefully correct) figured out that the storage level parameter that need to be set were autovacuum_freeze_min_age and set that one to 1.000.000.000 for the table. But apparently it didnt cause any changes. It is still waiting for the lock. Is a database restart required after setting storage parameters, or will autovacuum pick up the new one when it starts over with the table. > 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(). That should only be once per vacuuming .. right? That doesn't fit the pattern either. -- Jesper -- Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-admin