Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id C182A1337B9C for ; Wed, 30 Mar 2011 10:02:37 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 97430-07 for ; Wed, 30 Mar 2011 13:02:19 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from exprod7og107.obsmtp.com (exprod7og107.obsmtp.com [64.18.2.167]) by mail.postgresql.org (Postfix) with ESMTP id CA1A51337999 for ; Wed, 30 Mar 2011 10:02:18 -0300 (ADT) Received: from source ([209.85.215.176]) (using TLSv1) by exprod7ob107.postini.com ([64.18.6.12]) with SMTP ID DSNKTZMp2hkmxxJkbAfvz/p7XPia1ngGn2i4@postini.com; Wed, 30 Mar 2011 06:02:19 PDT Received: by eya28 with SMTP id 28so467716eya.21 for ; Wed, 30 Mar 2011 06:02:16 -0700 (PDT) Received: by 10.213.31.73 with SMTP id x9mr790009ebc.142.1301489535431; Wed, 30 Mar 2011 05:52:15 -0700 (PDT) Received: from [192.168.1.183] (dsl-hkibrasgw2-ff7ac300-240.dhcp.inet.fi [88.195.122.240]) by mx.google.com with ESMTPS id x14sm34845eeh.20.2011.03.30.05.52.13 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 30 Mar 2011 05:52:13 -0700 (PDT) Message-ID: <4D93277B.7060503@enterprisedb.com> Date: Wed, 30 Mar 2011 15:52:11 +0300 From: Heikki Linnakangas User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; fi-FI; rv:1.9.1.16) Gecko/20110307 Icedove/3.0.11 MIME-Version: 1.0 To: =?UTF-8?B?6auY5aKe55Cm?= CC: Simon Riggs , Jesper Krogh , Robert Haas , pgsql-hackers Subject: Re: crash-safe visibility map, take four References: <4D89902C.7000004@krogh.cc> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-5 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201103/1808 X-Sequence-Number: 185058 On 30.03.2011 06:24, 高增琦 wrote: > Should we do full-page write for visibilitymap all the time? > Now, when clear visiblitymap, there is no full-page write for vm > since we don't save buffer info in insert/update/delete's log. > > The full-page write is used to protect pages from disk failure. Without it, > 1) set vm: the vm bits that should be set to 1 may still be 0 > 2) clear vm: the vm bits that should be set to 0 may still be 1 > Are these true? Or the page is totally unpredictable? Not quite. The WAL replay will set or clear vm bits, regardless of full page writes. Full page writes protect from torn pages, ie. the problem where some operations on a page have made it to disk while others have not. That's not a problem for VM pages, as each bit on the page can be set or cleared individually. But for something like a heap page where you have an offset in the beginning of the page that points to the tuple elsewhere on the page, you have to ensure that they stay in sync, even if you don't otherwise care if the update makes it to disk or not. > Another question: > To address the problem in > http://archives.postgresql.org/pgsql-hackers/2010-02/msg02097.php > , should we just clear the vm before the log of insert/update/delete? > This may reduce the performance, is there another solution? Yeah, that's a straightforward way to fix it. I don't think the performance hit will be too bad. But we need to be careful not to hold locks while doing I/O, which might require some rearrangement of the code. We might want to do a similar dance that we do in vacuum, and call visibilitymap_pin first, then lock and update the heap page, and then set the VM bit while holding the lock on the heap page. -- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com