Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 04CF4B5DBD9 for ; Tue, 27 Sep 2011 00:55:15 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 16472-03 for ; Tue, 27 Sep 2011 03:55:08 +0000 (UTC) X-Greylist: delayed 00:09:28.738806 by SQLgrey-1.8.0-rc2 Received: from ix.inomial.com (mail.inomial.net [202.62.159.215]) by mail.postgresql.org (Postfix) with ESMTP id 0E0F0B5DBC7 for ; Tue, 27 Sep 2011 00:55:06 -0300 (ADT) Received: from jadzia.lan (ip-151.29.92.203.VOCUS.net.au [203.92.29.151]) by ix.inomial.com (Postfix) with ESMTPA id 59CBB2C1C63 for ; Tue, 27 Sep 2011 13:45:34 +1000 (EST) From: Royce Ausburn Content-Type: multipart/alternative; boundary="Apple-Mail=_71432666-4642-4E9C-A142-D45F5D95E720" Subject: Ineffective autovacuum Date: Tue, 27 Sep 2011 13:45:33 +1000 Message-Id: <059E65EF-8C66-4DA6-835C-936D6592C94B@inomial.com> To: pgsql-performance Mime-Version: 1.0 (Apple Message framework v1244.3) X-Mailer: Apple Mail (2.1244.3) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.899 tagged_above=-10 required=5 tests=BAYES_00=-1.9, HTML_MESSAGE=0.001 X-Spam-Level: X-Archive-Number: 201109/380 X-Sequence-Number: 45156 --Apple-Mail=_71432666-4642-4E9C-A142-D45F5D95E720 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=windows-1252 Hi all, I have a problem with autovacuum apparently not doing the job I need it = to do. I have a table named datasession that is frequently inserted, updated = and deleted from. Typically the table will have a few thousand rows in = it. Each row typically survives a few days and is updated every 5 - 10 = mins. The application receives unreliable, potentially duplicate data = from its source, so this table is heavily used for synchronising = application threads as well. A typical access pattern is: - tx begin - SELECT FOR UPDATE on a single row - Do some application processing (1 - 100 ms) - Possibly UPDATE the row - tx commit In a few instances of our application we're seeing this table grow = obscenely to the point where our monitoring servers get us out of bed to = manually vacuum. I like sleep, so I want to fix this =3DD I've read some recent threads and found a discussion (below) on auto = vacuum that mentions auto vacuum will be cancelled when a client = requests a lock that auto vacuum is using=85 My questions: 1) Does it look like I'm affected by the same problem as in the below = discussion? 2) Are there better solutions to this problem than a periodic task that = vacuums/truncates-and-rebuilds the table? =20 Perhaps relevant info: # select version(); version = =20 = --------------------------------------------------------------------------= ------------------------ PostgreSQL 8.3.12 on x86_64-pc-linux-gnu, compiled by GCC cc (GCC) = 4.2.4 (Ubuntu 4.2.4-1ubuntu3) (1 row) Auto vacuum and vacuum parameters are set to the factory defaults. Cheers, --Royce > From: Tom Lane > Subject: Re: [GENERAL] Vacuum as "easily obtained" locks=20 > Date: 4 August 2011 1:52:02 AM AEST > To: Michael Graham > Cc: Pavan Deolasee , = pgsql-general@postgresql.org >=20 >>> On Wed, 2011-08-03 at 11:40 -0400, Tom Lane wrote: >>> The other problem is that once autovacuum has gotten the lock, it = has >>> to keep it for long enough to re-scan the truncatable pages (to make >>> sure they're still empty). And it is set up so that any access to = the >>> table will kick autovacuum off the lock. An access pattern like = that >>> would very likely prevent it from ever truncating, if there are a = lot >>> of pages that need to be truncated. (There's been some discussion = of >>> modifying this behavior, but nothing's been done about it yet.)=20 > Michael Graham writes: >> Ah! This looks like it is very much the issue. Since I've got = around >> 150GB of data that should be truncatable and a select every ~2s. >=20 >> Just to confirm would postgres write: >=20 >> 2011-08-03 16:09:55 BST ERROR: canceling autovacuum task >> 2011-08-03 16:09:55 BST CONTEXT: automatic vacuum of table >> "traffic.public.logdata5queue" >=20 >> Under those circumstances? >=20 > Yup ... >=20 > If you do a manual VACUUM, it won't allow itself to get kicked off the > lock ... but as noted upthread, that will mean your other queries get > blocked till it's done. Not sure there's any simple fix for this that > doesn't involve some downtime. >=20 > regards, tom lane >=20 > --=20 > Sent via pgsql-general mailing list (pgsql-general@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-general --Apple-Mail=_71432666-4642-4E9C-A142-D45F5D95E720 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=windows-1252 Hi = all,

