]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commit
Fix a race condition in agents status update code
authorRoman Podoliaka <rpodolyaka@mirantis.com>
Wed, 27 Nov 2013 16:57:56 +0000 (18:57 +0200)
committerRoman Podoliaka <rpodolyaka@mirantis.com>
Mon, 9 Dec 2013 13:18:34 +0000 (15:18 +0200)
commit5529071bf1393d0d448bc495cc906a68bc30a820
tree39a6e6cf61d68073beba02d75325fe390571e866
parent3014e1e021b3fe59c75daae1734472c3a11582ee
Fix a race condition in agents status update code

Code handling agents status updates coming via RPC checks,
if a corresponding entry for the given (agent_type, host)
pair already exists in DB and updates it. And if it doesn't
exist, a new entry is created.

Without a unique constraint this can cause a race condition
resulting in adding of two agent entries having the same value
of (agent_type, host) pair.

Note, that it's already not allowed to have multiple agents of
the same type having the same host value, but currently it's
enforced only at code level, not at DB schema level, which
effectively makes race conditions possible.

Closes-Bug: #1254246

Change-Id: I1ebaa111154b3d6b34074705b579097ab730594c
neutron/db/agents_db.py
neutron/db/migration/alembic_migrations/versions/1fcfc149aca4_agents_unique_by_type_and_host.py [new file with mode: 0644]
neutron/tests/unit/db/test_agent_db.py [new file with mode: 0644]