Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 837B3650E80 for ; Mon, 30 Jun 2008 12:27:30 -0300 (ADT) Received: from postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 86443-01 for ; Mon, 30 Jun 2008 12:26:40 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from lists.commandprompt.com (host-159.commandprompt.net [207.173.203.159]) by postgresql.org (Postfix) with ESMTP id D0109650EBA for ; Mon, 30 Jun 2008 12:26:26 -0300 (ADT) Received: from perhan.alvh.no-ip.org (200-126-116-204.bk8-dsl.surnet.cl [200.126.116.204]) (authenticated bits=0) by lists.commandprompt.com (8.13.8/8.13.8) with ESMTP id m5UFRN1Z027098 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 30 Jun 2008 08:28:09 -0700 Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 5E11B47C7C; Mon, 30 Jun 2008 11:25:15 -0400 (CLT) Date: Mon, 30 Jun 2008 11:25:15 -0400 From: Alvaro Herrera To: Peter Schuller Cc: pgsql-performance@postgresql.org Subject: Re: VACUUM ANALYZE blocking both reads and writes to a table Message-ID: <20080630152515.GF10311@alvh.no-ip.org> References: <20080630145903.GA15197@hyperion.scode.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20080630145903.GA15197@hyperion.scode.org> User-Agent: Mutt/1.5.18 (2008-05-17) X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.0 (lists.commandprompt.com [207.173.203.159]); Mon, 30 Jun 2008 08:28:10 -0700 (PDT) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200806/238 X-Sequence-Number: 30588 Peter Schuller wrote: > Does anyone have input on why this could be happening? The PostgreSQL > version is 8.2.4[1]. Am I correct in that it *should* not be possible > for this to happen? No. VACUUM takes an exclusive lock at the end of the operation to truncate empty pages. (If it cannot get the lock then it'll just skip this step.) In 8.2.4 there was a bug that caused it to sleep according to vacuum_delay during the scan to identify possibly empty pages. This was fixed in 8.2.5: revision 1.81.2.1 date: 2007-09-10 13:58:50 -0400; author: alvherre; state: Exp; lines: +6 -2; Remove the vacuum_delay_point call in count_nondeletable_pages, because we hold an exclusive lock on the table at this point, which we want to release as soon as possible. This is called in the phase of lazy vacuum where we truncate the empty pages at the end of the table. An alternative solution would be to lower the vacuum delay settings before starting the truncating phase, but this doesn't work very well in autovacuum due to the autobalancing code (which can cause other processes to change our cost delay settings). This case could be considered in the balancing code, but it is simpler this way. -- Alvaro Herrera http://www.CommandPrompt.com/ PostgreSQL Replication, Consulting, Custom Development, 24x7 support