Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XDoWJ-0006jW-08 for pgsql-admin@arkaria.postgresql.org; Sun, 03 Aug 2014 05:39:47 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1XDoWH-0001rK-GU for pgsql-admin@arkaria.postgresql.org; Sun, 03 Aug 2014 05:39:45 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1XDoWF-0001r5-BD for pgsql-admin@postgresql.org; Sun, 03 Aug 2014 05:39:43 +0000 Received: from smtprelay0230.b.hostedemail.com ([64.98.42.230] helo=smtprelay.b.hostedemail.com) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XDoWA-0008K0-C8 for pgsql-admin@postgresql.org; Sun, 03 Aug 2014 05:39:41 +0000 Received: from filter.hostedemail.com (b-bigip1 [10.5.19.254]) by smtprelay04.b.hostedemail.com (Postfix) with ESMTP id 59E3C7B613; Sun, 3 Aug 2014 05:39:37 +0000 (UTC) X-Session-Marker: 616C76686572726540616C76682E6E6F2D69702E6F7267 X-Spam-Summary: 50, 0, 0, , d41d8cd98f00b204, alvherre@alvh.no-ip.org, :::, RULES_HIT:41:69:355:379:421:599:800:966:967:973:988:989:1260:1277:1311:1312:1313:1314:1345:1359:1437:1515:1516:1518:1519:1534:1543:1593:1594:1595:1596:1605:1711:1730:1747:1777:1792:2196:2199:2393:2525:2561:2564:2682:2685:2693:2740:2828:2859:2916:2933:2937:2939:2942:2945:2947:2951:2954:3022:3138:3139:3140:3141:3142:3865:3866:3867:3868:3870:3871:3872:3873:3874:3934:3936:3938:3941:3944:3947:3950:3953:3956:3959:4250:4321:4385:4416:4605:4659:5007:6261:7903:7974:8599:8957:9025:9072:9121:9388:10004:10049:10400:10848:10946:11026:11232:11256:11257:11473:11658:11914:12043:12296:12438:12517:12519:12555:12663:12683:12739:12740:12776:13095:13141:13153:13161:13180:13228:13229:13230:13891:13894:13895:21060:21080, 0, RBL:none, CacheIP:none, Bayesian:0.5, 0.5, 0.5, Netcheck:none, DomainCache:0, MSF:not bulk, SPF:fn, MSBL:0, DNSBL:none, Custom_rules:0:0:0 X-HE-Tag: town21_36c24d06c4f40 X-Filterd-Recvd-Size: 4625 Received: from eldon.alvh.no-ip.org (pc-65-79-161-190.cm.vtr.net [190.161.79.65]) (Authenticated sender: alvherre@alvh.no-ip.org) by omf13.b.hostedemail.com (Postfix) with ESMTPA; Sun, 3 Aug 2014 05:39:36 +0000 (UTC) Received: by eldon.alvh.no-ip.org (Postfix, from userid 1000) id CDC171FCB; Sun, 3 Aug 2014 01:39:34 -0400 (CLT) Date: Sun, 3 Aug 2014 01:39:34 -0400 From: Alvaro Herrera To: jesper@krogh.cc Cc: pgsql-admin@postgresql.org Subject: Re: Autovacuum not keeping up. (PG 9.2.9) Message-ID: <20140803053934.GG5475@eldon.alvh.no-ip.org> References: <26e211945432a41a56dd900440f27e6d.squirrel@shrek.krogh.cc> <20140731134025.GB5475@eldon.alvh.no-ip.org> <716ad55e559db5d9802de179677d2fb0.squirrel@shrek.krogh.cc> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <716ad55e559db5d9802de179677d2fb0.squirrel@shrek.krogh.cc> User-Agent: Mutt/1.5.21 (2010-09-15) X-Pg-Spam-Score: -1.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: > > 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? I misspoke -- I was referring to a full-table scan, not a for-wraparound vacuum. A full table scan is triggered when the table reaches the freeze_table_age. > > 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? Don't think so, unless you're open to patching the source. > > 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. It is autovacuum_freeze_table_age. You don't need to restart; autovacuum picks up new values from storage parameters immediately. (Workers that are already running will ignore changes for the table they are vacuuming at that moment.) > > 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. There's a retry loop in there (see src/backend/commands/vacuumlazy.c): /* * Timing parameters for truncate locking heuristics. * * These were not exposed as user tunable GUC values because it didn't seem * that the potential for improvement was great enough to merit the cost of * supporting them. */ #define VACUUM_TRUNCATE_LOCK_CHECK_INTERVAL 20 /* ms */ #define VACUUM_TRUNCATE_LOCK_WAIT_INTERVAL 50 /* ms */ #define VACUUM_TRUNCATE_LOCK_TIMEOUT 5000 /* ms */ ... while (true) { if (ConditionalLockAcquire( ... )) break; if (++lock_retry > (VACUUM_TRUNCATE_LOCK_TIMEOUT / VACUUM_TRUNCATE_LOCK_WAIT_INTERVAL)) { /* give up */ return; } pg_usleep(VACUUM_TRUNCATE_LOCK_WAIT_INTERVAL); } Note the sleeps are always of the same duration. -- Á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