Received: from localhost (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id AC3F864FC3B for ; Mon, 24 Nov 2008 04:05:21 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 39494-06 for ; Mon, 24 Nov 2008 04:05:12 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from nf-out-0910.google.com (nf-out-0910.google.com [64.233.182.187]) by mail.postgresql.org (Postfix) with ESMTP id 85F4764FC42 for ; Mon, 24 Nov 2008 04:05:12 -0400 (AST) Received: by nf-out-0910.google.com with SMTP id c7so1035619nfi.23 for ; Mon, 24 Nov 2008 00:05:11 -0800 (PST) Received: by 10.210.66.1 with SMTP id o1mr3260325eba.193.1227513910814; Mon, 24 Nov 2008 00:05:10 -0800 (PST) Received: from ?80.222.79.63? (dsl-hkibrasgw2-fe4fde00-63.dhcp.inet.fi [80.222.79.63]) by mx.google.com with ESMTPS id f4sm1792253nfh.27.2008.11.24.00.05.08 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 24 Nov 2008 00:05:09 -0800 (PST) Message-ID: <492A6032.6080000@enterprisedb.com> Date: Mon, 24 Nov 2008 10:05:06 +0200 Organization: EnterpriseDB User-Agent: Mozilla-Thunderbird 2.0.0.17 (X11/20081018) MIME-Version: 1.0 To: Tom Lane CC: PostgreSQL-development Subject: Re: Visibility map, partial vacuums References: <4905AE17.7090305@enterprisedb.com> <491D376B.9000608@enterprisedb.com> <491D7F52.6070908@enterprisedb.com> <4925664C.3090605@enterprisedb.com> <26361.1227467112@sss.pgh.pa.us> In-Reply-To: <26361.1227467112@sss.pgh.pa.us> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit From: Heikki Linnakangas X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200811/1519 X-Sequence-Number: 128231 Tom Lane wrote: > * ISTM that the patch is designed on the plan that the PD_ALL_VISIBLE > page header flag *must* be correct, but it's really okay if the backing > map bit *isn't* correct --- in particular we don't trust the map bit > when performing antiwraparound vacuums. This isn't well documented. Right. Will add comments. We can't use the map bit for antiwraparound vacuums, because the bit doesn't tell you when the tuples have been frozen. And we can't advance relfrozenxid if we've skipped any pages. I've been thinking that we could add one frozenxid field to each visibility map page, for the oldest xid on the heap pages covered by the visibility map page. That would allow more fine-grained anti-wraparound vacuums as well. > * Also, I see that vacuum has a provision for clearing an incorrectly > set PD_ALL_VISIBLE flag, but shouldn't it fix the map too? Yes, will fix. Although, as long as we don't trust the visibility map, no real damage would be done. > * It would be good if the visibility map fork were never created until > there is occasion to set a bit in it; this would for instance typically > mean that temp tables would never have one. I think that > visibilitymap.c doesn't get this quite right --- in particular > vm_readbuf seems willing to create/extend the fork whether its extend > argument is true or not, so it looks like an inquiry operation would > cause the map fork to be created. It should be possible to act as > though a nonexistent fork just means "all zeroes". The visibility map won't be inquired unless you vacuum. This is a bit tricky. In vacuum, we only know whether we can set a bit or not, after we've acquired a cleanup lock on the page, and scanned all the tuples. While we're holding a cleanup lock, we don't want to do I/O, which could potentially block out other processes for a long time. So it's too late to extend the visibility map at that point. I agree that vm_readbuf should not create the fork if 'extend' is false, that's an oversight, but it won't change the actual behavior because visibilitymap_test calls it with 'extend' true. Because of the above. I will add comments about that, though, there's nothing describing that currently. > * heap_insert's all_visible_cleared variable doesn't seem to get > initialized --- didn't your compiler complain? Hmph, I must've been compiling with -O0. > * You missed updating SizeOfHeapDelete and SizeOfHeapUpdate Thanks. -- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com