From 5ad890854c29879113831f2258bdd657b74c914c Mon Sep 17 00:00:00 2001 From: Riju19 <19.riju@gmail.com> Date: Mon, 8 Apr 2019 11:12:42 +0530 Subject: [PATCH] Retry on DB deadlock when updating story Updating the updated_at time of a story when creating a new task seems to be prone to deadlocks, which results in the task not getting created. This patch retries the update thrice. Change-Id: I1e657d9eb64717f1dfbaf53d843675ee686c774d Task: 4141 Signed-off-by: Riju19 <19.riju@gmail.com> --- storyboard/db/api/stories.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/storyboard/db/api/stories.py b/storyboard/db/api/stories.py index dd07030b..7df4eb45 100644 --- a/storyboard/db/api/stories.py +++ b/storyboard/db/api/stories.py @@ -16,6 +16,8 @@ import datetime import pytz +from oslo_db import api as oslo_db_api + from sqlalchemy.orm import subqueryload from storyboard._i18n import _ @@ -274,6 +276,8 @@ def get_project_ids(story_id, current_user=None): return project_ids +@oslo_db_api.wrap_db_retry(max_retries=3, retry_on_deadlock=True, +retry_interval=0.5, inc_retry_interval=True) def story_update_updated_at(story_id): session = api_base.get_session() with session.begin(subtransactions=True):