Re: What is "index returned tuples in wrong order" for recheck supposed to guard against?

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Regina Obe <lr(at)pcorp(dot)us>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: What is "index returned tuples in wrong order" for recheck supposed to guard against?
Date: 2017-01-03 02:03:09
Message-ID: CA+TgmoaSji75DnFcf6OZuhtWwjsGPcNfKgd-8zUsWeW49BiT+A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Dec 30, 2016 at 12:51 AM, Regina Obe <lr(at)pcorp(dot)us> wrote:
> I've been trying to troubleshoot the cause of this PostGIS recheck bug we
> have reported by two people so far. The last test was a nice simple
> repeatable one that triggered the issue:
>
> https://trac.osgeo.org/postgis/ticket/3418
>
> from what I have seen this only affects cases where we are doing a distance
> check between two points, which we actually don't need to enable recheck for
> anyway, but trying to disable that seems like just shoving the real problem
> under the covers.

Agreed.

> If things are out of order, why isn't just going to was_exact = false good
> enough?
>
> I'm not sure if the mistake is in our PostGIS code or something in
> PostgreSQL recheck logic.
> If I change the elog(ERROR ...) to a elog(NOTICE, the answers are correct
> and sort order is right.
>
> Under what conditions would cmp return less than 0? I tried following the
> code in cmp_orderbyvals, but got lost
> and trying to put elog notices in to see what the distance is returning (I
> probably did it wrong), just ended up crashing by backend.

cmp would return 0 if the estimated distance returned by the index AM
were greater than the actual distance. The estimated distance can be
less than the actual distance, but it isn't allowed to be more. See
gist_bbox_distance for an example of a "lossy" distance calculation,
and more generally "git show
35fcb1b3d038a501f3f4c87c05630095abaaadab".

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2017-01-03 03:02:55 Re: [PATCH] Reload SSL certificates on SIGHUP
Previous Message Thomas Munro 2017-01-03 01:43:50 Causal reads take II