Re: [HACKERS] tables > 1 gig - Mailing list pgsql-hackers

From Bruce Momjian
Subject Re: [HACKERS] tables > 1 gig
Date
Msg-id 199906181647.MAA29231@candle.pha.pa.us
Whole thread Raw
In response to RE: [HACKERS] tables > 1 gig  ("Hiroshi Inoue" <Inoue@tpf.co.jp>)
Responses Re: [HACKERS] tables > 1 gig
List pgsql-hackers
Thank you.  Applied.

[Charset iso-8859-1 unsupported, filtering to ASCII...]
> > 
> > > > Yes, I can see your point.  It would show them different views of the
> > > > table.
> > > >
> > > > So, as you were saying, we have no way of invalidating file 
> > descriptors
> > > > of other backends for secondary segments.
> > > 
> > > > Why does truncating the file
> > > > not work?  Any ideas?
> > > >
> > > 
> > > I have gotten no bug reports for my trial implementation.
> > > AFAIK,only Ole Gjerde has tested my patch.
> > > Is it sufficient ?
> > 
> > Yes.  We need something, and maybe after we add it, people can do
> > testing and find any problems.  It is better to apply it than to leave
> > it as it currently exists, no?
> >
> 
> OK,here is my patch for PostgreSQL6.5-release.
> 
> Regards.
> 
> Hiroshi Inoue
> Inoue@tpf.co.jp
> 
> *** storage/smgr/md.c.orig    Fri Jun 11 12:20:06 1999
> --- storage/smgr/md.c    Fri Jun 18 15:10:54 1999
> ***************
> *** 674,684 ****
>       segno = 0;
>       for (;;)
>       {
> !         if (v->mdfd_lstbcnt == RELSEG_SIZE
> !             || (nblocks = _mdnblocks(v->mdfd_vfd, BLCKSZ)) == RELSEG_SIZE)
>           {
> - 
> -             v->mdfd_lstbcnt = RELSEG_SIZE;
>               segno++;
>   
>               if (v->mdfd_chain == (MdfdVec *) NULL)
> --- 674,685 ----
>       segno = 0;
>       for (;;)
>       {
> !         nblocks = _mdnblocks(v->mdfd_vfd, BLCKSZ);
> !         if (nblocks > RELSEG_SIZE)
> !             elog(FATAL, "segment too big in mdnblocks!");
> !         v->mdfd_lstbcnt = nblocks;
> !         if (nblocks == RELSEG_SIZE)
>           {
>               segno++;
>   
>               if (v->mdfd_chain == (MdfdVec *) NULL)
> ***************
> *** 711,732 ****
>       MdfdVec    *v;
>   
>   #ifndef LET_OS_MANAGE_FILESIZE
> !     int            curnblk;
>   
>       curnblk = mdnblocks(reln);
> !     if (curnblk / RELSEG_SIZE > 0)
> !     {
> !         elog(NOTICE, "Can't truncate multi-segments relation %s",
> !             reln->rd_rel->relname.data);
> !         return curnblk;
> !     }
>   #endif
>   
>       fd = RelationGetFile(reln);
>       v = &Md_fdvec[fd];
>   
>       if (FileTruncate(v->mdfd_vfd, nblocks * BLCKSZ) < 0)
>           return -1;
>   
>       return nblocks;
>   
> --- 712,766 ----
>       MdfdVec    *v;
>   
>   #ifndef LET_OS_MANAGE_FILESIZE
> !     int            curnblk,
> !                 i,
> !                 oldsegno,
> !                 newsegno,
> !                 lastsegblocks;
> !     MdfdVec            **varray;
>   
>       curnblk = mdnblocks(reln);
> !     if (nblocks > curnblk)
> !         return -1;
> !     oldsegno = curnblk / RELSEG_SIZE;
> !     newsegno = nblocks / RELSEG_SIZE;
> ! 
>   #endif
>   
>       fd = RelationGetFile(reln);
>       v = &Md_fdvec[fd];
>   
> + #ifndef LET_OS_MANAGE_FILESIZE
> +     varray = (MdfdVec **)palloc((oldsegno + 1) * sizeof(MdfdVec *));
> +     for (i = 0; i <= oldsegno; i++)
> +     {
> +         if (!v)
> +             elog(ERROR,"segment isn't open in mdtruncate!");
> +         varray[i] = v;
> +         v = v->mdfd_chain;
> +     }
> +     for (i = oldsegno; i > newsegno; i--)
> +     {
> +         v = varray[i];
> +         if (FileTruncate(v->mdfd_vfd, 0) < 0)
> +         {
> +             pfree(varray);
> +             return -1;
> +         }
> +         v->mdfd_lstbcnt = 0;
> +     }
> +     /* Calculate the # of blocks in the last segment */
> +     lastsegblocks = nblocks - (newsegno * RELSEG_SIZE);
> +     v = varray[i];
> +     pfree(varray);
> +     if (FileTruncate(v->mdfd_vfd, lastsegblocks * BLCKSZ) < 0)
> +         return -1;
> +     v->mdfd_lstbcnt = lastsegblocks;
> + #else
>       if (FileTruncate(v->mdfd_vfd, nblocks * BLCKSZ) < 0)
>           return -1;
> +     v->mdfd_lstbcnt = nblocks;
> + #endif
>   
>       return nblocks;
> 


--  Bruce Momjian                        |  http://www.op.net/~candle maillist@candle.pha.pa.us            |  (610)
853-3000+  If your life is a hard drive,     |  830 Blythe Avenue +  Christ can be your backup.        |  Drexel Hill,
Pennsylvania19026
 


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: [HACKERS] New TODO item
Next
From: Bruce Momjian
Date:
Subject: Re: [HACKERS] Re: Apparent bug in _make_subplan