Revision karma allocator glacial and needed to be disabled

Bug #658124 reported by Stuart Bishop
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Launchpad itself
Fix Released
Undecided
Stuart Bishop

Bug Description

The following query no longer performs adequately under PostgreSQL 8.4:

SELECT Revision.*
FROM Revision, RevisionAuthor, ValidPersonCache
WHERE
    Revision.revision_author = RevisionAuthor.id
    AND RevisionAuthor.person = ValidPersonCache.id
    AND NOT Revision.karma_allocated
    AND EXISTS (
        SELECT true FROM Branch, BranchRevision
        WHERE BranchRevision.revision = Revision.id
            AND BranchRevision.branch = Branch.id
            AND (
                NOT (Branch.product IS NULL)
                OR NOT (Branch.distroseries IS NULL)))
LIMIT 100 OFFSET 0;

The simplest fix is to add a LIMIT into the EXISTS subquery, which I think restores the 8.3 behavior we were relying on:

SELECT Revision.*
FROM Revision, RevisionAuthor, ValidPersonCache
WHERE
    Revision.revision_author = RevisionAuthor.id
    AND RevisionAuthor.person = ValidPersonCache.id
    AND NOT Revision.karma_allocated
    AND EXISTS (
        SELECT true FROM Branch, BranchRevision
        WHERE BranchRevision.revision = Revision.id
            AND BranchRevision.branch = Branch.id
            AND (
                NOT (Branch.product IS NULL)
                OR NOT (Branch.distroseries IS NULL))
        LIMIT 1)
LIMIT 100 OFFSET 0;

A better fix is to return up to 100 rows instead of exactly 100 rows, which can be performed 10x faster:

SELECT DISTINCT * FROM (
SELECT Revision.*
FROM Revision, RevisionAuthor, ValidPersonCache, Branch, BranchRevision
WHERE
    Revision.revision_author = RevisionAuthor.id
    AND RevisionAuthor.person = ValidPersonCache.id
    AND NOT Revision.karma_allocated
    AND BranchRevision.revision = Revision.id
    AND BranchRevision.branch = Branch.id
    AND (NOT (Branch.product IS NULL) OR NOT (Branch.distroseries IS NULL))
LIMIT 100) AS Whatever;

Related branches

Revision history for this message
Stuart Bishop (stub) wrote :

The branch karma allocator has been disabled on production as it is just wasting DB resources and is unlikely to ever actually complete.

Revision history for this message
Launchpad QA Bot (lpqabot) wrote : Bug fixed by a commit
Changed in launchpad-code:
assignee: nobody → Stuart Bishop (stub)
milestone: none → 10.10
tags: added: qa-needstesting
Changed in launchpad-code:
status: New → Fix Committed
Revision history for this message
Edwin Grubbs (edwin-grubbs) wrote :

We don't know what an acceptable duration is for allocate-revision-karma.py, so we'll just keep it commented out of nightly.sh until then.

tags: added: qa-untestable
removed: qa-needstesting
Curtis Hovey (sinzui)
Changed in launchpad-code:
status: Fix Committed → Fix Released
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

Remote bug watches

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