pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andres Freund <andres@anarazel.de>
To: pgsql-bugs@postgresql.org
Cc: Robert Haas <robertmhaas@gmail.com>
Cc: Alvaro Herrera <alvherre@commandprompt.com>
Cc: Cédric Villemain <cedric.villemain.debian@gmail.com>
Cc: Greg Sabino Mullane <greg@endpoint.com>
Subject: Re: Unlogged tables cannot be truncated twice
Date: Thu, 2 Jun 2011 20:52:38 +0200
Message-ID: <201106022052.39070.andres@anarazel.de> (raw)
In-Reply-To: <BANLkTimnSgHYXM+O0DrNr9M6F3hmKezN1g@mail.gmail.com>
References: <20110530160043.GC3012@core.home>
	<BANLkTi=mZFyiH_MzqBXyg+O=31n213Fz2A@mail.gmail.com>
	<BANLkTimnSgHYXM+O0DrNr9M6F3hmKezN1g@mail.gmail.com>

On Thursday, June 02, 2011 07:31:33 PM Robert Haas wrote:
> On Wed, Jun 1, 2011 at 1:15 PM, Robert Haas <robertmhaas@gmail.com> wrote:
> > 2011/5/31 Andres Freund <andres@anarazel.de>:
> >> 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édric Villemain wrote:
> >>> > > > > I remove my own explanations as we conclude on the same thing.
> >>> > > > > Attached is the fix by adding a (!reindex)  in 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  did not observe
> >>> > > RelationTruncate's nblocks argument. That function is used to
> >>> > > "shorten" the relation in vacuum. So dropping the init fork there
> >>> > > is not a good idea.
> >>> > > 
> >>> > > So I think it is the simpler version of simply checking the
> >>> > > existance 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.  Doing smgr access at that
> >>> 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
> >> you there. On the other hand we are calling smgrcreate() two lines down
> >> anyway. I personally don't realy like the placement of that piece of
> >> code very much. 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.
Wow. I don't think I ever made so many stupid mistakes when doing a two line 
change. I abviously wasn't really awake that evening. As evidenced excessively 
in that thread ;)

Thanks,

Andres



view thread (16+ messages)  latest in thread

Message-ID: <201106022052.39070.andres@anarazel.de>
Permalink:  ../201106022052.39070.andres@anarazel.de/
Also on:    postgresql.org/message-id/201106022052.39070.andres@anarazel.de

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: andres@anarazel.de, robertmhaas@gmail.com, alvherre@commandprompt.com, cedric.villemain.debian@gmail.com, greg@endpoint.com
  Subject: Re: Unlogged tables cannot be truncated twice
  In-Reply-To: <201106022052.39070.andres@anarazel.de>
  References: <20110530160043.GC3012@core.home> <BANLkTi=mZFyiH_MzqBXyg+O=31n213Fz2A@mail.gmail.com> <BANLkTimnSgHYXM+O0DrNr9M6F3hmKezN1g@mail.gmail.com> <201106022052.39070.andres@anarazel.de>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox