RE: [HACKERS] tables > 1 gig - Mailing list pgsql-hackers
| From | Hiroshi Inoue |
|---|---|
| Subject | RE: [HACKERS] tables > 1 gig |
| Date | |
| Msg-id | 000401beb951$616a5280$2801007e@cadzone.tpf.co.jp Whole thread Raw |
| In response to | Re: [HACKERS] tables > 1 gig (Bruce Momjian <maillist@candle.pha.pa.us>) |
| Responses |
Re: [HACKERS] tables > 1 gig
|
| List | 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@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;
pgsql-hackers by date: