Re: Pb importing data in v. 7.0.3 - Mailing list pgsql-general

From Tom Lane
Subject Re: Pb importing data in v. 7.0.3
Date
Msg-id 19927.978582326@sss.pgh.pa.us
Whole thread Raw
In response to Re: Pb importing data in v. 7.0.3  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Pb importing data in v. 7.0.3
List pgsql-general
> "Herve Piedvache" <herve@elma.fr> writes:
>> When doing a "psql -e mydatabase < db", an error occured when recreating
>> indexes.
>> The error is :
>> -------------------------
>> FATAL 1:  btree: failed to add item to the page in _bt_sort (2)

After digging around in the failed process, I now understand what's
happening.  This error occurs when index building needs to insert a
new index item on a disk page, and finds that there isn't enough space
to insert the item, so it splits the page ... but then there *still*
isn't enough space on the right-hand split page for the new index
item.  This can happen in pathological cases, because the choice of
split point is constrained by 7.0's handling of chains of equal keys;
it doesn't want to split in the middle of a chain.  In the example
at hand, it seems that the pre-split page contained a single key
of a lower value (call it 'A') and all the remaining keys were of the
same higher value (call it 'AAAA').  We split the page in such a way
that the left sub-page has the 'A' and the right page has all the
'AAAA's ... which leaves us enough room on the right page to insert
an 'A', but unfortunately what we want to insert is 'AAAA' and it
doesn't fit.

The equal-key logic has been entirely rewritten for 7.1, and I believe
that it's not subject to this bug any longer.  I'm very hesitant to try
to jury-rig a solution for 7.0, though, because the old equal-key
handling is so complex and fragile that some other, more common case
might break.  How do you feel about running 7.1 beta?

            regards, tom lane

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: 7.1 PL/pgSQL EXECUTE Command
Next
From: "Anthony E . Greene"
Date:
Subject: Re: Problems about extracting data with cgi's