Re: Crash in gist insertion on pathological box data

From: Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>
To: Martijn van Oosterhout <kleptog(at)svana(dot)org>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Crash in gist insertion on pathological box data
Date: 2009-03-28 14:28:24
Message-ID: 877i29en7b.fsf@news-spur.riddles.org.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

>>>>> "Martijn" == Martijn van Oosterhout <kleptog(at)svana(dot)org> writes:

>> The nature of the problem is this: if gist_box_picksplit doesn't
>> find a good disposition on the first try, then it tries to split
>> the data again based on the positions of the box centers. But
>> there's a problem here with floating-point rounding; it's possible
>> for the average of N floating-point values to be strictly greater
>> (or less) than all of the values individually, and the function
>> then returns with, for example, all the entries assigned to the
>> left node, and nothing in the right node. This causes gistSplit to
>> try and split the left node again, with predictable results.

Martijn> ISTM the simplest solution here is detect that everything
Martijn> has been put in one node (left or right) and in that case
Martijn> just split the list straight down the middle (since clearly
Martijn> it doesn't matter on which side they appear.).

It's not quite so simple; we know that not all the values are equal,
since that's checked for earlier in the code (if they're all actually
equal they just get split down the middle). In this specific case the
values could actually be quite different, since we're only looking
at the centers; and with, say, a large number of very different size
boxes all centered on the same point, it would be preferable to split
them so that at least one node has a smaller union.

I'm interested to see what Oleg's solution (see other thread) is.

--
Andrew.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Gierth 2009-03-28 14:38:26 Re: TODO item
Previous Message Bruce Momjian 2009-03-28 14:24:10 Re: 8.4 release notes proof reading 1/2