Bug 773124 - race condition when adding distros
Summary: race condition when adding distros
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Beaker
Classification: Retired
Component: lab controller
Version: 0.8
Hardware: Unspecified
OS: Unspecified
low
high vote
Target Milestone: ---
Assignee: Dan Callaghan
QA Contact:
URL:
Whiteboard:
Depends On: 752869
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-01-11 01:00 UTC by Dan Callaghan
Modified: 2019-05-22 13:41 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of: 752869
Environment:
Last Closed: 2012-04-26 07:16:32 UTC


Attachments (Terms of Use)

Description Dan Callaghan 2012-01-11 01:00:16 UTC
+++ This bug was initially created as a clone of Bug #752869 +++

Description of problem:
If two lab controllers try to add the same new distro at the same time only one of them will succeed.

Comment 1 Dan Callaghan 2012-01-11 01:03:08 UTC
Bug 752869 was fixed in Beaker 0.8 with a workaround: the call to add a new distro was split into two separate calls, and the first (subject to the race) was permitted to fail.

The proper fix for this bug is to use MappedObject.lazy_create, and to make that method be race-free using nested transactions.

    session.begin_nested()
    try:
        item = cls(**kwargs)
        session.commit()
    except IntegrityError:
        session.rollback()
        item = cls.query.filter_by(**kwargs).one()


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