]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commit
Add deadlock retry to API and ML2 RPC port update
authorKevin Benton <blak111@gmail.com>
Sun, 14 Jun 2015 01:45:19 +0000 (18:45 -0700)
committerKevin Benton <blak111@gmail.com>
Wed, 17 Jun 2015 09:06:02 +0000 (02:06 -0700)
commit4e77442d529d9803ff90de905b846af940eaf382
treeb86154f0c49a104786d03763724bbe96b601e23f
parent1ab4fc7319010ddd5584451feccf78b704bd09c6
Add deadlock retry to API and ML2 RPC port update

With the switch to the pymsql SQL driver, eventlet will now yield
during database transactions. This greatly increased our probability
of multiple coroutines running transactions on the same table that
result in deadlocks.

These deadlocks could result from many things including the following:
* a coroutine holding a pessimistic "SELECT for UPDATE" lock when
  another tries to update the locked records
* two coroutines both issue update statements using a WHERE clause
  invalidated by the other update (e.g. from a compare and swap approach)
* two coroutines insert records that, when combined, violate a unique
  constraint on the table in a master-master Galera deployment
* any two workers using "SELECT for UPDATE" in a master-master Galera
  deployment (write-set certification failure translates to deadlock)

This problem is exacerbated by the switch to multiple API and RPC
workers, each of which can lead to most of the errors above even
without the switch to pymysql.

This patch adds a deadlock retry decorator to the delete, create,
and update methods at the HTTP API layer. Additionally, it adds a
decorator to the update_port_status AMQP API in ML2 since it updates
the port table, which is a heavily locked table by ML2 making it a
prime candidate for deadlocks.

Nova has had relied on the deadlock retry mechanism for quite some
time now. We were limping along by not using additional workers and
by relying on the unyielding nature of the MySQL C driver to
serialize everything.

Closes-Bug: #1464612
Change-Id: I635cc49ca69f589f99ab145d4d51e511b24194d2
neutron/api/v2/base.py
neutron/plugins/ml2/plugin.py