From 0eaab450c12e33f277c31098a6792421d3f5806c Mon Sep 17 00:00:00 2001 From: Michael Johnson Date: Fri, 14 Jun 2019 09:39:47 -0700 Subject: [PATCH] Fix allocate_and_associate DB deadlock In testing we saw a DB deadlock in allocate_and_associate. This patch corrects that with a DB retry wrapper. Change-Id: I20572505e448f9b7ff6314b5167cc4c519c445fb Story: 2005893 Task: 33751 --- octavia/db/repositories.py | 1 + .../Fix-allocate_and_associate-deadlock-3ff1464421c1d464.yaml | 4 ++++ 2 files changed, 5 insertions(+) create mode 100644 releasenotes/notes/Fix-allocate_and_associate-deadlock-3ff1464421c1d464.yaml diff --git a/octavia/db/repositories.py b/octavia/db/repositories.py index 346fd40100..5a01c7ad68 100644 --- a/octavia/db/repositories.py +++ b/octavia/db/repositories.py @@ -1137,6 +1137,7 @@ class AmphoraRepository(BaseRepository): id=amphora_id).first() load_balancer.amphorae.append(amphora) + @oslo_db_api.wrap_db_retry(max_retries=5, retry_on_deadlock=True) def allocate_and_associate(self, session, load_balancer_id): """Allocate an amphora for a load balancer. diff --git a/releasenotes/notes/Fix-allocate_and_associate-deadlock-3ff1464421c1d464.yaml b/releasenotes/notes/Fix-allocate_and_associate-deadlock-3ff1464421c1d464.yaml new file mode 100644 index 0000000000..8f2e3fabbc --- /dev/null +++ b/releasenotes/notes/Fix-allocate_and_associate-deadlock-3ff1464421c1d464.yaml @@ -0,0 +1,4 @@ +--- +fixes: + - | + Fixes a potential DB deadlock in allocate_and_associate found in testing.