RE: [HACKERS] tables > 1 gig

From: "Hiroshi Inoue" <Inoue(at)tpf(dot)co(dot)jp>
To: "Bruce Momjian" <maillist(at)candle(dot)pha(dot)pa(dot)us>
Cc: "PostgreSQL-development" <pgsql-hackers(at)postgreSQL(dot)org>
Subject: RE: [HACKERS] tables > 1 gig
Date: 1999-06-18 06:11:19
Message-ID: 000401beb951$616a5280$2801007e@cadzone.tpf.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

>
> > > 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(at)tpf(dot)co(dot)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;

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Vadim Mikheev 1999-06-18 06:28:30 Re: [HACKERS] Re: Apparent bug in _make_subplan
Previous Message Bruce Momjian 1999-06-18 05:32:27 Re: [HACKERS] tables > 1 gig