Bug 816553

Summary: Duplicate rows caused by lazy_create + missing unique constraint
Product: [Retired] Beaker Reporter: Dan Callaghan <dcallagh>
Component: schedulerAssignee: Dan Callaghan <dcallagh>
Status: CLOSED CURRENTRELEASE QA Contact:
Severity: high Docs Contact:
Priority: urgent    
Version: 0.8CC: bpeck, dcallagh, jstodola, rmancy, stl
Target Milestone: HOTFIX   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-04-27 03:12:24 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

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. ***