From 0378194f59bb725294b38288265497b1d504764c Mon Sep 17 00:00:00 2001
From: John Schwarz <jschwarz@redhat.com>
Date: Mon, 9 Jan 2017 14:26:22 +0200
Subject: [PATCH] Add retry to _create_ha_port_binding

Since _create_ha_port_binding creates a RouterPort object, it bumps the
revision of the Router in an atomic fashion. If something else modified
the Router concurrently, StaleDataError may be thrown. In that case we
just want to retry the function.

Closes-Bug: #1654998
Change-Id: I7a4c58a4476ca85209d28c2d3a2cb61268e3cab6
---
 neutron/db/l3_hamode_db.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/neutron/db/l3_hamode_db.py b/neutron/db/l3_hamode_db.py
index c58e6c1033a..7e9167d00a8 100644
--- a/neutron/db/l3_hamode_db.py
+++ b/neutron/db/l3_hamode_db.py
@@ -295,6 +295,7 @@ class L3_HA_NAT_db_mixin(l3_dvr_db.L3_NAT_with_dvr_db_mixin,
 
         return num_agents
 
+    @db_api.retry_if_session_inactive()
     def _create_ha_port_binding(self, context, router_id, port_id):
         try:
             with context.session.begin():