Bug 816553 - Duplicate rows caused by lazy_create + missing unique constraint
Summary: Duplicate rows caused by lazy_create + missing unique constraint
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Beaker
Classification: Retired
Component: scheduler
Version: 0.8
Hardware: Unspecified
OS: Unspecified
urgent
high
Target Milestone: HOTFIX
Assignee: Dan Callaghan
QA Contact:
URL:
Whiteboard:
: 816638 (view as bug list)
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-04-26 11:53 UTC by Dan Callaghan
Modified: 2012-04-27 03:12 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2012-04-27 03:12:24 UTC


Attachments (Terms of Use)

Description Dan Callaghan 2012-04-26 11:53:53 UTC
In the new implementation of MappedObject.lazy_create (as of 0.8.2) it relies on a suitable unique constraint being present for the columns passed to it.

We are calling lazy_create for the following tables without the necessary unique constraints:

    task_type
    task_package
    device_class
    device

This causes duplicate rows to be inserted, which manifests as problems in other parts of the code which are calling .one() on a query expecting a single unique result.

The first of this reported by users is:

    XML-RPC fault: <class 'bkr.common.bexceptions.BX'>:'Invalid Task Type: Multihost'

when invoking bkr workflow commands, however there are many places which would exhibit similar failures due to the duplicate rows.

Comment 1 Dan Callaghan 2012-04-26 12:27:16 UTC
Patch posted to Gerrit:

http://gerrit.beaker-project.org/1034

Comment 2 Dan Callaghan 2012-04-27 03:12:24 UTC
Fix released.

Comment 3 Dan Callaghan 2012-04-27 03:12:32 UTC
*** Bug 816638 has been marked as a duplicate of this bug. ***


Note You need to log in before you can comment on or make changes to this bug.