Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 402D9632316 for ; Sun, 15 Aug 2010 18:17:59 -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 53787-04 for ; Sun, 15 Aug 2010 21:17:51 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-iw0-f174.google.com (mail-iw0-f174.google.com [209.85.214.174]) by mail.postgresql.org (Postfix) with ESMTP id 119D06321F7 for ; Sun, 15 Aug 2010 18:17:51 -0300 (ADT) Received: by iwn7 with SMTP id 7so973745iwn.19 for ; Sun, 15 Aug 2010 14:17:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=oIPqZUeq59spQ51AWHR57vpCSsi0u6FC0xr2/sDW8gk=; b=BuDt0rR2BKF+mADrLOGFO6TKTPiWbXngJfHJ6VSPWxYDwyceSL7fX3sF76jKuFy3KD Lc1sNtlkj4IewI5NJ1ZhQTpgKME+v5BDDxgx5mjhZuKZloUJha/vLT7a5k944ZCT8c51 GCvAs3EDuj0RFenPZPRaPCG8XvHx1gWBrCEZg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=yEgnOhOEKbc+cRNaLD3yXmZ7dWN8IszH6ZnXld4P1DKiJV+X0WLPD1mFcqZ7vd2OR8 D+KPnxKzH6/r3b5960XSJDlZRcBfVrxMOzldKlQr91xjY1/E0dKgxx3pGeLWorJ+h0t7 POaz+DztaaFFiZqzXH8SaQioXBNSYArfPfbcs= MIME-Version: 1.0 Received: by 10.231.15.70 with SMTP id j6mr5026976iba.12.1281907070825; Sun, 15 Aug 2010 14:17:50 -0700 (PDT) Received: by 10.231.36.194 with HTTP; Sun, 15 Aug 2010 14:17:50 -0700 (PDT) In-Reply-To: <3092.1281898690@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> Date: Sun, 15 Aug 2010 17:17:50 -0400 Message-ID: Subject: Re: DropRelFileNodeBuffers API change (was Re: [BUGS] BUG #5599: Vacuum fails due to index corruption issues) From: Robert Haas To: Tom Lane Cc: pgsql-hackers@postgresql.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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, RCVD_IN_DNSWL_NONE=-0.0001 X-Spam-Level: X-Archive-Number: 201008/1041 X-Sequence-Number: 167844 On Sun, Aug 15, 2010 at 2:58 PM, Tom Lane wrote: > In the discussion of bug #5599 we pretty much agreed to do this: >> Seems like we need to think harder about recovering from a truncate >> failure. =A0A few random ideas: >> 1. Write the dirty buffers before dropping them. =A0Kind of ugly from a >> performance viewpoint, but simple and safe. > > I looked at making this happen, and noted that DropRelFileNodeBuffers > is used both for the truncation case and for dropping relation buffers > during smgrdounlink. =A0In the latter case, it's still appropriate to > drop dirty buffers without writing them, both for performance reasons > and because we don't really care about any errors: we have already > committed the relation DROP, and are not going to look at the file > contents again in any case. =A0So this means that two different behaviors > are now required for truncation and dropping. > > The cleanest fix is an API change to add a boolean write-or-not > parameter to DropRelFileNodeBuffers. =A0That's what I want to do in HEAD > and 9.0, but I'm unsure whether it's a safe fix in the back branches. > Does anyone have an opinion whether it's likely that any third-party > code is calling DropRelFileNodeBuffers directly? =A0If there is, then > changing its API in a minor release would be an unfriendly thing to do. > We could avoid that by some ugly expedient like inserting a second copy > of the function in back branches. > > Comments? I really hate this solution, because writing out data that we're about to throw away just in case we can't actually throw it away seems like a real waste from a performance standpoint. Could we avoid this altogether by allocating a new relfilenode on truncate? --=20 Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise Postgres Company