Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 349D1632CD5 for ; Sun, 15 Aug 2010 18:59:15 -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 72678-07 for ; Sun, 15 Aug 2010 21:59:07 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id 1F83F632B09 for ; Sun, 15 Aug 2010 18:59:08 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id o7FLx6Vm006184; Sun, 15 Aug 2010 17:59:06 -0400 (EDT) To: Robert Haas cc: pgsql-hackers@postgresql.org Subject: Re: DropRelFileNodeBuffers API change (was Re: [BUGS] BUG #5599: Vacuum fails due to index corruption issues) In-reply-to: <5884.1281908348@sss.pgh.pa.us> References: <201008042147.o74LlCge057659@wwwmaster.postgresql.org> <1280978913-sup-5475@alvh.no-ip.org> <8B7319E089E48047A0B688CE9CF54FD855C3C916@USRES8MAIL.asg.com> <1880.1281020817@sss.pgh.pa.us> <3092.1281898690@sss.pgh.pa.us> <5884.1281908348@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Sun, 15 Aug 2010 17:39:08 -0400" Date: Sun, 15 Aug 2010 17:59:06 -0400 Message-ID: <6183.1281909546@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-5 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201008/1046 X-Sequence-Number: 167849 I wrote: > Robert Haas writes: >> Could we avoid this >> altogether by allocating a new relfilenode on truncate? > Then we'd have to copy all the data we *didn't* truncate, which is > hardly likely to be a win. There is one thing we could do pretty easily. AFAICS there are presently just two users of smgrtruncate: vacuumlazy.c and heap_truncate. The latter is used primarily for ON COMMIT DELETE ROWS. AFAICS we could still use drop-dirty-buffers semantics for that. In event of a truncate failure, we'd have garbage data on disk, but it doesn't matter because that data would represent rows inserted by the transaction that was aborted by the truncation failure, so later transactions would ignore it anyway. Now the indexes on such a temp table are a bigger problem, but we have pretty fatal heap-to-index consistency issues anyhow if one of the interrelated truncates fails. We could probably minimize the danger if we did things in the right order: truncate indexes to zero length, truncate table to zero length, rebuild indexes as empty. However, I'm not sure that we want to do that in the back branches, because it would require adding write-or-drop booleans to some higher-level functions like smgrtruncate, thus greatly increasing the risk of breaking 3rd-party code. regards, tom lane