Re: Create index problem ( _bt_sort )

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Yasuo Ohgaki" <yasuo_ohgaki(at)hotmail(dot)com>
Cc: pgsql-admin(at)postgresql(dot)org, "Loc TREGOUT" <loic(at)cri74(dot)org>, svanegmond(at)home(dot)com, pgsql-bugs(at)postgresql(dot)org
Subject: Re: Create index problem ( _bt_sort )
Date: 2001-02-08 23:17:50
Message-ID: 13480.981674270@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin pgsql-bugs

"Yasuo Ohgaki" <yasuo_ohgaki(at)hotmail(dot)com> writes:
> raslog=# create index user2000 on log2000(username);
> FATAL 1: btree: failed to add item to the page in _bt_sort (2)

Stephen van Egmnond was kind enough to submit a self-contained example,
from which it turns out that this bug is one that was found and fixed
about a month ago (sheesh, my memory is going). Attached is a patch
that fixes it in 7.0.*.

regards, tom lane

*** src/backend/access/nbtree/nbtsort.c.orig Wed Apr 12 13:14:49 2000
--- src/backend/access/nbtree/nbtsort.c Thu Jan 4 16:51:49 2001
***************
*** 28,34 ****
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
! * $Header: /home/projects/pgsql/cvsroot/pgsql/src/backend/access/nbtree/nbtsort.c,v 1.52 2000/04/12 17:14:49 momjian Exp $
*
*-------------------------------------------------------------------------
*/
--- 28,34 ----
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
! * $Header: /home/projects/pgsql/cvsroot/pgsql/src/backend/access/nbtree/nbtsort.c,v 1.52.2.1 2001/01/04 21:51:49 tgl Exp $
*
*-------------------------------------------------------------------------
*/
***************
*** 321,327 ****
btisz,
(PageGetPageSize(npage) - sizeof(PageHeaderData) - MAXALIGN(sizeof(BTPageOpaqueData))) /3 - sizeof(ItemIdData));

! if (pgspc < btisz)
{
Buffer obuf = nbuf;
Page opage = npage;
--- 321,327 ----
btisz,
(PageGetPageSize(npage) - sizeof(PageHeaderData) - MAXALIGN(sizeof(BTPageOpaqueData))) /3 - sizeof(ItemIdData));

! while (pgspc < btisz)
{
Buffer obuf = nbuf;
Page opage = npage;
***************
*** 436,441 ****
--- 436,448 ----
* we aren't locking).
*/
_bt_wrtbuf(index, obuf);
+
+ /*
+ * Recompute pgspc and loop back to check free space again. If
+ * we were forced to split at a bad split point, we might need
+ * to split again.
+ */
+ pgspc = PageGetFreeSpace(npage);
}

/*

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Stefan Huber 2001-02-09 10:34:08 Re: Re: pgadmin
Previous Message Leonid Furman 2001-02-08 20:59:13

Browse pgsql-bugs by date

  From Date Subject
Next Message praveenkumar reddy m 2001-02-09 12:53:03 please give me the answer
Previous Message Stephen van Egmond 2001-02-08 23:07:26 Re: Backend crash while indexing large strings