I have a problem with autovacuum apparently not = doing the job I need it to do.

I have a table = named datasession that is frequently inserted, updated and deleted from. =  Typically the table will have a few thousand rows in it. =  Each row typically survives a few days and is updated every 5 - 10 = mins.  The application receives unreliable, potentially duplicate = data from its source, so this table is heavily used for synchronising = application threads as well.  A typical access pattern = is:

- tx begin
- SELECT FOR UPDATE on = a single row
- Do some application processing (1 - 100 = ms)
- Possibly UPDATE the row
- tx = commit

In a few instances of our application = we're seeing this table grow obscenely to the point where our monitoring = servers get us out of bed to manually vacuum.  I like sleep, so I = want to fix this =3DD

I've read some recent = threads and found a discussion (below) on auto vacuum that mentions auto = vacuum will be cancelled when a client requests a lock that auto vacuum = is using=85 My questions:

1) Does it look like = I'm affected by the same problem as in the below = discussion?

2) Are there better solutions to = this problem than a periodic task that vacuums/truncates-and-rebuilds = the table?  


Perhaps = relevant info:


# select = version();
                =                     =          version         =                     =                 =  
---------------------------------------------------------= -----------------------------------------
 PostgreSQL 8.3.12 on = x86_64-pc-linux-gnu, compiled by GCC cc (GCC) 4.2.4 (Ubuntu = 4.2.4-1ubuntu3)
(1 row)

Auto = vacuum and vacuum parameters are set to the factory = defaults.

Cheers,

--Royc= e

From: Tom Lane <tgl@sss.pgh.pa.us>
Subject: Re: [GENERAL] = Vacuum as "easily obtained" locks 
Date: 4 August 2011 = 1:52:02 AM AEST
On = Wed, 2011-08-03 at 11:40 -0400, Tom Lane = wrote:
The other problem is = that once autovacuum has gotten the lock, it = has
to keep it for long enough = to re-scan the truncatable pages (to make
sure they're still empty).  And it is set up so that = any access to the
table will = kick autovacuum off the lock.  An access pattern like = that
would very likely prevent = it from ever truncating, if there are a lot
of pages that need to be truncated.  (There's been = some discussion of
modifying = this behavior, but nothing's been done about it = yet.) 

Michael Graham <mgraham@bloxx.com> = writes:
Ah!  This looks like it is = very much the issue.  Since I've got = around
150GB of data that = should be truncatable and a select every = ~2s.

Just to confirm would = postgres write:

2011-08-03 = 16:09:55 BST ERROR:  canceling autovacuum = task
2011-08-03 16:09:55 BST = CONTEXT:  automatic vacuum of table
"traffic.public.logdata5queue"

Under those circumstances?

Yup = ...

If you do a manual VACUUM, it won't allow itself to get = kicked off the
lock ... but as noted upthread, that will mean your = other queries get
blocked till it's done.  Not sure there's any = simple fix for this that
doesn't involve some downtime.

regards, = tom lane

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org<= /a>)
To make changes to your subscription:
http://www.postg= resql.org/mailpref/pgsql-general

<= /div>

= --Apple-Mail=_71432666-4642-4E9C-A142-D45F5D95E720--