bug comment full text search is disabled - GIN indices in pg 8.2 do not support table scans

Bug #119780 reported by Stuart Bishop
32
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Launchpad itself
Fix Released
Medium
Stuart Bishop

Bug Description

Currently searching in bug comments is disabled, since it needs use to use a GIN index (for performance). When using a GIN index, searches that are too general fail, similar to this:

launchpad_prod=# select person.id from person where person.fti @@ ftq('-lt');
ERROR: Query requires full scan, GIN doesn't support it

Seen in OOPS-524C471

To workaround this we need to look at the querytree() described in Stuart's comment below, and only do the actual search if we know that we will get back a result. After we've done this, we should search in bug comments again.

Tags: lp-bugs search
Revision history for this message
Stuart Bishop (stub) wrote :
Changed in launchpad:
assignee: nobody → stub
importance: Undecided → High
status: Unconfirmed → Confirmed
Revision history for this message
Christian Reis (kiko) wrote :

Is there a workaround for this issue?

Revision history for this message
Diogo Matsubara (matsubara) wrote :

<kiko> Is there a workaround for this issue?
<stub> No. We need to revert the indexes or put up with it until it is fixed upstream.

Lowering importance since it happens only using specific search terms as seen by OOPS-523A69 and OOPS-524C471. Meanwhile stub will poke psgsql developer regarding the GIN limitations.

Changed in launchpad:
importance: High → Medium
Revision history for this message
Stuart Bishop (stub) wrote :

We need to revert. If a fix is forthcoming it won't be around until 8.4 most likely. We need to revert to GIST indexes.

Revision history for this message
Diogo Matsubara (matsubara) wrote :

Stuart,
do you plan to revert in the next rollout?

Revision history for this message
Stuart Bishop (stub) wrote : Re: [Bug 119780] Re: GIN indexes cause some slow queries to fail entirely

Diogo Matsubara wrote:
> Stuart,
> do you plan to revert in the next rollout?
>

No - rebuilding the indexes will take 6 or 7 hours. It can be done live, but
will cause occasional OOPSes to users for occasional 5 minute periods.

We either need to:
 - Take launchpad down for a long time and do them all at once
 - Schedule regular downtime when stuff like this can be done.
   We can do it it 8 1 hour chunks instead of one long one
 - Do it live.

I'm not sure whose call it is on how we proceed.

--
Stuart Bishop <email address hidden> http://www.canonical.com/
Canonical Ltd. http://www.ubuntu.com/

Revision history for this message
Diogo Matsubara (matsubara) wrote : Re: GIN indexes cause some slow queries to fail entirely

Talked to kiko about this and he suggested to do it live over two Sundays. Stuart, is that feasible?

It seems to be the less disruptive alternative.

Revision history for this message
Stuart Bishop (stub) wrote : Re: [Bug 119780] Re: GIN indexes cause some slow queries to fail entirely

Diogo Matsubara wrote:
> Talked to kiko about this and he suggested to do it live over two
> Sundays. Stuart, is that feasible?
>
> It seems to be the less disruptive alternative.
>

Sure. I'll start this weekend.

--
Stuart Bishop <email address hidden> http://www.canonical.com/
Canonical Ltd. http://www.ubuntu.com/

Changed in launchpad:
status: Confirmed → In Progress
Stuart Bishop (stub)
Changed in launchpad:
status: In Progress → Fix Released
Revision history for this message
Stuart Bishop (stub) wrote : Re: GIN indexes cause some slow queries to fail entirely

Reopening as we might have a work around that enables us to use GIN indexes. We need GIN indexes to allow us to start searching in bug comments again, as the GIST indexes are just too slow.

The error occurs when a full scan is needed, and the GIN index type does not support this and fails. The work around is to inspect the query tree of the query to see if it will require a full scan, and if so, return a 'Query too general' error message to the user.

launchpad_prod=# select querytree(ftq('-lt'));
 querytree
-----------
 T
(1 row)

launchpad_prod=# select querytree(ftq('gin (index OR indexes) fail'));
               querytree
----------------------------------------
 'gin' & ( 'index' | 'index' ) & 'fail'
(1 row)

