Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WUW7f-0008LP-A8 for pgsql-bugs@arkaria.postgresql.org; Mon, 31 Mar 2014 06:55:07 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1WUW7d-0002tV-I2 for pgsql-bugs@arkaria.postgresql.org; Mon, 31 Mar 2014 06:55:05 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WUW7c-0002tO-Gt for pgsql-bugs@postgresql.org; Mon, 31 Mar 2014 06:55:04 +0000 Received: from smtp-outbound-2.vmware.com ([208.91.2.13]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WUW7X-0008Hj-Ah for pgsql-bugs@postgresql.org; Mon, 31 Mar 2014 06:55:02 +0000 Received: from sc9-mailhost2.vmware.com (sc9-mailhost2.vmware.com [10.113.161.72]) by smtp-outbound-2.vmware.com (Postfix) with ESMTP id D54B4284D0; Sun, 30 Mar 2014 23:54:55 -0700 (PDT) Received: from zcs-prod-ext-mta-2.vmware.com (zcs-prod-ext-mta-2.vmware.com [10.113.62.224]) by sc9-mailhost2.vmware.com (Postfix) with ESMTP id D23ECB0B51; Sun, 30 Mar 2014 23:54:55 -0700 (PDT) Received: from zcs-prod-ext-mta-2.vmware.com (localhost.localdomain [127.0.0.1]) by zcs-prod-ext-mta-2.vmware.com (Postfix) with ESMTP id 50DBCC005D; Sun, 30 Mar 2014 23:54:50 -0700 (PDT) Received: from [192.168.1.90] (zimbra-prod-ext-proxy-vip.vmware.com [10.113.63.87]) by zcs-prod-ext-mta-2.vmware.com (Postfix) with ESMTPSA; Sun, 30 Mar 2014 23:54:49 -0700 (PDT) Message-ID: <5339113D.8020202@vmware.com> Date: Mon, 31 Mar 2014 09:54:53 +0300 From: Heikki Linnakangas Organization: VMware User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20131103 Icedove/17.0.10 MIME-Version: 1.0 To: digoal@126.com CC: pgsql-bugs@postgresql.org Subject: Re: BUG #9757: Why reclaim index deleted pages need twice vacuum References: <20140328081525.1150.60443@wrigleys.postgresql.org> In-Reply-To: <20140328081525.1150.60443@wrigleys.postgresql.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -7.5 (-------) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org On 03/28/2014 10:15 AM, digoal@126.com wrote: > The following bug has been logged on the website: > > Bug reference: 9757 > Logged by: digoal.zhou > Email address: digoal@126.com > PostgreSQL version: 9.3.3 > Operating system: CentOS 6.4 x64 > Description: > > When I'm testing a index page recycling, found that the index page must be > two vacuum can be reused. Yep, that's how the b-tree works [1]. A deleted page cannot be immediately reused, because there might be concurrent scans that are just about to visit the page. So when a page is deleted, i.e unlinked from the tree, it is stamped with the next transaction ID, and left in place. The next vacuum checks that the transaction ID is no longer visible to anyone, which ensures that there are no transactions running that might've seen a reference to that page. Only after that the page can be reused. That's quite pessimal; in most cases the page could be reused much earlier, because it is a very tight window for vacuum to delete a page just when a concurrent scan has read a link to the page and is about to follow it. But B-tree pages are usually not deleted that often that it would matter in practice, so there has been no effort to optimize it. In short, it's not a bug :-). [1] http://git.postgresql.org/gitweb/?p=postgresql.git;a=blob;f=src/backend/access/nbtree/README#l283 - Heikki -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs