Re: Crash in gist insertion on pathological box data - Mailing list pgsql-hackers

From Martijn van Oosterhout
Subject Re: Crash in gist insertion on pathological box data
Date
Msg-id 20090328114834.GA8762@svana.org
Whole thread Raw
In response to Crash in gist insertion on pathological box data  (Andrew Gierth <andrew@tao11.riddles.org.uk>)
Responses Re: Crash in gist insertion on pathological box data
List pgsql-hackers
On Thu, Mar 26, 2009 at 02:39:05PM +0000, Andrew Gierth wrote:
> A user on IRC reported a crash (backend segfault) in GiST insertion
> (in 8.3.5 but I can reproduce this in today's HEAD) that turns out
> to be due to misbehaviour of gist_box_picksplit.
>
> 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.

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

Or switch algorithms, but that's more than just a bugfix.

Have a nice day,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> Please line up in a tree and maintain the heap invariant while
> boarding. Thank you for flying nlogn airlines.

pgsql-hackers by date:

Previous
From: Devrim GÜNDÜZ
Date:
Subject: New shapshot RPMs (Mar 27, 2009) are ready for testing
Next
From: Andrew Gierth
Date:
Subject: Re: TODO item