If the querytree() function returns 'T', that query will fail if it is
applied to a GIN index.

Changed in launchpad:
status: Fix Released → Confirmed
Revision history for this message
Christian Reis (kiko) wrote :

So what we need to do is to update BugTaskSet.search() to look before it leaps, in other words? Nice job.

Revision history for this message
Stuart Bishop (stub) wrote : Re: [Bug 119780] Re: GIN indexes cause some slow queries to fail entirely

Christian Reis wrote:
> So what we need to do is to update BugTaskSet.search() to look before it
> leaps, in other words? Nice job.

Yes, and any other places that are searching the bug or message full text
indexes. I don't know if the support tracker is searching the comment spool
or not.

We can leave the other full text indexes as GIST for the time being as they
are not having problems.

--
Stuart Bishop <email address hidden> http://www.canonical.com/
Canonical Ltd. http://www.ubuntu.com/

Revision history for this message
Christian Reis (kiko) wrote : Re: GIN indexes cause some slow queries to fail entirely

Let's try that workaround!

Revision history for this message
Christian Reis (kiko) wrote :

Bjorn, reassign as necessary.

Changed in launchpad:
assignee: stub → bjornt
Joey Stanford (joey)
Changed in launchpad:
milestone: 1.1.10 → 1.1.11
Changed in launchpad:
milestone: 1.1.11 → 1.1.12
description: updated
Changed in launchpad:
milestone: 1.1.12 → none
Revision history for this message
Jerzy Jalocha N (jjalocha) wrote : Re: GIN indexes cause some searches of bug comments to fail

Is it possible that this bug causes searches to fail also in the bug title and body? I have an open Question #22884 in Launchpad itself about that.

Revision history for this message
Björn Tillenius (bjornt) wrote :

No, this bug doesn't affect searches in the title and body.

Revision history for this message
Jerzy Jalocha N (jjalocha) wrote :

Thanks, Björn, my question got answered, too, and I can confirm it has nothing to do with this bug.

Revision history for this message
Graham Binns (gmb) wrote :

This bug has been cited by Stuart on-list as the cause for bug #186262 (whether that makes the latter bug a dupe of this one I'm not sure).

Revision history for this message
Björn Tillenius (bjornt) wrote : Re: [Bug 119780] Re: GIN indexes cause some searches of bug comments to fail

On Mon, Jan 28, 2008 at 08:11:32AM -0000, Graham Binns wrote:
> This bug has been cited by Stuart on-list as the cause for bug #186262
> (whether that makes the latter bug a dupe of this one I'm not sure).

No, it's not a dupe. This bug is about searching comments, while bug
#186262
is about searching in the bug description. I don't think there's
a single fix which will fix both cases.

Revision history for this message
Eleanor Berger (intellectronica) wrote : Re: [Bug 119780] Re: GIN indexes cause some searches of bug comments to fail

On 28/01/2008, Björn Tillenius <email address hidden> wrote:
> On Mon, Jan 28, 2008 at 08:11:32AM -0000, Graham Binns wrote:
> > This bug has been cited by Stuart on-list as the cause for bug #186262
> > (whether that makes the latter bug a dupe of this one I'm not sure).
>
> No, it's not a dupe. This bug is about searching comments, while bug
> #186262 is about searching in the bug description. I don't think there's
> a single fix which will fix both cases.

I wonder whether it's worth (and at all possible) to maintain both GIN
and GiST indexes, the latter not including comments, and fall back to
searching the GiST (but not the comments) if the searching the GIN
indexes proves impossible. Then again, this may be a bad idea, if only
because of the complexity involved.

Changed in malone:
assignee: Björn Tillenius (bjornt) → nobody
summary: - GIN indexes cause some searches of bug comments to fail
+ bug comment full text search is disabled - GIN indices in pg 8.2 do not
+ support table scans
Revision history for this message
Stuart Bishop (stub) wrote :

This issue was resolved by reverting. We can switch to GIN indexes with PG 9.0.

Changed in launchpad:
status: Triaged → Fix Released
assignee: nobody → Stuart Bishop (stub)
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Related questions

Remote bug watches

Bug watches keep track of this bug in other bug trackers.