Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 393B1B6089F for ; Thu, 2 Jun 2011 14:40:29 -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 24152-06 for ; Thu, 2 Jun 2011 17:40:21 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pz0-f46.google.com (mail-pz0-f46.google.com [209.85.210.46]) by mail.postgresql.org (Postfix) with ESMTP id 8B390B60876 for ; Thu, 2 Jun 2011 14:40:21 -0300 (ADT) Received: by pzk9 with SMTP id 9so489103pzk.19 for ; Thu, 02 Jun 2011 10:40:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=shqss8flQmU9mRWTm4gBxx74tZVtubYxySihEXhlzeY=; b=oEXJXX9qOSaNXaRrHE6BMIQHEJN3cfXIO/YJGKI0z1Awd2rLSA6+hJKUYNGu95VgPm zg+OnV1d1w0RCvnzE0w0TxWVUWOUwijziFvkRX0JE10eYU6WcqqN6JtldTJWva+4cTXj Hxp3iUxtRgl7wnpRnO+1/lFw9kfUo6u6WqVs8= 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=dPuKQNu4nu1cZwa035pIHPGYFZ4AnjUKHZU3rz04qgNlP/KQaZ0D1Gftynmz9t/Lv4 kc4x9BW6oYAAEjw5YGwinthU7aQGLxqd/FbE6GEYdNgBzL6Y2sPKqOgrdCoyEVrIA8u5 chR4klZhvYyTgeKOq5aKC9E87+D+8N5QZZamU= MIME-Version: 1.0 Received: by 10.68.12.226 with SMTP id b2mr435161pbc.44.1307035893716; Thu, 02 Jun 2011 10:31:33 -0700 (PDT) Received: by 10.68.56.70 with HTTP; Thu, 2 Jun 2011 10:31:33 -0700 (PDT) In-Reply-To: References: <20110530160043.GC3012@core.home> <201105310247.50055.andres@anarazel.de> <1306805168-sup-4188@alvh.no-ip.org> <201105310944.26712.andres@anarazel.de> Date: Thu, 2 Jun 2011 13:31:33 -0400 Message-ID: Subject: Re: Unlogged tables cannot be truncated twice From: Robert Haas To: Andres Freund Cc: pgsql-bugs@postgresql.org, Alvaro Herrera , =?ISO-8859-1?Q?C=E9dric_Villemain?= , Greg Sabino Mullane 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.898 tagged_above=-5 required=5 tests=BAYES_00=-1.9, FREEMAIL_FROM=0.001, RFC_ABUSE_POST=0.001 X-Spam-Level: X-Archive-Number: 201106/22 X-Sequence-Number: 30401 On Wed, Jun 1, 2011 at 1:15 PM, Robert Haas wrote: > 2011/5/31 Andres Freund : >> On Tuesday, May 31, 2011 03:27:22 Alvaro Herrera wrote: >>> Excerpts from Andres Freund's message of lun may 30 20:47:49 -0400 2011= : >>> > On Tuesday, May 31, 2011 02:35:58 AM Andres Freund wrote: >>> > > On Tuesday, May 31, 2011 02:14:00 AM Andres Freund wrote: >>> > > > On Tuesday, May 31, 2011 01:56:05 AM C=E9dric Villemain wrote: >>> > > > > I remove my own explanations as we conclude on the same thing. >>> > > > > Attached is the fix by adding a (!reindex) =A0in the index.c if= (). >>> > > > >>> > > > Thats imo wrong because it will break a plain REINDEX? >>> > > >>> > > > I think one possible correct fix would be the attached: >>> > > My version was wrong as well because it =A0did not observe >>> > > RelationTruncate's nblocks argument. That function is used to >>> > > "shorten" the relation in vacuum. So dropping the init fork there i= s >>> > > not a good idea. >>> > > >>> > > So I think it is the simpler version of simply checking the existan= ce >>> > > of the fork before creating is ok. >>> >>> Hmm, I wonder if what we should be doing here is observe isreindex in >>> index_build to avoid creating the init fork. =A0Doing smgr access at th= at >>> level seems wrong. >> isreindex doesn't contain the necessary informormation as its set doing = a >> REINDEX even though a new relfilenode is created and thus the fork needs= to be >> created. >> >> It doesn't seem terribly clean do do the !smgrexists(), I aggree with yo= u >> there. On the other hand we are calling smgrcreate() two lines down anyw= ay. I >> personally don't realy like the placement of that piece of code very muc= h. >> Doing it in index_build seems to be the wrong place. I don't think there >> really is a good place for it right now. > > I'm open to suggestions on how to rearrange this, but I think for > right now the approach you proposed upthread (add a smgrexists() test) > is probably the simplest way to fix this. Done. Your patch tested for FSM_FORKNUM instead of INIT_FORKNUM, which seemed wrong, so I changed it. I also added comments. --=20 Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company