etcd driver implement allocate_unique_key in a raceful manner

Bug #1713496 reported by Dima Kuznetsov
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
DragonFlow
Fix Released
High
Unassigned

Bug Description

The code that allocates unique keys for etcd is susceptible to a race where a number of execution contexts will get value 1.

When a unique key is generated it is retrieved, incremented, and stored using compare&swap operation. If a key is not present, 1 is stored and returned.

If several contexts perform the lookup at the same time, all will choose 1 and write it to the database.

Dima Kuznetsov (dimakuz)
summary: - etcd driver implement allocate_unique_key in a receful manner
+ etcd driver implement allocate_unique_key in a raceful manner
Revision history for this message
Omer Anson (omer-anson) wrote :

This bug needs two side-by-side solutions:
1. The etcd driver should avoid race conditions on the first unique ID allocation
2. All unique keys should be allocated by df-db init and df-db upgrade (Where new models are added between versions).

Changed in dragonflow:
importance: Undecided → High
importance: High → Medium
Omer Anson (omer-anson)
Changed in dragonflow:
importance: Medium → High
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to dragonflow (master)

Reviewed: https://review.openstack.org/507814
Committed: https://git.openstack.org/cgit/openstack/dragonflow/commit/?id=a9de80cb5d523dba3dcc1da3bbf135ecd1ed2d46
Submitter: Jenkins
Branch: master

commit a9de80cb5d523dba3dcc1da3bbf135ecd1ed2d46
Author: Lihi Wishnitzer <email address hidden>
Date: Wed Sep 27 13:20:55 2017 +0300

    Allocate unique key in etcd using "create"

    Create use atomic transaction in order to verify that
    the value wasn't exist before updating the DB.

    This should solve our race-condition. If two (or more)
    allocations will occure at the same time, after the first
    allocation will succeed, the others will fail.

    Change-Id: Id72c7c35415a68c1eebc05ed3126f59793d5c475
    Closes-bug: #1713496

Changed in dragonflow:
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

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