]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commit
Fix a race condition in add_tunnel_endpoint()
authorRoman Podolyaka <rpodolyaka@mirantis.com>
Tue, 30 Apr 2013 12:12:15 +0000 (15:12 +0300)
committerMark McClain <mark.mcclain@dreamhost.com>
Thu, 29 Aug 2013 04:37:58 +0000 (00:37 -0400)
commit658452478fb35f3200e5d62b23d328be72d35039
tree6af8ef69c3fe2a30d483876bf61d4ad80b656024
parenta34f6f0e868bcd0a22dca4c0879247791c997434
Fix a race condition in add_tunnel_endpoint()

If there are multiple OVS agents concurrently executing
'tunnel_sync' RPC call a race condition can occur
leading to insertion of two different TunnelEndpoint
entries having the same 'id' value.

Unfortunately, we can not rely on:
  - @lockutils.synchronized(), because a Neutron installation can use
    more than one API node
  - with_lockmode('update'), because it works differently in PostgreSQL
    comparing to MySQL and doesn't guarantee that no new rows have been
    added to the table since the select query was issued. Please take a
    look at http://www.postgresql.org/files/developer/concurrency.pdf for
    more details.

The proposed fix:
  - ensures there is a unique constraint set for 'id' column
  - wraps creation of a new TunnelEndpoint entry into a
    repeatedly executed transactional block (so even if a concurrent
    DB transaction has been flushed or commited earlier than this one
    we can handle an integrity error and try again, in spite of the
    specified transactions isolation level value)

Fixes bug 1167916

Change-Id: I62dc729d595f090436199d5e1b6b98a884ead7a5
neutron/db/migration/alembic_migrations/versions/63afba73813_ovs_tunnelendpoints_id_unique.py [new file with mode: 0644]
neutron/plugins/openvswitch/ovs_db_v2.py
neutron/plugins/openvswitch/ovs_models_v2.py
neutron/tests/unit/openvswitch/test_ovs_db.py